diva.sketch.parser2d
Class Grammar2dParser

java.lang.Object
  |
  +--com.microstar.xml.HandlerBase
        |
        +--diva.sketch.parser2d.Grammar2dParser

public class Grammar2dParser
extends com.microstar.xml.HandlerBase

Reads in an XML file and parses it into an array of rules that make up a grammar.

Version:
$Revision: 1.1 $

Field Summary
static java.lang.String ANGLE_TAG
          The string constant that specifies an angle constraint element.
static java.lang.String AREA_TAG
          The string constant that specifies an area ratio constraint element.
static java.lang.String CONSTRAINT_TAG
          The string constant that specifies the constraint attribute of an overlap constraint element.
static double DEFAULT_ANGLE_TOLERANCE
          FIXME ??? this parser is smart
static java.lang.String DIRECTION_TAG
          The string constant that specifies the direction attribute of an angle constraint element.
static java.lang.String DISTANCE_TAG
          The string constant that specifies a distance constraint element.
static java.lang.String GRAMMAR_TAG
          The string constant that specifies a grammar element.
static java.lang.String HEIGHT_TAG
          The string constant that specifies an height ratio constraint element.
static java.lang.String MAX_TAG
          The string constant that specifies the max attribute of a constraint element.
static java.lang.String MIN_TAG
          The string constant that specifies the min attribute of a constraint element.
static java.lang.String NAME_TAG
          The string constant that specifies the name attribute of a root or a relative.
static java.lang.String OVERLAP_TAG
          The string constant that specifies an overlap constraint element.
static java.lang.String RELATIVE_SITE_TAG
          The string constant that specifies the relativeSite attribute of a distance or angle constraint element.
static java.lang.String RELATIVE_TAG
          The string constant that specifies a relative element.
static java.lang.String ROOT_SITE_TAG
          The string constant that specifies the rootSite attribute of a distance or angle constraint element.
static java.lang.String ROOT_TAG
          The string constant that specifies a root element.
static java.lang.String RULE_TAG
          The string constant that specifies a rule element.
static java.lang.String TITLE_TAG
          The string constant that specifies the title attribute of a grammar.
static java.lang.String TYPE_TAG
          The string constant that specifies the type attribute of a rule, a root, or a relative.
static java.lang.String VERSION_TAG
          The string constant that specifies the version attribute of a grammar.
static java.lang.String WHICH_TAG
          The string constant that specifies the "which" attribute of an overlap constraint element.
static java.lang.String WIDTH_TAG
          The string constant that specifies an width ratio constraint element.
 
Constructor Summary
Grammar2dParser()
           
 
Method Summary
 void attribute(java.lang.String name, java.lang.String value, boolean isSpecified)
          Handle an attribute value assignment.
 void endElement(java.lang.String name)
          Handle the end of an element.
 void error(java.lang.String message)
          Handle a parsing error by throwing an exception with the given error message prepended with the line number and column number.
 Rule[] getRules()
          Return the resulting set of rules from the previous parse.
static void main(java.lang.String[] args)
          Test this puppy out!
 Rule[] parse(java.lang.String url)
          Create the full path string for the url and parses the file into a Document object.
protected  void resetConstraintState()
          Reset the parsing state from the previous constraint that was parsed.
protected  void resetParseState()
          Reset the parsing state from the previous rule that was parsed.
protected  void resetRelativeState()
          Reset the parsing state from the previous rule that was parsed.
protected  void resetRuleState()
          Reset the parsing state from the previous rule that was parsed.
 void startElement(java.lang.String name)
          Handle the start of an element.
 
Methods inherited from class com.microstar.xml.HandlerBase
charData, doctypeDecl, endDocument, endExternalEntity, error, ignorableWhitespace, processingInstruction, resolveEntity, startDocument, startExternalEntity
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ANGLE_TOLERANCE

public static final double DEFAULT_ANGLE_TOLERANCE
FIXME ??? this parser is smart

GRAMMAR_TAG

