Class ConfigurationHandler
java.lang.Object
org.apache.felix.utils.properties.ConfigurationHandler
The
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 .
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Mapprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprivate intprivate static final BitSetprivate intprivate intprotected static final intprotected static final intprivate static final BitSetprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprivate Stringprotected static final Map -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidensureNext(PushbackReader pr, int expected) private intprivate intprivate intnextToken(PushbackReader pr, boolean newLine) private static EnumerationorderedKeys(Dictionary properties) Generates anEnumerationfor the givenDictionarywhere the keys of theDictionaryare provided in sorted order.static Dictionaryread(InputStream ins) Reads configuration data from the givenInputStreamand returns a newDictionaryobject containing the data.private intread(PushbackReader pr) private intread(PushbackReader pr, char[] buf) static Objectprivate ObjectreadArray(int typeCode, PushbackReader pr) private CollectionreadCollection(int typeCode, PushbackReader pr) private IOExceptionreadFailure(int current, int expected) private DictionaryreadInternal(InputStream ins) private Stringprivate ObjectreadSimple(int code, PushbackReader pr) private Stringprivate Objectvalue = type ( "[" values "]" | "(" values ")" | simple ) .static voidwrite(OutputStream out, Dictionary properties) Writes the configuration data from theDictionaryto the givenOutputStream.static Stringprivate static voidwriteArray(Writer out, Object arrayValue) private static voidwriteCollection(Writer out, Collection collection) private static voidwriteCollectionElement(Writer out, Object element) private static voidwriteQuoted(Writer out, String simple) private static voidwriteSimple(Writer out, Object value) private static voidprivate static voidwriteValue(Writer out, Object value)
-
Field Details
-
ENCODING
- See Also:
-
TOKEN_NAME
protected static final int TOKEN_NAME- See Also:
-
TOKEN_EQ
protected static final int TOKEN_EQ- See Also:
-
TOKEN_ARR_OPEN
protected static final int TOKEN_ARR_OPEN- See Also:
-
TOKEN_ARR_CLOS
protected static final int TOKEN_ARR_CLOS- See Also:
-
TOKEN_VEC_OPEN
protected static final int TOKEN_VEC_OPEN- See Also:
-
TOKEN_VEC_CLOS
protected static final int TOKEN_VEC_CLOS- See Also:
-
TOKEN_COMMA
protected static final int TOKEN_COMMA- See Also:
-
TOKEN_VAL_OPEN
protected static final int TOKEN_VAL_OPEN- See Also:
-
TOKEN_VAL_CLOS
protected static final int TOKEN_VAL_CLOS- See Also:
-
TOKEN_SPACE
protected static final int TOKEN_SPACE- See Also:
-
TOKEN_COMMENT
protected static final int TOKEN_COMMENT- See Also:
-
TOKEN_SIMPLE_STRING
protected static final int TOKEN_SIMPLE_STRING- See Also:
-
TOKEN_SIMPLE_INTEGER
protected static final int TOKEN_SIMPLE_INTEGER- See Also:
-
TOKEN_SIMPLE_LONG
protected static final int TOKEN_SIMPLE_LONG- See Also:
-
TOKEN_SIMPLE_FLOAT
protected static final int TOKEN_SIMPLE_FLOAT- See Also:
-
TOKEN_SIMPLE_DOUBLE
protected static final int TOKEN_SIMPLE_DOUBLE- See Also:
-
TOKEN_SIMPLE_BYTE
protected static final int TOKEN_SIMPLE_BYTE- See Also:
-
TOKEN_SIMPLE_SHORT
protected static final int TOKEN_SIMPLE_SHORT- See Also:
-
TOKEN_SIMPLE_CHARACTER
protected static final int TOKEN_SIMPLE_CHARACTER- See Also:
-
TOKEN_SIMPLE_BOOLEAN
protected static final int TOKEN_SIMPLE_BOOLEAN- See Also:
-
TOKEN_PRIMITIVE_INT
protected static final int TOKEN_PRIMITIVE_INT- See Also:
-
TOKEN_PRIMITIVE_LONG
protected static final int TOKEN_PRIMITIVE_LONG- See Also:
-
TOKEN_PRIMITIVE_FLOAT
protected static final int TOKEN_PRIMITIVE_FLOAT- See Also:
-
TOKEN_PRIMITIVE_DOUBLE
protected static final int TOKEN_PRIMITIVE_DOUBLE- See Also:
-
TOKEN_PRIMITIVE_BYTE
protected static final int TOKEN_PRIMITIVE_BYTE- See Also:
-
TOKEN_PRIMITIVE_SHORT
protected static final int TOKEN_PRIMITIVE_SHORT- See Also:
-
TOKEN_PRIMITIVE_CHAR
protected static final int TOKEN_PRIMITIVE_CHAR- See Also:
-
TOKEN_PRIMITIVE_BOOLEAN
protected static final int TOKEN_PRIMITIVE_BOOLEAN- See Also:
-
CRLF
- See Also:
-
INDENT
- See Also:
-
COLLECTION_LINE_BREAK
- See Also:
-
code2Type
-
type2Code
-
NAME_CHARS
-
TOKEN_CHARS
-
token
private int token -
tokenValue
-
line
private int line -
pos
private int pos
-
-
Constructor Details
-
ConfigurationHandler
private ConfigurationHandler()
-
-
Method Details
-
write
Writes the configuration data from theDictionaryto the givenOutputStream.This method writes at the current location in the stream and does not close the outputstream.
- Parameters:
out- TheOutputStreamto write the configurtion data to.properties- TheDictionaryto write.- Throws:
IOException- If an error occurrs writing to the output stream.
-
write
- Throws:
IOException
-
orderedKeys
Generates anEnumerationfor the givenDictionarywhere the keys of theDictionaryare provided in sorted order.- Parameters:
properties- TheDictionarythat keys are sorted.- Returns:
- An
Enumerationthat provides the keys of properties in an ordered manner.
-
read
Reads configuration data from the givenInputStreamand returns a newDictionaryobject 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.
- Parameters:
ins- TheInputStreamfrom which to read the configuration data.- Returns:
- A
Dictionaryobject containing the configuration data. This object may be empty if the stream contains no configuration data. - Throws:
IOException- If an error occurrs reading from the stream. This exception is also thrown if a syntax error is encountered.
-
read
- Throws:
IOException
-
readInternal
- Throws:
IOException
-
readValue
value = type ( "[" values "]" | "(" values ")" | simple ) . values = value { "," value } . simple = "{" stringsimple "}" . type = // 1-char type code . stringsimple = // quoted string representation of the value .- Parameters:
pr-- Returns:
- Throws:
IOException
-
readArray
- Throws:
IOException
-
readCollection
- Throws:
IOException
-
readSimple
- Throws:
IOException
-
ensureNext
- Throws:
IOException
-
readQuoted
- Throws:
IOException
-
readUnquoted
- Throws:
IOException
-
nextToken
- Throws:
IOException
-
ignorableWhiteSpace
- Throws:
IOException
-
ignorablePageBreakAndWhiteSpace
- Throws:
IOException
-
read
- Throws:
IOException
-
read
- Throws:
IOException
-
readFailure
-
writeValue
- Throws:
IOException
-
writeArray
- Throws:
IOException
-
writeCollection
- Throws:
IOException
-
writeCollectionElement
- Throws:
IOException
-
writeType
- Throws:
IOException
-
writeSimple
- Throws:
IOException
-
writeQuoted
- Throws:
IOException
-