org.apache.commons.configuration2

## Class PropertiesConfiguration.PropertiesReader

- java.lang.Object
- - java.io.Reader
  - - java.io.BufferedReader
    - - java.io.LineNumberReader
      - - org.apache.commons.configuration2.PropertiesConfiguration.PropertiesReader

- All Implemented Interfaces:
    Closeable, AutoCloseable, Readable
  Direct Known Subclasses:
    PropertiesConfiguration.JupPropertiesReader
  Enclosing class:
    PropertiesConfiguration

      public static class PropertiesConfiguration.PropertiesReader
      extends LineNumberReader

  This class is used to read properties lines. These lines do not terminate with new-line chars but rather when there is no backslash sign a the end of the line. This is used to concatenate multiple lines for readability.

- - ### Property Summary

    All Methods Instance Methods Concrete Methods
    Type | Property and Description
    --- | ---
    `boolean` | `next` Parses the next property from the input stream and stores the found name and value in internal fields.
    `String` | `read` Reads a property line.

  - ### Field Summary

    - ### Fields inherited from class java.io.Reader

      `lock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PropertiesReader(Reader reader)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<String>` | `getCommentLines()` Returns the comment lines that have been read for the last property.
    `String` | `getPropertyName()` Returns the name of the last read property.
    `String` | `getPropertySeparator()` Returns the separator that was used for the last read property.
    `String` | `getPropertyValue()` Returns the value of the last read property.
    `protected void` | `initPropertyName(String name)` Sets the name of the current property.
    `protected void` | `initPropertySeparator(String value)` Sets the separator of the current property.
    `protected void` | `initPropertyValue(String value)` Sets the value of the current property.
    `boolean` | `nextProperty()` Parses the next property from the input stream and stores the found name and value in internal fields.
    `protected void` | `parseProperty(String line)` Parses a line read from the properties file.
    `String` | `readProperty()` Reads a property line.
    `protected String` | `unescapePropertyName(String name)` Performs unescaping on the given property name.
    `protected String` | `unescapePropertyValue(String value)` Performs unescaping on the given property value.

    - ### Methods inherited from class java.io.LineNumberReader

      `getLineNumber, mark, read, read, readLine, reset, setLineNumber, skip`

    - ### Methods inherited from class java.io.BufferedReader

      `close, lines, markSupported, ready`

    - ### Methods inherited from class java.io.Reader

      `read, read`

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

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

- - ### Property Detail

    - #### read

          public String readProperty

      Reads a property line. Returns null if Stream is at EOF. Concatenates lines ending with "\". Skips lines beginning with "#" or "!" and empty lines. The return value is a property definition (`<name>` = `<value>`)
      Throws:
        `IOException`

    - #### next

          public boolean nextProperty

      Parses the next property from the input stream and stores the found name and value in internal fields. These fields can be obtained using the provided getter methods. The return value indicates whether EOF was reached (false) or whether further properties are available (true).
      Throws:
        `IOException`
      Since:
        1.3

  - ### Constructor Detail

    - #### PropertiesReader

          public PropertiesReader(Reader reader)

      Constructor.
      Parameters:
        `reader` - A Reader.

  - ### Method Detail

    - #### readProperty

          public String readProperty()
                              throws IOException

      Reads a property line. Returns null if Stream is at EOF. Concatenates lines ending with "\". Skips lines beginning with "#" or "!" and empty lines. The return value is a property definition (`<name>` = `<value>`)
      Throws:
        `IOException`

    - #### nextProperty

          public boolean nextProperty()
                               throws IOException

      Parses the next property from the input stream and stores the found name and value in internal fields. These fields can be obtained using the provided getter methods. The return value indicates whether EOF was reached (false) or whether further properties are available (true).
      Throws:
        `IOException`
      Since:
        1.3

    - #### getCommentLines

          public List<String> getCommentLines()

      Returns the comment lines that have been read for the last property.
      Returns:
        the comment lines for the last property returned by `readProperty()`
      Since:
        1.3

    - #### getPropertyName

          public String getPropertyName()

      Returns the name of the last read property. This method can be called after `nextProperty()` was invoked and its return value was true.
      Returns:
        the name of the last read property
      Since:
        1.3

    - #### getPropertyValue

          public String getPropertyValue()

      Returns the value of the last read property. This method can be called after `nextProperty()` was invoked and its return value was true.
      Returns:
        the value of the last read property
      Since:
        1.3

    - #### getPropertySeparator

          public String getPropertySeparator()

      Returns the separator that was used for the last read property. The separator can be stored so that it can later be restored when saving the configuration.
      Returns:
        the separator for the last read property
      Since:
        1.7

    - #### parseProperty

          protected void parseProperty(String line)

      Parses a line read from the properties file. This method is called for each non-comment line read from the source file. Its task is to split the passed in line into the property key and its value. The results of the parse operation can be stored by calling the `initPropertyXXX()` methods.
      Parameters:
        `line` - the line read from the properties file
      Since:
        1.7

    - #### initPropertyName

          protected void initPropertyName(String name)

      Sets the name of the current property. This method can be called by `parseProperty()` for storing the results of the parse operation. It also ensures that the property key is correctly escaped.
      Parameters:
        `name` - the name of the current property
      Since:
        1.7

    - #### unescapePropertyName

          protected String unescapePropertyName(String name)

      Performs unescaping on the given property name.
      Parameters:
        `name` - the property name
      Returns:
        the unescaped property name
      Since:
        2.4

    - #### initPropertyValue

          protected void initPropertyValue(String value)

      Sets the value of the current property. This method can be called by `parseProperty()` for storing the results of the parse operation. It also ensures that the property value is correctly escaped.
      Parameters:
        `value` - the value of the current property
      Since:
        1.7

    - #### unescapePropertyValue

          protected String unescapePropertyValue(String value)

      Performs unescaping on the given property value.
      Parameters:
        `value` - the property value
      Returns:
        the unescaped property value
      Since:
        2.4

    - #### initPropertySeparator

          protected void initPropertySeparator(String value)

      Sets the separator of the current property. This method can be called by `parseProperty()`. It allows the associated layout object to keep track of the property separators. When saving the configuration the separators can be restored.
      Parameters:
        `value` - the separator used for the current property
      Since:
        1.7

Copyright © 2001–2018 The Apache Software Foundation. All rights reserved.