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 Map
protected static final String
protected static final String
protected static final String
protected static final String
private int
private static final BitSet
private int
private int
protected static final int
protected static final int
private static final BitSet
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
private String
protected static final Map
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
ensureNext
(PushbackReader pr, int expected) private int
private int
private int
nextToken
(PushbackReader pr, boolean newLine) private static Enumeration
orderedKeys
(Dictionary properties) Generates anEnumeration
for the givenDictionary
where the keys of theDictionary
are provided in sorted order.static Dictionary
read
(InputStream ins) Reads configuration data from the givenInputStream
and returns a newDictionary
object containing the data.private int
read
(PushbackReader pr) private int
read
(PushbackReader pr, char[] buf) static Object
private Object
readArray
(int typeCode, PushbackReader pr) private Collection
readCollection
(int typeCode, PushbackReader pr) private IOException
readFailure
(int current, int expected) private Dictionary
readInternal
(InputStream ins) private String
private Object
readSimple
(int code, PushbackReader pr) private String
private Object
value = type ( "[" values "]" | "(" values ")" | simple ) .static void
write
(OutputStream out, Dictionary properties) Writes the configuration data from theDictionary
to the givenOutputStream
.static String
private static void
writeArray
(Writer out, Object arrayValue) private static void
writeCollection
(Writer out, Collection collection) private static void
writeCollectionElement
(Writer out, Object element) private static void
writeQuoted
(Writer out, String simple) private static void
writeSimple
(Writer out, Object value) private static void
private static void
writeValue
(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 theDictionary
to the givenOutputStream
.This method writes at the current location in the stream and does not close the outputstream.
- Parameters:
out
- TheOutputStream
to write the configurtion data to.properties
- TheDictionary
to write.- Throws:
IOException
- If an error occurrs writing to the output stream.
-
write
- Throws:
IOException
-
orderedKeys
Generates anEnumeration
for the givenDictionary
where the keys of theDictionary
are provided in sorted order.- Parameters:
properties
- TheDictionary
that keys are sorted.- Returns:
- An
Enumeration
that provides the keys of properties in an ordered manner.
-
read
Reads configuration data from the givenInputStream
and returns a newDictionary
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.
- Parameters:
ins
- TheInputStream
from which to read the configuration data.- Returns:
- A
Dictionary
object 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
-