Class FileSystemLocationStrategy
java.lang.Object
org.apache.commons.configuration2.io.FileSystemLocationStrategy
- All Implemented Interfaces:
FileLocationStrategy
A specialized implementation of FileLocationStrategy
which uses the passed in FileSystem
to locate a
file.
This strategy implementation ignores the URL of the passed in FileLocator
and operates on its base path and
file name. These properties are passed to the locateFromURL()
method of FileSystem
. So the burden of
resolving the file is delegated to the FileSystem
.
- Since:
- 2.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlocate
(FileSystem fileSystem, FileLocator locator) Tries to locate the specified file.
-
Constructor Details
-
FileSystemLocationStrategy
public FileSystemLocationStrategy()
-
-
Method Details
-
locate
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 delegates to theFileSystem
.- 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
-