Top Description Constructors Methods
org.apache.commons.collections4.properties

public abstract Class AbstractPropertiesFactory<T extends java.util.Properties>

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.commons.collections4.properties.PropertiesFactory, org.apache.commons.collections4.properties.SortedPropertiesFactory
Type Parameters
<T>
Properties or a subclass like SortedProperties.
Imports
java.io.File, .FileInputStream, .FileNotFoundException, .IOException, .InputStream, .Reader, java.net.URI, .URL, java.nio.file.Files, .Path, .Paths, java.util.Properties

Subclasses create and load Properties and subclasses of Properties like SortedProperties.
Since
4.4
See Also
Properties

Constructor Summary

AccessConstructor and Description
protected
AbstractPropertiesFactory()

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
protected abstract T

Returns:

a new Properties instance.
createProperties
()

Subclasses override to provide customized properties instances.

public T

Returns:

a new properties object.
load
(final ClassLoader
the class loader to use to get the named resource.
classLoader
,
final String
the location of the properties file.
name
)

Creates and loads properties from the given file.

public T

Returns:

a new properties object.
load
(final File
the location of the properties file.
file
)

Creates and loads properties from the given file.

public T

Returns:

a new properties object.
load
(final InputStream
the location of the properties file.
inputStream
)

Creates and loads properties from the given input stream.

public T

Returns:

a new properties object.
load
(final Path
the location of the properties file.
path
)

Creates and loads properties from the given path.

public T

Returns:

a new properties object.
load
(final Reader
the location of the properties file.
reader
)

Creates and loads properties from the given reader.

public T

Returns:

a new properties object.
load
(final String
the location of the properties file.
name
)

Creates and loads properties from the given file name.

public T

Returns:

a new properties object.
load
(final URI
the location of the properties file.
uri
)

Creates and loads properties from the given URI.

public T

Returns:

a new properties object.
load
(final URL
the location of the properties file.
url
)

Creates and loads properties from the given URL.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AbstractPropertiesFactoryback to summary
protected AbstractPropertiesFactory()

Constructs an instance.

Method Detail

createPropertiesback to summary
protected abstract T createProperties()

Subclasses override to provide customized properties instances.

Returns:T

a new Properties instance.

loadback to summary
public T load(final ClassLoader classLoader, final String name) throws IOException

Creates and loads properties from the given file.

Parameters
classLoader:ClassLoader

the class loader to use to get the named resource.

name:String

the location of the properties file.

Returns:T

a new properties object.

Exceptions
IOException:
Thrown if an error occurred reading the input stream.
IllegalArgumentException:
Thrown if the input contains a malformed Unicode escape sequence.
loadback to summary
public T load(final File file) throws FileNotFoundException, IOException

Creates and loads properties from the given file.

Parameters
file:File

the location of the properties file.

Returns:T

a new properties object.

Exceptions
FileNotFoundException:
Thrown if the file does not exist, is a directory, or cannot be opened for reading.
IOException:
Thrown if an error occurred reading the input stream.
IllegalArgumentException:
Thrown if the input contains a malformed Unicode escape sequence.
SecurityException:
Thrown if a security manager's checkRead method denies read access to the file.
loadback to summary
public T load(final InputStream inputStream) throws IOException

Creates and loads properties from the given input stream.

Parameters
inputStream:InputStream

the location of the properties file.

Returns:T

a new properties object.

Exceptions
IOException:
Thrown if an error occurred reading the input stream.
IllegalArgumentException:
Thrown if the input contains a malformed Unicode escape sequence.
loadback to summary
public T load(final Path path) throws IOException

Creates and loads properties from the given path.

Parameters
path:Path

the location of the properties file.

Returns:T

a new properties object.

Exceptions
IOException:
Thrown if an error occurred reading the input stream.
IllegalArgumentException:
Thrown if the input contains a malformed Unicode escape sequence.
loadback to summary
public T load(final Reader reader) throws IOException

Creates and loads properties from the given reader.

Parameters
reader:Reader

the location of the properties file.

Returns:T

a new properties object.

Exceptions
IOException:
Thrown if an error occurred reading the input stream.
IllegalArgumentException:
Thrown if the input contains a malformed Unicode escape sequence.
loadback to summary
public T load(final String name) throws IOException

Creates and loads properties from the given file name.

Parameters
name:String

the location of the properties file.

Returns:T

a new properties object.

Exceptions
IOException:
Thrown if an error occurred reading the input stream.
IllegalArgumentException:
Thrown if the input contains a malformed Unicode escape sequence.
loadback to summary
public T load(final URI uri) throws IOException

Creates and loads properties from the given URI.

Parameters
uri:URI

the location of the properties file.

Returns:T

a new properties object.

Exceptions
IOException:
Thrown if an error occurred reading the input stream.
IllegalArgumentException:
Thrown if the input contains a malformed Unicode escape sequence.
loadback to summary
public T load(final URL url) throws IOException

Creates and loads properties from the given URL.

Parameters
url:URL

the location of the properties file.

Returns:T

a new properties object.

Exceptions
IOException:
Thrown if an error occurred reading the input stream.
IllegalArgumentException:
Thrown if the input contains a malformed Unicode escape sequence.