Class ClasspathLocationStrategy
- java.lang.Object
-
- org.apache.commons.configuration2.io.ClasspathLocationStrategy
-
- All Implemented Interfaces:
FileLocationStrategy
public class ClasspathLocationStrategy extends java.lang.Object implements FileLocationStrategy
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.- Since:
- 2.0
- Version:
- $Id: ClasspathLocationStrategy.java 1624601 2014-09-12 18:04:36Z oheger $
-
-
Constructor Summary
Constructors Constructor Description ClasspathLocationStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.URL
locate(FileSystem fileSystem, FileLocator locator)
Tries to locate the specified file.
-
-
-
Method Detail
-
locate
public java.net.URL locate(FileSystem fileSystem, FileLocator locator)
Tries to locate the specified file. The method also expects theFileSystem
to be used. Note that theFileLocator
object may also contain aFileSystem
, but this is optional. The passed inFileSystem
should be used, and callers must not pass a null reference for this argument. A concrete implementation has to evaluate the properties stored in theFileLocator
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.- Specified by:
locate
in interfaceFileLocationStrategy
- Parameters:
fileSystem
- theFileSystem
to be used for this operationlocator
- 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
-
-