| 
 | Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.io.gml.ItemParser
public class ItemParser
This class can be used as a base class for parsers, that want to
 parse items. It will intercept events which are delivered by the
 GMLTokenizer, store top scope level attributes in a Map. It can be provided
 with child ItemParser instances, that will be automatically be invoked
 for subsections. Implementers basically need to overwrite three
 methods in order to get a working parser.
 begin() will be automatically called when the parsers
 enters the scope level. Subclasses, that overwrite this method should
 should make a super call, since the internal attribute map will be
 cleared there.
 childFinished(y.io.gml.ItemParser) will be called as soon as the parser leaves
 the scope of a child ItemParser, after the child's end() method
 has been called.
 end() will be called as soon as the current scope will be left.
 Instances can than process the attributes and the results of the child
 parsers to produce a suitable item.
| Field Summary | |
|---|---|
| protected  java.util.Map | attributesthe attribute map, used to store key value pairs which belong to the top level only | 
| protected  java.util.Map | childMapthe map of section names to child ItemParser instances | 
| protected  ItemParser | delegatethe currently active child | 
| protected  int | levelthe relative scope depth of the parser, i.e. 0 if we are on the current top level, and positive if in a subsection | 
| Constructor Summary | |
|---|---|
| ItemParser()constructs a new ItemParser with no children. | |
| Method Summary | |
|---|---|
|  void | addAttribute(java.lang.String key,
             java.lang.Object value)Puts the key value pair into the local attribute map | 
|  void | addChild(java.lang.String scopeName,
         ItemParser child)add a child ItemParser, to which events will be delegated if the parser comes across a section with the specified scope name. | 
|  void | attribute(java.lang.String key,
          java.lang.Number value)Note: subclass implementers should make a super call, if they want to overwrite this method. | 
|  void | attribute(java.lang.String key,
          java.lang.String value)Note: subclass implementers should make a super call, if they want to overwrite this method. | 
|  void | begin()this method will be called as soon as the parser enters the scope. | 
|  void | beginScope(java.lang.String scopeName)Note: subclass implementers should make a super call, if they want to overwrite this method. | 
|  void | childFinished(ItemParser p)this method will be called, as soon as the a child ItemParser finished and returned from its end() method. | 
|  void | end()this method will be called as soon as the parser leaves the scope. | 
|  void | endScope(java.lang.String endScope)Note: subclass implementers should make a super call, if they want to overwrite this method. | 
|  java.util.Map | getAttributes()Getter for property attributes. | 
|  boolean | getBoolean(java.lang.String key)Convenience method, which returns trueif and only if there is
 an integer attribute valued >0 in the table for the key. | 
|  double | getDouble(java.lang.String key)Convenience method, which returns a double if there is an numeric attribute in the table for the key, or 0.0d | 
|  double | getDouble(java.lang.String key,
          double defaultValue)Convenience method, which returns a double if there is an numeric attribute in the table for the key, or the default value | 
|  int | getInt(java.lang.String key)Convenience method, which returns a double if there is an numeric attribute in the table for the key, or 0 | 
|  int | getInt(java.lang.String key,
       int defaultValue)Convenience method, which returns an int if there is an numeric attribute in the table for the key, or the default value | 
|  java.lang.Object | getItem()Returns the "product" of this scope. | 
|  int | getLevel()Getter for property level. | 
|  java.lang.String | getString(java.lang.String key)Returns a String representation of the value in the map for key. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected int level
protected java.util.Map childMap
protected java.util.Map attributes
protected ItemParser delegate
| Constructor Detail | 
|---|
public ItemParser()
| Method Detail | 
|---|
public void addChild(java.lang.String scopeName,
                     ItemParser child)
scopeName - the name of the sub sectionchild - the responsible ItemParserpublic void beginScope(java.lang.String scopeName)
beginScope in interface GMLTokenizer.CallbackscopeName - the name of the scopepublic void endScope(java.lang.String endScope)
endScope in interface GMLTokenizer.CallbackendScope - the name of the scope which was left
public void attribute(java.lang.String key,
                      java.lang.String value)
attribute in interface GMLTokenizer.Callbackkey - the key of the attribute value pairvalue - the string value
public void attribute(java.lang.String key,
                      java.lang.Number value)
attribute in interface GMLTokenizer.Callbackkey - the key of the attribute value pairvalue - the numeric value
public void addAttribute(java.lang.String key,
                         java.lang.Object value)
key - the keyvalue - the valuepublic boolean getBoolean(java.lang.String key)
true if and only if there is
 an integer attribute valued >0 in the table for the key.
key - the key
true, iff map.get(key)!= null and the value is an
 positive Integerpublic java.lang.String getString(java.lang.String key)
key - the key
nullpublic double getDouble(java.lang.String key)
0.0d
key - the key
0.0d
public double getDouble(java.lang.String key,
                        double defaultValue)
key - the keydefaultValue - a default value
public int getInt(java.lang.String key)
0
key - the key
0
public int getInt(java.lang.String key,
                  int defaultValue)
key - the keydefaultValue - the default value
public void begin()
public void end()
public java.lang.Object getItem()
end() has been called. The latter should construct
 the resulting item from the collected data and this item
 should be returned by this method. By default, this method
 return the map of the attributes.
Mappublic void childFinished(ItemParser p)
p - the child ItemParser, which just finishedpublic int getLevel()
public java.util.Map getAttributes()
| 
 | © Copyright 2000-2025, yWorks GmbH. All rights reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||