org.apache.commons.configuration
Class PropertiesConfiguration.PropertiesReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.BufferedReader
          extended by java.io.LineNumberReader
              extended by org.apache.commons.configuration.PropertiesConfiguration.PropertiesReader
All Implemented Interfaces:
Closeable, Readable
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.


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
PropertiesConfiguration.PropertiesReader(Reader reader)
          Constructor.
PropertiesConfiguration.PropertiesReader(Reader reader, char listDelimiter)
          Creates a new instance of PropertiesReader and sets the underlaying reader and the list delimiter.
 
Method Summary
 List getCommentLines()
          Returns the comment lines that have been read for the last property.
 String getPropertyName()
          Returns the name of the last read property.
 String getPropertyValue()
          Returns the value of the last read property.
 boolean nextProperty()
          Parses the next property from the input stream and stores the found name and value in internal fields.
 String readProperty()
          Reads a property line.
 
Methods inherited from class java.io.LineNumberReader
getLineNumber, mark, read, read, readLine, reset, setLineNumber, skip
 
Methods inherited from class java.io.BufferedReader
close, 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
 

Constructor Detail

PropertiesConfiguration.PropertiesReader

public PropertiesConfiguration.PropertiesReader(Reader reader)
Constructor.

Parameters:
reader - A Reader.

PropertiesConfiguration.PropertiesReader

public PropertiesConfiguration.PropertiesReader(Reader reader,
                                                char listDelimiter)
Creates a new instance of PropertiesReader and sets the underlaying reader and the list delimiter.

Parameters:
reader - the reader
listDelimiter - the list delimiter character
Since:
1.3
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>)

Returns:
A string containing a property value or null
Throws:
IOException - in case of an I/O error

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).

Returns:
a flag if further properties are available
Throws:
IOException - if an error occurs
Since:
1.3

getCommentLines

public List 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


Copyright © 2001-2007 The Apache Software Foundation. All Rights Reserved.