public interface FileLocationStrategy
An interface allowing applications to customize the process of locating a file.
FileHandler
uses FileLocator
objects for referencing files.
These objects are not guaranteed to identify a file in a unique way. For
instance, if only a file name is defined, this could mean a relative file
name in the current directory, the name of a resource to be loaded from the
class path, or something else. Before the file described by a
FileLocator
can be actually accessed, an unambiguous URL pointing to
this file has to be obtained. This is the job of a
FileLocationStrategy
.
This interface defines a method for locating a file provided as a
FileLocator
object. If location is successful, a URL is returned. A
concrete implementation can perform arbitrary actions to search for the file
in question at various places. There will also be an implementation allowing
the combination of multiple FileLocationStrategy
implementations; so
a file can be searched using multiple strategies until one of them is
successful.
Modifier and Type | Method and Description |
---|---|
URL |
locate(FileSystem fileSystem,
FileLocator locator)
Tries to locate the specified file.
|
URL locate(FileSystem fileSystem, FileLocator locator)
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.fileSystem
- the FileSystem
to be used for this operationlocator
- the object describing the file to be locatedCopyright © 2001–2020 The Apache Software Foundation. All rights reserved.