Package org.apache.commons.collections4.properties

# Class AbstractPropertiesFactory<T extends Properties>

java.lang.Object
org.apache.commons.collections4.properties.AbstractPropertiesFactory<T>

Type Parameters:
  `T` - `Properties` or a subclass like `SortedProperties`.

Direct Known Subclasses:
  `OrderedPropertiesFactory`, `PropertiesFactory`, `SortedPropertiesFactory`

public abstract class AbstractPropertiesFactory<T extends Properties> extends Object
Subclasses create and load `Properties` and subclasses of `Properties` like `SortedProperties`.

Since:
  4.4
See Also:
  - `Properties`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `AbstractPropertiesFactory.PropertyFormat`
  Enumerates property formats.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AbstractPropertiesFactory()`
  Constructs an instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract T`
  `createProperties()`
  Subclasses override to provide customized properties instances.
  `T`
  `load(File file)`
  Creates and loads properties from the given file.
  `T`
  `load(InputStream inputStream)`
  Creates and loads properties from the given input stream.
  `T`
  `load(InputStream inputStream, AbstractPropertiesFactory.PropertyFormat propertyFormat)`
  Creates and loads properties from the given input stream.
  `T`
  `load(Reader reader)`
  Creates and loads properties from the given reader.
  `T`
  `load(ClassLoader classLoader, String name)`
  Creates and loads properties from the given file.
  `T`
  `load(String name)`
  Creates and loads properties from the given file name.
  `T`
  `load(URI uri)`
  Creates and loads properties from the given URI.
  `T`
  `load(URL url)`
  Creates and loads properties from the given URL.
  `T`
  `load(Path path)`
  Creates and loads properties from the given path.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AbstractPropertiesFactory

    protected AbstractPropertiesFactory()
    Constructs an instance.

- ## Method Details

  - ### createProperties

    protected abstract T createProperties()
    Subclasses override to provide customized properties instances.
    Returns:
      a new Properties instance.

  - ### load

    public T load(ClassLoader classLoader, String name) throws IOException
    Creates and loads properties from the given file.
    Parameters:
      `classLoader` - the class loader to use to get the named resource.
      `name` - the location of the properties file.
    Returns:
      a new properties object.
    Throws:
      `IOException` - Thrown if an error occurred reading the input stream.
      `IllegalArgumentException` - Thrown if the input contains a malformed Unicode escape sequence.

  - ### load

    public T load(File file) throws FileNotFoundException, IOException
    Creates and loads properties from the given file.
    Parameters:
      `file` - the location of the properties file.
    Returns:
      a new properties object.
    Throws:
      `IOException` - Thrown if an error occurred reading the input stream.
      `IllegalArgumentException` - Thrown if the input contains a malformed Unicode escape sequence.
      `FileNotFoundException` - Thrown if the file does not exist, is a directory, or cannot be opened for reading.
      `SecurityException` - Thrown if a security manager's `checkRead` method denies read access to the file.

  - ### load

    public T load(InputStream inputStream) throws IOException
    Creates and loads properties from the given input stream.
    Parameters:
      `inputStream` - the location of the properties file.
    Returns:
      a new properties object.
    Throws:
      `IOException` - Thrown if an error occurred reading the input stream.
      `IllegalArgumentException` - Thrown if the input contains a malformed Unicode escape sequence.

  - ### load

    public T load(InputStream inputStream, AbstractPropertiesFactory.PropertyFormat propertyFormat) throws IOException
    Creates and loads properties from the given input stream.
    Parameters:
      `inputStream` - the location of the properties file.
      `propertyFormat` - The format of the given file.
    Returns:
      a new properties object.
    Throws:
      `IOException` - Thrown if an error occurred reading the input stream.
      `IllegalArgumentException` - Thrown if the input contains a malformed Unicode escape sequence.
    Since:
      4.5.0-M1

  - ### load

    public T load(Path path) throws IOException
    Creates and loads properties from the given path.
    Parameters:
      `path` - the location of the properties file.
    Returns:
      a new properties object.
    Throws:
      `IOException` - Thrown if an error occurred reading the input stream.
      `IllegalArgumentException` - Thrown if the input contains a malformed Unicode escape sequence.

  - ### load

    public T load(Reader reader) throws IOException
    Creates and loads properties from the given reader.
    Parameters:
      `reader` - the location of the properties file.
    Returns:
      a new properties object.
    Throws:
      `IOException` - Thrown if an error occurred reading the input stream.
      `IllegalArgumentException` - Thrown if the input contains a malformed Unicode escape sequence.

  - ### load

    public T load(String name) throws IOException
    Creates and loads properties from the given file name.
    Parameters:
      `name` - the location of the properties file.
    Returns:
      a new properties object.
    Throws:
      `IOException` - Thrown if an error occurred reading the input stream.
      `IllegalArgumentException` - Thrown if the input contains a malformed Unicode escape sequence.

  - ### load

    public T load(URI uri) throws IOException
    Creates and loads properties from the given URI.
    Parameters:
      `uri` - the location of the properties file.
    Returns:
      a new properties object.
    Throws:
      `IOException` - Thrown if an error occurred reading the input stream.
      `IllegalArgumentException` - Thrown if the input contains a malformed Unicode escape sequence.

  - ### load

    public T load(URL url) throws IOException
    Creates and loads properties from the given URL.
    Parameters:
      `url` - the location of the properties file.
    Returns:
      a new properties object.
    Throws:
      `IOException` - Thrown if an error occurred reading the input stream.
      `IllegalArgumentException` - Thrown if the input contains a malformed Unicode escape sequence.