|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Reader
java.io.BufferedReader
java.io.LineNumberReader
com.opensymphony.xwork2.util.PropertiesReader
public class PropertiesReader
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 | |
---|---|
(package private) static String |
COMMENT_CHARS
Constant for the supported comment characters. |
private List |
commentLines
Stores the comment lines for the currently processed property. |
private char |
delimiter
Stores the list delimiter character. |
private static int |
HEX_RADIX
Constant for the radix of hex numbers. |
private String |
propertyName
Stores the name of the last read property. |
private String |
propertyValue
Stores the value of the last read property. |
private static char[] |
SEPARATORS
The list of possible key/value separators |
private static int |
UNICODE_LEN
Constant for the length of a unicode literal. |
private static char[] |
WHITE_SPACE
The white space characters used as key/value separators. |
Fields inherited from class java.io.Reader |
---|
lock |
Constructor Summary | |
---|---|
PropertiesReader(Reader reader)
Constructor. |
|
PropertiesReader(Reader reader,
char listDelimiter)
Creates a new instance of PropertiesReader and sets
the underlaying reader and the list delimiter. |
Method Summary | |
---|---|
private boolean |
checkCombineLines(String line)
Checks if the passed in line should be combined with the following. |
boolean |
contains(char[] array,
char objectToFind)
Checks if the object is in the given array. |
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. |
(package private) boolean |
isCommentLine(String line)
Tests whether a line is a comment, i.e. |
boolean |
nextProperty()
Parses the next property from the input stream and stores the found name and value in internal fields. |
private String[] |
parseProperty(String line)
Parse a property line and return the key and the value in an array. |
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 . |
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 |
Field Detail |
---|
private List commentLines
private String propertyName
private String propertyValue
private char delimiter
static final String COMMENT_CHARS
private static final int HEX_RADIX
private static final int UNICODE_LEN
private static final char[] SEPARATORS
private static final char[] WHITE_SPACE
Constructor Detail |
---|
public 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 characterMethod Detail |
---|
boolean isCommentLine(String line)
line
- the line
public String readProperty() throws IOException
<name>
= <value>
)
IOException
- in case of an I/O errorpublic boolean nextProperty() throws IOException
IOException
- if an error occurspublic List 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.
private boolean checkCombineLines(String line)
line
- the line
private String[] parseProperty(String line)
line
- the line to parse
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 properties
IllegalArgumentException
- if the Writer is null
public 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 find
true
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 null
String
, 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 null
IllegalArgumentException
- if the Writer is null
IOException
- if error occurs on underlying Writer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |