Class ProvidedURLLocationStrategy
- java.lang.Object
-
- org.apache.commons.configuration2.io.AbstractFileLocationStrategy
-
- org.apache.commons.configuration2.io.ProvidedURLLocationStrategy
-
- All Implemented Interfaces:
FileLocationStrategy
public class ProvidedURLLocationStrategy extends AbstractFileLocationStrategy
A specialized implementation ofFileLocationStrategywhich checks whether a passed inFileLocatoralready has a defined URL.FileLocatorobjects that have a URL already reference a file in an unambiguous way. Therefore, this strategy just returns the URL of the passed inFileLocator. It can be used as a first step of the file resolving process. If it fails, more sophisticated attempts for resolving the file can be made.See
AbstractFileLocationStrategylearn 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 ProvidedURLLocationStrategy()Constructs a new instance where URL resources are bound byAbstractFileLocationStrategy.AbstractBuilder.ProvidedURLLocationStrategy(AbstractFileLocationStrategy.AbstractBuilder<?,?> builder)Constructs a new instance where URL resources are bound byAbstractFileLocationStrategy.AbstractBuilder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AbstractFileLocationStrategy.StrategyBuilder<ProvidedURLLocationStrategy>builder()Builds new instances ofProvidedURLLocationStrategy.java.net.URLlocate(FileSystem fileSystem, FileLocator locator)Tries to locate the specified file.-
Methods inherited from class org.apache.commons.configuration2.io.AbstractFileLocationStrategy
toString
-
-
-
-
Constructor Detail
-
ProvidedURLLocationStrategy
public ProvidedURLLocationStrategy()
Constructs a new instance where URL resources are bound byAbstractFileLocationStrategy.AbstractBuilder.
-
ProvidedURLLocationStrategy
public ProvidedURLLocationStrategy(AbstractFileLocationStrategy.AbstractBuilder<?,?> builder)
Constructs a new instance where URL resources are bound byAbstractFileLocationStrategy.AbstractBuilder.- Parameters:
builder- How to build the instance.- Since:
- 2.15.0
-
-
Method Detail
-
builder
public static AbstractFileLocationStrategy.StrategyBuilder<ProvidedURLLocationStrategy> builder()
Builds new instances ofProvidedURLLocationStrategy.- Returns:
- a new builder.
- Since:
- 2.15.0
-
locate
public java.net.URL locate(FileSystem fileSystem, FileLocator locator)
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 just returns the URL stored in the givenFileLocator.- 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
-
-