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
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
mMap
private java.util.Map mMap
mListeners
private java.util.Vector mListeners
mErrorCount
private int mErrorCount
mScanner
private PropertyParser.Scanner mScanner
PropertyParser
public PropertyParser(java.util.Map map)
addErrorListener
public void addErrorListener(PropertyParser.ErrorListener listener)
removeErrorListener
public void removeErrorListener(PropertyParser.ErrorListener listener)
dispatchParseError
private void dispatchParseError(PropertyParser.ErrorEvent e)
error
private void error(java.lang.String str,
com.go.trove.io.SourceInfo info)
error
private void error(java.lang.String str,
PropertyParser.Token token)
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.
parseProperties
private void parseProperties()
throws java.io.IOException
parsePropertyList
private void parsePropertyList(java.lang.String keyPrefix)
throws java.io.IOException
parseProperty
private void parseProperty(java.lang.String keyPrefix,
PropertyParser.Token token)
throws java.io.IOException
parseBlock
private void parseBlock(java.lang.String keyPrefix)
throws java.io.IOException
putProperty
private void putProperty(java.lang.String key,
java.lang.String value,
PropertyParser.Token token)
getErrorCount
public int getErrorCount()
- Total number of errors accumulated by this PropertyParser instance.
read
private PropertyParser.Token read()
throws java.io.IOException
peek
private PropertyParser.Token peek()
throws java.io.IOException
unread
private void unread(PropertyParser.Token token)
throws java.io.IOException