Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.go.trove.util
Class PropertyParser  view PropertyParser download PropertyParser.java

java.lang.Object
  extended bycom.go.trove.util.PropertyParser

public class PropertyParser
extends java.lang.Object

Parses a properties file similar to how java.util.Properties does, except:

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

Nested Class Summary
static class PropertyParser.ErrorEvent
           
static interface PropertyParser.ErrorListener
           
private static class PropertyParser.Scanner
           
private static class PropertyParser.Token
           
 
Field Summary
private  int mErrorCount
           
private  java.util.Vector mListeners
           
private  java.util.Map mMap
           
private  PropertyParser.Scanner mScanner
           
 
Constructor Summary
PropertyParser(java.util.Map map)
           
 
Method Summary
 void addErrorListener(PropertyParser.ErrorListener listener)
           
private  void dispatchParseError(PropertyParser.ErrorEvent e)
           
private  void error(java.lang.String str, PropertyParser.Token token)
           
private  void error(java.lang.String str, com.go.trove.io.SourceInfo info)
           
 int getErrorCount()
          Total number of errors accumulated by this PropertyParser instance.
 void parse(java.io.Reader reader)
          Parses properties from the given reader and stores them in the Map.
private  void parseBlock(java.lang.String keyPrefix)
           
private  void parseProperties()
           
private  void parseProperty(java.lang.String keyPrefix, PropertyParser.Token token)
           
private  void parsePropertyList(java.lang.String keyPrefix)
           
private  PropertyParser.Token peek()
           
private  void putProperty(java.lang.String key, java.lang.String value, PropertyParser.Token token)
           
private  PropertyParser.Token read()
           
 void removeErrorListener(PropertyParser.ErrorListener listener)
           
private  void unread(PropertyParser.Token token)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mMap

private java.util.Map mMap

mListeners

private java.util.Vector mListeners

mErrorCount

private int mErrorCount

mScanner

private PropertyParser.Scanner mScanner
Constructor Detail

PropertyParser

public PropertyParser(java.util.Map map)
Method Detail

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