Class Properties.PropertiesReader
java.lang.Object
java.io.Reader
java.io.BufferedReader
java.io.LineNumberReader
org.apache.felix.utils.properties.Properties.PropertiesReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
- Enclosing class:
Properties
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionStores the comment lines for the currently processed property.private booleanprivate StringStores the name of the last read property.private StringStores the value of the last read property.(package private) BooleanStores if the properties are typed or notStores the value lines for the currently processed property. -
Constructor Summary
ConstructorsConstructorDescriptionPropertiesReader(Reader reader, boolean maybeTyped) Creates a new instance ofPropertiesReaderand sets the underlaying reader and the list delimiter. -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleancheckCombineLines(String line) Checks if the passed in line should be combined with the following.Returns the comment lines that have been read for the last property.Returns the name of the last read property.Returns the value of the last read property.Returns the value lines that have been read for the last property.booleanParses the next property from the input stream and stores the found name and value in internal fields.private static String[]parseProperty(String line) Parse a property line and return the key and the value in an array.Reads a property line.Methods inherited from class java.io.LineNumberReader
getLineNumber, mark, read, read, readLine, reset, setLineNumber, skipMethods inherited from class java.io.BufferedReader
close, lines, markSupported, readyMethods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Field Details
-
commentLines
Stores the comment lines for the currently processed property. -
valueLines
Stores the value lines for the currently processed property. -
propertyName
Stores the name of the last read property. -
propertyValue
Stores the value of the last read property. -
maybeTyped
private boolean maybeTyped -
typed
Boolean typedStores if the properties are typed or not
-
-
Constructor Details
-
PropertiesReader
Creates a new instance ofPropertiesReaderand sets the underlaying reader and the list delimiter.- Parameters:
reader- the reader
-
-
Method Details
-
readProperty
Reads a property line. Returns null if Stream is at EOF. Concatenates lines ending with "\". Skips lines beginning with "#" or "!" and empty lines. The return value is a property definition (<name>=<value>)- Returns:
- A string containing a property value or null
- Throws:
IOException- in case of an I/O error
-
nextProperty
Parses the next property from the input stream and stores the found name and value in internal fields. These fields can be obtained using the provided getter methods. The return value indicates whether EOF was reached (false) or whether further properties are available (true).- Returns:
- a flag if further properties are available
- Throws:
IOException- if an error occurs
-
getCommentLines
Returns the comment lines that have been read for the last property.- Returns:
- the comment lines for the last property returned by
readProperty()
-
getValueLines
Returns the value lines that have been read for the last property.- Returns:
- the raw value lines for the last property returned by
readProperty()
-
getPropertyName
Returns the name of the last read property. This method can be called afterwas invoked and its return value was true.nextProperty()- Returns:
- the name of the last read property
-
getPropertyValue
Returns the value of the last read property. This method can be called afterwas invoked and its return value was true.nextProperty()- Returns:
- the value of the last read property
-
checkCombineLines
Checks if the passed in line should be combined with the following. This is true, if the line ends with an odd number of backslashes.- Parameters:
line- the line- Returns:
- a flag if the lines should be combined
-
parseProperty
Parse a property line and return the key and the value in an array.- Parameters:
line- the line to parse- Returns:
- an array with the property's key and value
-