Class ConfigurationHandler
- java.lang.Object
-
- org.apache.felix.utils.properties.ConfigurationHandler
-
public class ConfigurationHandler extends java.lang.ObjectTheConfigurationHandlerclass implements configuration reading form ajava.io.InputStreamand writing to ajava.io.OutputStreamon behalf of theFilePersistenceManagerclass.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
Fields Modifier and Type Field Description protected static java.util.Mapcode2Typeprotected static java.lang.StringCOLLECTION_LINE_BREAKprotected static java.lang.StringCRLFprotected static java.lang.StringENCODINGprotected static java.lang.StringINDENTprivate intlineprivate static java.util.BitSetNAME_CHARSprivate intposprivate inttokenprotected static intTOKEN_ARR_CLOSprotected static intTOKEN_ARR_OPENprivate static java.util.BitSetTOKEN_CHARSprotected static intTOKEN_COMMAprotected static intTOKEN_COMMENTprotected static intTOKEN_EQprotected static intTOKEN_NAMEprotected static intTOKEN_PRIMITIVE_BOOLEANprotected static intTOKEN_PRIMITIVE_BYTEprotected static intTOKEN_PRIMITIVE_CHARprotected static intTOKEN_PRIMITIVE_DOUBLEprotected static intTOKEN_PRIMITIVE_FLOATprotected static intTOKEN_PRIMITIVE_INTprotected static intTOKEN_PRIMITIVE_LONGprotected static intTOKEN_PRIMITIVE_SHORTprotected static intTOKEN_SIMPLE_BOOLEANprotected static intTOKEN_SIMPLE_BYTEprotected static intTOKEN_SIMPLE_CHARACTERprotected static intTOKEN_SIMPLE_DOUBLEprotected static intTOKEN_SIMPLE_FLOATprotected static intTOKEN_SIMPLE_INTEGERprotected static intTOKEN_SIMPLE_LONGprotected static intTOKEN_SIMPLE_SHORTprotected static intTOKEN_SIMPLE_STRINGprotected static intTOKEN_SPACEprotected static intTOKEN_VAL_CLOSprotected static intTOKEN_VAL_OPENprotected static intTOKEN_VEC_CLOSprotected static intTOKEN_VEC_OPENprivate java.lang.StringtokenValueprotected static java.util.Maptype2Code
-
Constructor Summary
Constructors Modifier Constructor Description privateConfigurationHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidensureNext(java.io.PushbackReader pr, int expected)private intignorablePageBreakAndWhiteSpace(java.io.PushbackReader pr)private intignorableWhiteSpace(java.io.PushbackReader pr)private intnextToken(java.io.PushbackReader pr, boolean newLine)private static java.util.EnumerationorderedKeys(java.util.Dictionary properties)Generates anEnumerationfor the givenDictionarywhere the keys of theDictionaryare provided in sorted order.static java.util.Dictionaryread(java.io.InputStream ins)Reads configuration data from the givenInputStreamand returns a newDictionaryobject containing the data.private intread(java.io.PushbackReader pr)private intread(java.io.PushbackReader pr, char[] buf)static java.lang.Objectread(java.lang.String value)private java.lang.ObjectreadArray(int typeCode, java.io.PushbackReader pr)private java.util.CollectionreadCollection(int typeCode, java.io.PushbackReader pr)private java.io.IOExceptionreadFailure(int current, int expected)private java.util.DictionaryreadInternal(java.io.InputStream ins)private java.lang.StringreadQuoted(java.io.PushbackReader pr)private java.lang.ObjectreadSimple(int code, java.io.PushbackReader pr)private java.lang.StringreadUnquoted(java.io.PushbackReader pr)private java.lang.ObjectreadValue(java.io.PushbackReader pr)value = type ( "[" values "]" | "(" values ")" | simple ) .static voidwrite(java.io.OutputStream out, java.util.Dictionary properties)Writes the configuration data from theDictionaryto the givenOutputStream.static java.lang.Stringwrite(java.lang.Object value)private static voidwriteArray(java.io.Writer out, java.lang.Object arrayValue)private static voidwriteCollection(java.io.Writer out, java.util.Collection collection)private static voidwriteCollectionElement(java.io.Writer out, java.lang.Object element)private static voidwriteQuoted(java.io.Writer out, java.lang.String simple)private static voidwriteSimple(java.io.Writer out, java.lang.Object value)private static voidwriteType(java.io.Writer out, java.lang.Class valueType)private static voidwriteValue(java.io.Writer out, java.lang.Object value)
-
-
-
Field Detail
-
ENCODING
protected static final java.lang.String ENCODING
- See Also:
- Constant Field Values
-
TOKEN_NAME
protected static final int TOKEN_NAME
- See Also:
- Constant Field Values
-
TOKEN_EQ
protected static final int TOKEN_EQ
- See Also:
- Constant Field Values
-
TOKEN_ARR_OPEN
protected static final int TOKEN_ARR_OPEN
- See Also:
- Constant Field Values
-
TOKEN_ARR_CLOS
protected static final int TOKEN_ARR_CLOS
- See Also:
- Constant Field Values
-
TOKEN_VEC_OPEN
protected static final int TOKEN_VEC_OPEN
- See Also:
- Constant Field Values
-
TOKEN_VEC_CLOS
protected static final int TOKEN_VEC_CLOS
- See Also:
- Constant Field Values
-
TOKEN_COMMA
protected static final int TOKEN_COMMA
- See Also:
- Constant Field Values
-
TOKEN_VAL_OPEN
protected static final int TOKEN_VAL_OPEN
- See Also:
- Constant Field Values
-
TOKEN_VAL_CLOS
protected static final int TOKEN_VAL_CLOS
- See Also:
- Constant Field Values
-
TOKEN_SPACE
protected static final int TOKEN_SPACE
- See Also:
- Constant Field Values
-
TOKEN_COMMENT
protected static final int TOKEN_COMMENT
- See Also:
- Constant Field Values
-
TOKEN_SIMPLE_STRING
protected static final int TOKEN_SIMPLE_STRING
- See Also:
- Constant Field Values
-
TOKEN_SIMPLE_INTEGER
protected static final int TOKEN_SIMPLE_INTEGER
- See Also:
- Constant Field Values
-
TOKEN_SIMPLE_LONG
protected static final int TOKEN_SIMPLE_LONG
- See Also:
- Constant Field Values
-
TOKEN_SIMPLE_FLOAT
protected static final int TOKEN_SIMPLE_FLOAT
- See Also:
- Constant Field Values
-
TOKEN_SIMPLE_DOUBLE
protected static final int TOKEN_SIMPLE_DOUBLE
- See Also:
- Constant Field Values
-
TOKEN_SIMPLE_BYTE
protected static final int TOKEN_SIMPLE_BYTE
- See Also:
- Constant Field Values
-
TOKEN_SIMPLE_SHORT
protected static final int TOKEN_SIMPLE_SHORT
- See Also:
- Constant Field Values
-
TOKEN_SIMPLE_CHARACTER
protected static final int TOKEN_SIMPLE_CHARACTER
- See Also:
- Constant Field Values
-
TOKEN_SIMPLE_BOOLEAN
protected static final int TOKEN_SIMPLE_BOOLEAN
- See Also:
- Constant Field Values
-
TOKEN_PRIMITIVE_INT
protected static final int TOKEN_PRIMITIVE_INT
- See Also:
- Constant Field Values
-
TOKEN_PRIMITIVE_LONG
protected static final int TOKEN_PRIMITIVE_LONG
- See Also:
- Constant Field Values
-
TOKEN_PRIMITIVE_FLOAT
protected static final int TOKEN_PRIMITIVE_FLOAT
- See Also:
- Constant Field Values
-
TOKEN_PRIMITIVE_DOUBLE
protected static final int TOKEN_PRIMITIVE_DOUBLE
- See Also:
- Constant Field Values
-
TOKEN_PRIMITIVE_BYTE
protected static final int TOKEN_PRIMITIVE_BYTE
- See Also:
- Constant Field Values
-
TOKEN_PRIMITIVE_SHORT
protected static final int TOKEN_PRIMITIVE_SHORT
- See Also:
- Constant Field Values
-
TOKEN_PRIMITIVE_CHAR
protected static final int TOKEN_PRIMITIVE_CHAR
- See Also:
- Constant Field Values
-
TOKEN_PRIMITIVE_BOOLEAN
protected static final int TOKEN_PRIMITIVE_BOOLEAN
- See Also:
- Constant Field Values
-
CRLF
protected static final java.lang.String CRLF
- See Also:
- Constant Field Values
-
INDENT
protected static final java.lang.String INDENT
- See Also:
- Constant Field Values
-
COLLECTION_LINE_BREAK
protected static final java.lang.String COLLECTION_LINE_BREAK
- See Also:
- Constant Field Values
-
code2Type
protected static final java.util.Map code2Type
-
type2Code
protected static final java.util.Map type2Code
-
NAME_CHARS
private static final java.util.BitSet NAME_CHARS
-
TOKEN_CHARS
private static final java.util.BitSet TOKEN_CHARS
-
token
private int token
-
tokenValue
private java.lang.String tokenValue
-
line
private int line
-
pos
private int pos
-
-
Method Detail
-
write
public static void write(java.io.OutputStream out, java.util.Dictionary properties) throws java.io.IOExceptionWrites 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:
java.io.IOException- If an error occurrs writing to the output stream.
-
write
public static java.lang.String write(java.lang.Object value) throws java.io.IOException- Throws:
java.io.IOException
-
orderedKeys
private static java.util.Enumeration orderedKeys(java.util.Dictionary properties)
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
public static java.util.Dictionary read(java.io.InputStream ins) throws java.io.IOExceptionReads 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:
java.io.IOException- If an error occurrs reading from the stream. This exception is also thrown if a syntax error is encountered.
-
read
public static java.lang.Object read(java.lang.String value) throws java.io.IOException- Throws:
java.io.IOException
-
readInternal
private java.util.Dictionary readInternal(java.io.InputStream ins) throws java.io.IOException- Throws:
java.io.IOException
-
readValue
private java.lang.Object readValue(java.io.PushbackReader pr) throws java.io.IOExceptionvalue = 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:
java.io.IOException
-
readArray
private java.lang.Object readArray(int typeCode, java.io.PushbackReader pr) throws java.io.IOException- Throws:
java.io.IOException
-
readCollection
private java.util.Collection readCollection(int typeCode, java.io.PushbackReader pr) throws java.io.IOException- Throws:
java.io.IOException
-
readSimple
private java.lang.Object readSimple(int code, java.io.PushbackReader pr) throws java.io.IOException- Throws:
java.io.IOException
-
ensureNext
private void ensureNext(java.io.PushbackReader pr, int expected) throws java.io.IOException- Throws:
java.io.IOException
-
readQuoted
private java.lang.String readQuoted(java.io.PushbackReader pr) throws java.io.IOException- Throws:
java.io.IOException
-
readUnquoted
private java.lang.String readUnquoted(java.io.PushbackReader pr) throws java.io.IOException- Throws:
java.io.IOException
-
nextToken
private int nextToken(java.io.PushbackReader pr, boolean newLine) throws java.io.IOException- Throws:
java.io.IOException
-
ignorableWhiteSpace
private int ignorableWhiteSpace(java.io.PushbackReader pr) throws java.io.IOException- Throws:
java.io.IOException
-
ignorablePageBreakAndWhiteSpace
private int ignorablePageBreakAndWhiteSpace(java.io.PushbackReader pr) throws java.io.IOException- Throws:
java.io.IOException
-
read
private int read(java.io.PushbackReader pr) throws java.io.IOException- Throws:
java.io.IOException
-
read
private int read(java.io.PushbackReader pr, char[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
readFailure
private java.io.IOException readFailure(int current, int expected)
-
writeValue
private static void writeValue(java.io.Writer out, java.lang.Object value) throws java.io.IOException- Throws:
java.io.IOException
-
writeArray
private static void writeArray(java.io.Writer out, java.lang.Object arrayValue) throws java.io.IOException- Throws:
java.io.IOException
-
writeCollection
private static void writeCollection(java.io.Writer out, java.util.Collection collection) throws java.io.IOException- Throws:
java.io.IOException
-
writeCollectionElement
private static void writeCollectionElement(java.io.Writer out, java.lang.Object element) throws java.io.IOException- Throws:
java.io.IOException
-
writeType
private static void writeType(java.io.Writer out, java.lang.Class valueType) throws java.io.IOException- Throws:
java.io.IOException
-
writeSimple
private static void writeSimple(java.io.Writer out, java.lang.Object value) throws java.io.IOException- Throws:
java.io.IOException
-
writeQuoted
private static void writeQuoted(java.io.Writer out, java.lang.String simple) throws java.io.IOException- Throws:
java.io.IOException
-
-