Class PropertiesReader
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Readable
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.
This class was pulled out of Jakarta Commons Configuration and Jakarta Commons Lang trunk revision 476093
- 
Field Summary
- 
Constructor SummaryConstructorsConstructorDescriptionPropertiesReader(Reader reader) Constructor.PropertiesReader(Reader reader, char listDelimiter) Creates a new instance ofPropertiesReaderand sets the underlaying reader and the list delimiter.
- 
Method SummaryModifier and TypeMethodDescriptionbooleancontains(char[] array, char objectToFind) Checks if the object is in the given array.Returns the comment lines that have been read for the last property.Returns the name of the last read property.Returns the value of the last read property.booleanParses the next property from the input stream and stores the found name and value in internal fields.Reads a property line.static voidunescapeJava(Writer out, String str) Unescapes any Java literals found in theStringto aWriter.static StringunescapeJava(String str) Unescapes any Java literals found in theString.protected static StringunescapeJava(String str, char delimiter) Unescapes any Java literals found in theStringto aWriter.Methods inherited from class java.io.LineNumberReadergetLineNumber, mark, read, read, readLine, reset, setLineNumber, skipMethods inherited from class java.io.BufferedReaderclose, lines, markSupported, readyMethods inherited from class java.io.ReadernullReader, read, read, transferTo
- 
Constructor Details- 
PropertiesReaderConstructor.- Parameters:
- reader- A Reader.
 
- 
PropertiesReaderCreates a new instance ofPropertiesReaderand sets the underlaying reader and the list delimiter.- Parameters:
- reader- the reader
- listDelimiter- the list delimiter character
- Since:
- 1.3
 
 
- 
- 
Method Details- 
readPropertyReads 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
 
- 
nextPropertyParses 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
 
- 
getCommentLinesReturns 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
 
- 
getPropertyNameReturns the name of the last read property. This method can be called afternextProperty()- Returns:
- the name of the last read property
- Since:
- 1.3
 
- 
getPropertyValueReturns the value of the last read property. This method can be called afternextProperty()- Returns:
- the value of the last read property
- Since:
- 1.3
 
- 
unescapeJavaUnescapes any Java literals found in the This is a slightly modified version of the StringEscapeUtils.unescapeJava() function in commons-lang that doesn't drop escaped separators (i.e '\,').Stringto aWriter.- Parameters:
- str- the- Stringto unescape, may be null
- delimiter- the delimiter for multi-valued properties
- Returns:
- the processed string
- Throws:
- IllegalArgumentException- if the Writer is- null
 
- 
containspublic boolean contains(char[] array, char objectToFind) Checks if the object is in the given array. The method returns falseif anullarray is passed in.- Parameters:
- array- the array to search through
- objectToFind- the object to find
- Returns:
- trueif the array contains the object
 
- 
unescapeJavaUnescapes any Java literals found in the String. For example, it will turn a sequence of'\'and'n'into a newline character, unless the'\'is preceded by another'\'.- Parameters:
- str- the- Stringto unescape, may be null
- Returns:
- a new unescaped String,nullif null string input
 
- 
unescapeJavaUnescapes any Java literals found in the Stringto aWriter.For example, it will turn a sequence of '\'and'n'into a newline character, unless the'\'is preceded by another'\'.A nullstring input has no effect.- Parameters:
- out- the- Writerused to output unescaped characters
- str- the- Stringto unescape, may be null
- Throws:
- IllegalArgumentException- if the Writer is- null
- IOException- if error occurs on underlying Writer
 
 
-