Class BasePathLocationStrategy
java.lang.Object
org.apache.commons.configuration2.io.AbstractFileLocationStrategy
org.apache.commons.configuration2.io.BasePathLocationStrategy
- All Implemented Interfaces:
FileLocationStrategy
A specialized implementation of
FileLocationStrategy which tries to construct a file path from the locator's
base path and file name.
This strategies ignores the URL stored in the passed in FileLocator. It generates a path by concatenating the
base path (if present) and the file name. If the resulting path points to a valid file, the corresponding URL is
returned.
See AbstractFileLocationStrategy learn how to grant an deny URL schemes and hosts.
- Since:
- 2.0
- See Also:
-
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
ConstructorsConstructorDescriptionConstructs a new instance where URL resources are bound byAbstractFileLocationStrategy.AbstractBuilder.Constructs a new instance where URL resources are bound byAbstractFileLocationStrategy.AbstractBuilder. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Builds new instances ofProvidedURLLocationStrategy.locate(FileSystem fileSystem, FileLocator locator) Tries to locate the specified file.Methods inherited from class org.apache.commons.configuration2.io.AbstractFileLocationStrategy
toString
-
Constructor Details
-
BasePathLocationStrategy
public BasePathLocationStrategy()Constructs a new instance where URL resources are bound byAbstractFileLocationStrategy.AbstractBuilder. -
BasePathLocationStrategy
Constructs a new instance where URL resources are bound byAbstractFileLocationStrategy.AbstractBuilder.- Parameters:
builder- How to build the instance.- Since:
- 2.15.0
-
-
Method Details
-
builder
Builds new instances ofProvidedURLLocationStrategy.- Returns:
- a new builder.
- Since:
- 2.15.0
-
locate
Tries to locate the specified file. The method also expects theFileSystemto be used. Note that theFileLocatorobject may also contain aFileSystem, but this is optional. The passed inFileSystemshould be used, and callers must not pass a null reference for this argument. A concrete implementation has to evaluate the properties stored in theFileLocatorobject 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 uses utility methods fromFileLocatorUtilsto generate aFilefrom the locator's base path and file name. If thisFileexists, its URL is returned.- Parameters:
fileSystem- theFileSystemto 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
-