Class FileLocator
A class describing the location of a file.
An instance of this class provides information for locating and accessing a file. The file location can be defined
- as a URL; this identifies a file in a unique way
- as a combination of base path and file name; if this variant is used, there may be an additional location step required in order to identify the referenced file (for instance, the file name may be interpreted as the name of a resource to be loaded from class path).
In addition, other properties are available which are also needed for loading or saving a file, like the underlying
FileSystem
. The encoding to be used when accessing the represented data is also part of the data contained in
an instance; if no encoding is set explicitly, the platform's default encoding is used.
Instances of this class are immutable and thus can be safely shared between arbitrary components. FileHandler
also uses an instance to reference the associated file. Instances are created using a builder.
FileLocatorUtils
offers convenience methods for obtaining such a builder.
- Since:
- 2.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A typical builder implementation for creatingFileLocator
objects. -
Constructor Summary
ConstructorDescriptionCreates a new instance ofFileLocatorImpl
and initializes it from the given builder instance -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares this object with another one.Gets the base path stored in this locator or null if it is undefined.Gets the encoding stored in this locator or null if it is undefined.Gets the file name stored in this locator or null if it is undefined.Gets theFileSystem
to be used for accessing the file referenced by this locator or null if it is undefined.Gets theFileLocationStrategy
to be used for locating the referenced file.Gets the URL pointing to the referenced source file or null if it is undefined.Gets the URLConnectionOptionsint
hashCode()
Returns a hash code for this object.toString()
-
Constructor Details
-
FileLocator
Creates a new instance ofFileLocatorImpl
and initializes it from the given builder instance- Parameters:
builder
- the builder
-
-
Method Details
-
equals
Compares this object with another one. Two instances ofFileLocatorImpl
are considered equal if all of their properties are equal. -
getBasePath
Gets the base path stored in this locator or null if it is undefined.- Returns:
- the base path
-
getEncoding
Gets the encoding stored in this locator or null if it is undefined.- Returns:
- the encoding
-
getFileName
Gets the file name stored in this locator or null if it is undefined.- Returns:
- the file name
-
getFileSystem
Gets theFileSystem
to be used for accessing the file referenced by this locator or null if it is undefined.- Returns:
- the
FileSystem
-
getLocationStrategy
Gets theFileLocationStrategy
to be used for locating the referenced file. If no specificFileLocationStrategy
has been set, result is null. This means that the default strategy should be used.- Returns:
- the
FileLocationStrategy
to be used
-
getSourceURL
Gets the URL pointing to the referenced source file or null if it is undefined.- Returns:
- the source URL
-
getURLConnectionOptions
Gets the URLConnectionOptions- Returns:
- the URLConnectionOptions
-
hashCode
Returns a hash code for this object. -
toString
-