Class FileLocator.FileLocatorBuilder
- java.lang.Object
-
- org.apache.commons.configuration2.io.FileLocator.FileLocatorBuilder
-
- Enclosing class:
- FileLocator
public static final class FileLocator.FileLocatorBuilder extends java.lang.Object
A typical builder implementation for creatingFileLocator
objects. An instance of this class is returned by thefileLocator()
method of {link FileLocatorUtils}. It can be used to define the various components of theFileLocator
object. By callingcreate()
the new immutableFileLocator
instance is created.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
basePath
The base path.private java.lang.String
encoding
The encoding.private java.lang.String
fileName
The file name.private FileSystem
fileSystem
The file system.private FileLocationStrategy
locationStrategy
The location strategy.private java.net.URL
sourceURL
The URL.private URLConnectionOptions
urlConnectionOptions
The URL connection options.
-
Constructor Summary
Constructors Constructor Description FileLocatorBuilder(FileLocator src)
Creates a new instance ofFileLocatorBuilder
and initializes the builder's properties from the passed inFileLocator
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileLocator.FileLocatorBuilder
basePath(java.lang.String path)
Specifies the base path of the newFileLocator
.FileLocator
create()
Creates a new immutableFileLocatorImpl
object based on the properties set so far for this builder.FileLocator.FileLocatorBuilder
encoding(java.lang.String enc)
Specifies the encoding of the newFileLocator
.FileLocator.FileLocatorBuilder
fileName(java.lang.String name)
Specifies the file name of the newFileLocator
.FileLocator.FileLocatorBuilder
fileSystem(FileSystem fs)
Specifies theFileSystem
of the newFileLocator
.private void
initBuilder(FileLocator src)
Initializes the properties of this builder from the passed in locator object.FileLocator.FileLocatorBuilder
locationStrategy(FileLocationStrategy strategy)
Specifies theFileLocationStrategy
to be used when the referenced file is to be located.FileLocator.FileLocatorBuilder
sourceURL(java.net.URL url)
Specifies the source URL of the newFileLocator
.FileLocator.FileLocatorBuilder
urlConnectionOptions(URLConnectionOptions urlConnectionOptions)
Specifies the source URL connection options of the newFileLocator
.
-
-
-
Field Detail
-
basePath
private java.lang.String basePath
The base path.
-
encoding
private java.lang.String encoding
The encoding.
-
fileName
private java.lang.String fileName
The file name.
-
fileSystem
private FileSystem fileSystem
The file system.
-
locationStrategy
private FileLocationStrategy locationStrategy
The location strategy.
-
sourceURL
private java.net.URL sourceURL
The URL.
-
urlConnectionOptions
private URLConnectionOptions urlConnectionOptions
The URL connection options.
-
-
Constructor Detail
-
FileLocatorBuilder
FileLocatorBuilder(FileLocator src)
Creates a new instance ofFileLocatorBuilder
and initializes the builder's properties from the passed inFileLocator
object.- Parameters:
src
- the sourceFileLocator
(may be null)
-
-
Method Detail
-
basePath
public FileLocator.FileLocatorBuilder basePath(java.lang.String path)
Specifies the base path of the newFileLocator
.- Parameters:
path
- the base path- Returns:
- a reference to this builder for method chaining
-
create
public FileLocator create()
Creates a new immutableFileLocatorImpl
object based on the properties set so far for this builder.- Returns:
- the newly created
FileLocator
object, never null.
-
encoding
public FileLocator.FileLocatorBuilder encoding(java.lang.String enc)
Specifies the encoding of the newFileLocator
.- Parameters:
enc
- the encoding- Returns:
- a reference to this builder for method chaining
-
fileName
public FileLocator.FileLocatorBuilder fileName(java.lang.String name)
Specifies the file name of the newFileLocator
.- Parameters:
name
- the file name- Returns:
- a reference to this builder for method chaining
-
fileSystem
public FileLocator.FileLocatorBuilder fileSystem(FileSystem fs)
Specifies theFileSystem
of the newFileLocator
.- Parameters:
fs
- theFileSystem
- Returns:
- a reference to this builder for method chaining
-
initBuilder
private void initBuilder(FileLocator src)
Initializes the properties of this builder from the passed in locator object.- Parameters:
src
- the sourceFileLocator
-
locationStrategy
public FileLocator.FileLocatorBuilder locationStrategy(FileLocationStrategy strategy)
Specifies theFileLocationStrategy
to be used when the referenced file is to be located.- Parameters:
strategy
- theFileLocationStrategy
- Returns:
- a reference to this builder for method chaining
-
sourceURL
public FileLocator.FileLocatorBuilder sourceURL(java.net.URL url)
Specifies the source URL of the newFileLocator
.- Parameters:
url
- the source URL- Returns:
- a reference to this builder for method chaining
-
urlConnectionOptions
public FileLocator.FileLocatorBuilder urlConnectionOptions(URLConnectionOptions urlConnectionOptions)
Specifies the source URL connection options of the newFileLocator
.- Parameters:
urlConnectionOptions
- the source URL connection options.- Returns:
- a reference to this builder for method chaining
-
-