com.go.trove.util
Class PropertyParser
java.lang.Object
|
+--com.go.trove.util.PropertyParser
- public class PropertyParser
- extends java.lang.Object
Parses a properties file similar to how java.util.Properties does,
except:
- Values have trailing whitespace trimmed.
- Quotation marks ( " or ' ) can be used to define keys and values that
have embedded spaces.
- Quotation marks can also be used to define multi-line keys and values
without having to use continuation characters.
- Properties may be nested using braces '{' and '}'.
Just like Properties, comment lines start with optional whitespace followed
by a '#' or '!'. Keys and values may have an optional '=' or ':' as a
separator, unicode escapes are supported as well as other common escapes.
A line may end in a backslash so that it continues to the next line.
Escapes for brace characters '{' and '}' are also supported.
Example:
# Properties file
foo = bar
foo.sub = blink
empty
block {
inner {
foo = bar
item
}
next.item = "true"
}
section = test {
level = 4
message = "Message: "
}
is equivalent to
# Properties file
foo = bar
foo.sub = blink
empty
block.inner.foo = bar
block.inner.item
block.next.item = true
section = test
section.level = 4
section.message = Message:
- Version:
- 8 , 12/11/00
- Author:
- Brian S O'Neill
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PropertyParser
public PropertyParser(java.util.Map map)
- Parameters:
map - Map to receive properties
addErrorListener
public void addErrorListener(PropertyParser.ErrorListener listener)
removeErrorListener
public void removeErrorListener(PropertyParser.ErrorListener listener)
parse
public void parse(java.io.Reader reader)
throws java.io.IOException
- Parses properties from the given reader and stores them in the Map. To
capture any parsing errors, call addErrorListener prior to parsing.
getErrorCount
public int getErrorCount()
- Total number of errors accumulated by this PropertyParser instance.