public class 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.
This class was pulled out of Jakarta Commons Configuration and Jakarta Commons Lang trunk revision 476093
| 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.
|
| Constructor and Description |
|---|
PropertiesReader(Reader reader)
Constructor.
|
PropertiesReader(Reader reader,
char listDelimiter)
Creates a new instance of
PropertiesReader and sets
the underlaying reader and the list delimiter. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(char[] array,
char objectToFind)
Checks if the object is in the given array.
|
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 |
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.
|
static String |
unescapeJava(String str)
Unescapes any Java literals found in the
String. |
protected static String |
unescapeJava(String str,
char delimiter)
Unescapes any Java literals found in the
String to a
Writer. |
static void |
unescapeJava(Writer out,
String str)
Unescapes any Java literals found in the
String to a
Writer. |
getLineNumber, mark, read, read, readLine, reset, setLineNumber, skipclose, markSupported, ready<name>
= <value>)IOException - in case of an I/O errorIOException - if an error occurspublic PropertiesReader(Reader reader)
reader - A Reader.public PropertiesReader(Reader reader, char listDelimiter)
PropertiesReader and sets
the underlaying reader and the list delimiter.reader - the readerlistDelimiter - the list delimiter characterpublic String readProperty() throws IOException
<name>
= <value>)IOException - in case of an I/O errorpublic boolean nextProperty()
throws IOException
IOException - if an error occurspublic List<String> getCommentLines()
readProperty()public String getPropertyName()
nextProperty() was invoked and its
return value was true.public String getPropertyValue()
nextProperty() was invoked and
its return value was true.protected static String unescapeJava(String str, char delimiter)
Unescapes any Java literals found in the String to a
Writer.
str - the String to unescape, may be nulldelimiter - the delimiter for multi-valued propertiesIllegalArgumentException - if the Writer is nullpublic boolean contains(char[] array,
char objectToFind)
Checks if the object is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughobjectToFind - the object to findtrue if the array contains the objectpublic static String unescapeJava(String str)
Unescapes 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 '\'.
str - the String to unescape, may be nullString, null if null string inputpublic static void unescapeJava(Writer out, String str) throws IOException
Unescapes any Java literals found in the String to a
Writer.
For example, it will turn a sequence of '\' and
'n' into a newline character, unless the '\'
is preceded by another '\'.
A null string input has no effect.
out - the Writer used to output unescaped charactersstr - the String to unescape, may be nullIllegalArgumentException - if the Writer is nullIOException - if error occurs on underlying WriterCopyright © 2000–2017 Apache Software Foundation. All rights reserved.