public static final java.lang.String GRAMMAR_TAG
The string constant that specifies a grammar element.

VERSION_TAG

public static final java.lang.String VERSION_TAG
The string constant that specifies the version attribute of a grammar.

TITLE_TAG

public static final java.lang.String TITLE_TAG
The string constant that specifies the title attribute of a grammar.

RULE_TAG

public static final java.lang.String RULE_TAG
The string constant that specifies a rule element.

TYPE_TAG

public static final java.lang.String TYPE_TAG
The string constant that specifies the type attribute of a rule, a root, or a relative.

ROOT_TAG

public static final java.lang.String ROOT_TAG
The string constant that specifies a root element.

NAME_TAG

public static final java.lang.String NAME_TAG
The string constant that specifies the name attribute of a root or a relative.

RELATIVE_TAG

public static final java.lang.String RELATIVE_TAG
The string constant that specifies a relative element.

DISTANCE_TAG

public static final java.lang.String DISTANCE_TAG
The string constant that specifies a distance constraint element.

ROOT_SITE_TAG

public static final java.lang.String ROOT_SITE_TAG
The string constant that specifies the rootSite attribute of a distance or angle constraint element.

RELATIVE_SITE_TAG

public static final java.lang.String RELATIVE_SITE_TAG
The string constant that specifies the relativeSite attribute of a distance or angle constraint element.

MIN_TAG

public static final java.lang.String MIN_TAG
The string constant that specifies the min attribute of a constraint element.

MAX_TAG

public static final java.lang.String MAX_TAG
The string constant that specifies the max attribute of a constraint element.

OVERLAP_TAG

public static final java.lang.String OVERLAP_TAG
The string constant that specifies an overlap constraint element.

CONSTRAINT_TAG

public static final java.lang.String CONSTRAINT_TAG
The string constant that specifies the constraint attribute of an overlap constraint element.

WHICH_TAG

public static final java.lang.String WHICH_TAG
The string constant that specifies the "which" attribute of an overlap constraint element.

ANGLE_TAG

public static final java.lang.String ANGLE_TAG
The string constant that specifies an angle constraint element.

DIRECTION_TAG

public static final java.lang.String DIRECTION_TAG
The string constant that specifies the direction attribute of an angle constraint element.

AREA_TAG

public static final java.lang.String AREA_TAG
The string constant that specifies an area ratio constraint element.

WIDTH_TAG

public static final java.lang.String WIDTH_TAG
The string constant that specifies an width ratio constraint element.

HEIGHT_TAG

public static final java.lang.String HEIGHT_TAG
The string constant that specifies an height ratio constraint element.
Constructor Detail

Grammar2dParser

public Grammar2dParser()
Method Detail

resetParseState

protected void resetParseState()
Reset the parsing state from the previous rule that was parsed.

resetRuleState

protected void resetRuleState()
Reset the parsing state from the previous rule that was parsed.

resetRelativeState

protected void resetRelativeState()
Reset the parsing state from the previous rule that was parsed.

resetConstraintState

protected void resetConstraintState()
Reset the parsing state from the previous constraint that was parsed.

attribute

public void attribute(java.lang.String name,
                      java.lang.String value,
                      boolean isSpecified)
Handle an attribute value assignment.
Overrides:
attribute in class com.microstar.xml.HandlerBase
See Also:
XmlHandler.attribute(java.lang.String, java.lang.String, boolean)

startElement

public void startElement(java.lang.String name)
Handle the start of an element.
Overrides:
startElement in class com.microstar.xml.HandlerBase

endElement

public void endElement(java.lang.String name)
Handle the end of an element.
Overrides:
endElement in class com.microstar.xml.HandlerBase

error

public void error(java.lang.String message)
Handle a parsing error by throwing an exception with the given error message prepended with the line number and column number.

getRules

public Rule[] getRules()
Return the resulting set of rules from the previous parse.

parse

public Rule[] parse(java.lang.String url)
             throws java.lang.Exception
Create the full path string for the url and parses the file into a Document object.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Test this puppy out!