public class ConfigurationHandler
extends java.lang.Object
ConfigurationHandler class implements configuration reading
form a java.io.InputStream and writing to a
java.io.OutputStream on behalf of the
FilePersistenceManager class.
cfg = prop "=" value .
prop = symbolic-name . // 1.4.2 of OSGi Core Specification
symbolic-name = token { "." token } .
token = { [ 0..9 ] | [ a..z ] | [ A..Z ] | '_' | '-' } .
value = [ type ] ( "[" values "]" | "(" values ")" | simple ) .
values = simple { "," simple } .
simple = """ stringsimple """ .
type = // 1-char type code .
stringsimple = // quoted string representation of the value .
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.Map |
code2Type |
protected static java.lang.String |
COLLECTION_LINE_BREAK |
protected static java.lang.String |
CRLF |
protected static java.lang.String |
ENCODING |
protected static java.lang.String |
INDENT |
private int |
line |
private static java.util.BitSet |
NAME_CHARS |
private int |
pos |
private int |
token |
protected static int |
TOKEN_ARR_CLOS |
protected static int |
TOKEN_ARR_OPEN |
private static java.util.BitSet |
TOKEN_CHARS |
protected static int |
TOKEN_COMMA |
protected static int |
TOKEN_COMMENT |
protected static int |
TOKEN_EQ |
protected static int |
TOKEN_NAME |
protected static int |
TOKEN_PRIMITIVE_BOOLEAN |
protected static int |
TOKEN_PRIMITIVE_BYTE |
protected static int |
TOKEN_PRIMITIVE_CHAR |
protected static int |
TOKEN_PRIMITIVE_DOUBLE |
protected static int |
TOKEN_PRIMITIVE_FLOAT |
protected static int |
TOKEN_PRIMITIVE_INT |
protected static int |
TOKEN_PRIMITIVE_LONG |
protected static int |
TOKEN_PRIMITIVE_SHORT |
protected static int |
TOKEN_SIMPLE_BOOLEAN |
protected static int |
TOKEN_SIMPLE_BYTE |
protected static int |
TOKEN_SIMPLE_CHARACTER |
protected static int |
TOKEN_SIMPLE_DOUBLE |
protected static int |
TOKEN_SIMPLE_FLOAT |
protected static int |
TOKEN_SIMPLE_INTEGER |
protected static int |
TOKEN_SIMPLE_LONG |
protected static int |
TOKEN_SIMPLE_SHORT |
protected static int |
TOKEN_SIMPLE_STRING |
protected static int |
TOKEN_SPACE |
protected static int |
TOKEN_VAL_CLOS |
protected static int |
TOKEN_VAL_OPEN |
protected static int |
TOKEN_VEC_CLOS |
protected static int |
TOKEN_VEC_OPEN |
private java.lang.String |
tokenValue |
protected static java.util.Map |
type2Code |
| Modifier | Constructor and Description |
|---|---|
private |
ConfigurationHandler() |
| Modifier and Type | Method and Description |
|---|---|
private void |
ensureNext(java.io.PushbackReader pr,
int expected) |
private int |
ignorablePageBreakAndWhiteSpace(java.io.PushbackReader pr) |
private int |
ignorableWhiteSpace(java.io.PushbackReader pr) |
private int |
nextToken(java.io.PushbackReader pr,
boolean newLine) |
private static java.util.Enumeration |
orderedKeys(java.util.Dictionary properties)
Generates an
Enumeration for the given
Dictionary where the keys of the Dictionary
are provided in sorted order. |
static java.util.Dictionary |
read(java.io.InputStream ins)
Reads configuration data from the given
InputStream and
returns a new Dictionary object containing the data. |
private int |
read(java.io.PushbackReader pr) |
private int |
read(java.io.PushbackReader pr,
char[] buf) |
static java.lang.Object |
read(java.lang.String value) |
private java.lang.Object |
readArray(int typeCode,
java.io.PushbackReader pr) |
private java.util.Collection |
readCollection(int typeCode,
java.io.PushbackReader pr) |
private java.io.IOException |
readFailure(int current,
int expected) |
private java.util.Dictionary |
readInternal(java.io.InputStream ins) |
private java.lang.String |
readQuoted(java.io.PushbackReader pr) |
private java.lang.Object |
readSimple(int code,
java.io.PushbackReader pr) |
private java.lang.String |
readUnquoted(java.io.PushbackReader pr) |
private java.lang.Object |
readValue(java.io.PushbackReader pr)
value = type ( "[" values "]" | "(" values ")" | simple ) .
|
static java.lang.String |
write(java.lang.Object value) |
static void |
write(java.io.OutputStream out,
java.util.Dictionary properties)
Writes the configuration data from the
Dictionary to the
given OutputStream. |
private static void |
writeArray(java.io.Writer out,
java.lang.Object arrayValue) |
private static void |
writeCollection(java.io.Writer out,
java.util.Collection collection) |
private static void |
writeCollectionElement(java.io.Writer out,
java.lang.Object element) |
private static void |
writeQuoted(java.io.Writer out,
java.lang.String simple) |
private static void |
writeSimple(java.io.Writer out,
java.lang.Object value) |
private static void |
writeType(java.io.Writer out,
java.lang.Class valueType) |
private static void |
writeValue(java.io.Writer out,
java.lang.Object value) |
protected static final java.lang.String ENCODING
protected static final int TOKEN_NAME
protected static final int TOKEN_EQ
protected static final int TOKEN_ARR_OPEN
protected static final int TOKEN_ARR_CLOS
protected static final int TOKEN_VEC_OPEN
protected static final int TOKEN_VEC_CLOS
protected static final int TOKEN_COMMA
protected static final int TOKEN_VAL_OPEN
protected static final int TOKEN_VAL_CLOS
protected static final int TOKEN_SPACE
protected static final int TOKEN_COMMENT
protected static final int TOKEN_SIMPLE_STRING
protected static final int TOKEN_SIMPLE_INTEGER
protected static final int TOKEN_SIMPLE_LONG
protected static final int TOKEN_SIMPLE_FLOAT
protected static final int TOKEN_SIMPLE_DOUBLE
protected static final int TOKEN_SIMPLE_BYTE
protected static final int TOKEN_SIMPLE_SHORT
protected static final int TOKEN_SIMPLE_CHARACTER
protected static final int TOKEN_SIMPLE_BOOLEAN
protected static final int TOKEN_PRIMITIVE_INT
protected static final int TOKEN_PRIMITIVE_LONG
protected static final int TOKEN_PRIMITIVE_FLOAT
protected static final int TOKEN_PRIMITIVE_DOUBLE
protected static final int TOKEN_PRIMITIVE_BYTE
protected static final int TOKEN_PRIMITIVE_SHORT
protected static final int TOKEN_PRIMITIVE_CHAR
protected static final int TOKEN_PRIMITIVE_BOOLEAN
protected static final java.lang.String CRLF
protected static final java.lang.String INDENT
protected static final java.lang.String COLLECTION_LINE_BREAK
protected static final java.util.Map code2Type
protected static final java.util.Map type2Code
private static final java.util.BitSet NAME_CHARS
private static final java.util.BitSet TOKEN_CHARS
private int token
private java.lang.String tokenValue
private int line
private int pos
public static void write(java.io.OutputStream out,
java.util.Dictionary properties)
throws java.io.IOException
Dictionary to the
given OutputStream.
This method writes at the current location in the stream and does not close the outputstream.
out - The OutputStream to write the configurtion data
to.properties - The Dictionary to write.java.io.IOException - If an error occurrs writing to the output stream.public static java.lang.String write(java.lang.Object value)
throws java.io.IOException
java.io.IOExceptionprivate static java.util.Enumeration orderedKeys(java.util.Dictionary properties)
Enumeration for the given
Dictionary where the keys of the Dictionary
are provided in sorted order.properties - The Dictionary that keys are sorted.Enumeration that provides the keys of
properties in an ordered manner.public static java.util.Dictionary read(java.io.InputStream ins)
throws java.io.IOException
InputStream and
returns a new Dictionary object containing the data.
This method reads from the current location in the stream upto the end of the stream but does not close the stream at the end.
ins - The InputStream from which to read the
configuration data.Dictionary object containing the configuration
data. This object may be empty if the stream contains no
configuration data.java.io.IOException - If an error occurrs reading from the stream. This exception
is also thrown if a syntax error is encountered.public static java.lang.Object read(java.lang.String value)
throws java.io.IOException
java.io.IOExceptionprivate java.util.Dictionary readInternal(java.io.InputStream ins)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.Object readValue(java.io.PushbackReader pr)
throws java.io.IOException
pr - java.io.IOExceptionprivate java.lang.Object readArray(int typeCode,
java.io.PushbackReader pr)
throws java.io.IOException
java.io.IOExceptionprivate java.util.Collection readCollection(int typeCode,
java.io.PushbackReader pr)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.Object readSimple(int code,
java.io.PushbackReader pr)
throws java.io.IOException
java.io.IOExceptionprivate void ensureNext(java.io.PushbackReader pr,
int expected)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String readQuoted(java.io.PushbackReader pr)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String readUnquoted(java.io.PushbackReader pr)
throws java.io.IOException
java.io.IOExceptionprivate int nextToken(java.io.PushbackReader pr,
boolean newLine)
throws java.io.IOException
java.io.IOExceptionprivate int ignorableWhiteSpace(java.io.PushbackReader pr)
throws java.io.IOException
java.io.IOExceptionprivate int ignorablePageBreakAndWhiteSpace(java.io.PushbackReader pr)
throws java.io.IOException
java.io.IOExceptionprivate int read(java.io.PushbackReader pr)
throws java.io.IOException
java.io.IOExceptionprivate int read(java.io.PushbackReader pr,
char[] buf)
throws java.io.IOException
java.io.IOExceptionprivate java.io.IOException readFailure(int current,
int expected)
private static void writeValue(java.io.Writer out,
java.lang.Object value)
throws java.io.IOException
java.io.IOExceptionprivate static void writeArray(java.io.Writer out,
java.lang.Object arrayValue)
throws java.io.IOException
java.io.IOExceptionprivate static void writeCollection(java.io.Writer out,
java.util.Collection collection)
throws java.io.IOException
java.io.IOExceptionprivate static void writeCollectionElement(java.io.Writer out,
java.lang.Object element)
throws java.io.IOException
java.io.IOExceptionprivate static void writeType(java.io.Writer out,
java.lang.Class valueType)
throws java.io.IOException
java.io.IOExceptionprivate static void writeSimple(java.io.Writer out,
java.lang.Object value)
throws java.io.IOException
java.io.IOExceptionprivate static void writeQuoted(java.io.Writer out,
java.lang.String simple)
throws java.io.IOException
java.io.IOException