ClasspathLocationStrategy (Apache Commons Configuration 2.15.1 API)
Description: declaration: package: org.apache.commons.configuration2.io, class: ClasspathLocationStrategy

Package org.apache.commons.configuration2.io

# Class ClasspathLocationStrategy

java.lang.Object
org.apache.commons.configuration2.io.AbstractFileLocationStrategy
org.apache.commons.configuration2.io.ClasspathLocationStrategy

All Implemented Interfaces:
  `FileLocationStrategy`

public class ClasspathLocationStrategy extends AbstractFileLocationStrategy
A specialized `FileLocationStrategy` implementation which searches for files on the class path.

This strategy implementation ignores the URL and the base path components of the passed in `FileLocator`. It tries to look up the file name on both the class path and the system class path.

See `AbstractFileLocationStrategy` learn how to grant an deny URL schemes and hosts.

Since:
  2.0
See Also:
  - `AbstractFileLocationStrategy`

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.apache.commons.configuration2.io.AbstractFileLocationStrategy

  `AbstractFileLocationStrategy.AbstractBuilder<T extends FileLocationStrategy,B extends AbstractFileLocationStrategy.AbstractBuilder<T,B>>, AbstractFileLocationStrategy.StrategyBuilder<T extends FileLocationStrategy>`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClasspathLocationStrategy()`
  Constructs a new instance.
  `ClasspathLocationStrategy(AbstractFileLocationStrategy.AbstractBuilder<?,?> builder)`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AbstractFileLocationStrategy.StrategyBuilder<ClasspathLocationStrategy>`
  `builder()`
  Builds new instances of `ProvidedURLLocationStrategy`.
  `URL`
  `locate(FileSystem fileSystem, FileLocator locator)`
  Tries to locate the specified file.

  ### Methods inherited from class org.apache.commons.configuration2.io.AbstractFileLocationStrategy

  `toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ClasspathLocationStrategy

    public ClasspathLocationStrategy()
    Constructs a new instance.

  - ### ClasspathLocationStrategy

    public ClasspathLocationStrategy(AbstractFileLocationStrategy.AbstractBuilder<?,?> builder)
    Constructs a new instance.
    Parameters:
      `builder` - How to build the instance.
    Since:
      2.15.0

- ## Method Details

  - ### builder

    public static AbstractFileLocationStrategy.StrategyBuilder<ClasspathLocationStrategy> builder()
    Builds new instances of `ProvidedURLLocationStrategy`.
    Returns:
      a new builder.
    Since:
      2.15.0

  - ### locate

    public URL locate(FileSystem fileSystem, FileLocator locator)
    Tries to locate the specified file. The method also expects the `FileSystem` to be used. Note that the `FileLocator` object may also contain a `FileSystem`, but this is optional. The passed in `FileSystem` should be used, and callers must not pass a null reference for this argument. A concrete implementation has to evaluate the properties stored in the `FileLocator` object and try to match them to an existing file. If this can be done, a corresponding URL is returned. Otherwise, result is null. Implementations should not throw an exception (unless parameters are null) as there might be alternative strategies which can find the file in question. This implementation looks up the locator's file name as a resource on the class path.
    Parameters:
      `fileSystem` - the `FileSystem` to be used for this operation
      `locator` - the object describing the file to be located
    Returns:
      a URL pointing to the referenced file if location was successful; null if the file could not be resolved