Class GapFeaturedGrammarFileHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byGrammarFileHandler
          extended byAugmentedGrammarFileHandler
              extended byHeadFeaturedGrammarFileHandler
                  extended byGapFeaturedGrammarFileHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class GapFeaturedGrammarFileHandler
extends HeadFeaturedGrammarFileHandler

An GapFeaturedGrammarFileHandler reads grammars whose constituents are HeadFeaturedConstituents. The main difference from the HeadFeaturedGrammarFileHandler is that we need to properly parse embedded constituents as the value of the GAP feature.

See Also:
GapFeaturedChartParser

Field Summary
(package private)  boolean isEmbedded
           
(package private)  Symbol savedCat
           
(package private)  Symbol savedFeature
           
(package private)  FeatureSet savedFeatures
           
(package private)  boolean savedIsHead
           
(package private) static int STATE_LEXICALCATEGORIES
           
 
Fields inherited from class HeadFeaturedGrammarFileHandler
isHead, STATE_HEADFEATURES
 
Fields inherited from class AugmentedGrammarFileHandler
feature, features, STATE_FEATURE, varTable
 
Fields inherited from class GrammarFileHandler
cat, constits, grammar, locator, ruleId, state, STATE_CONSTIT, STATE_DESCRIPTION, STATE_FILE, STATE_GRAMMAR, STATE_RULE, textBuffer
 
Constructor Summary
GapFeaturedGrammarFileHandler(GapFeaturedGrammar g)
          Create a new GapFeaturedGrammarFileHandler to read into the given GapFeaturedGrammar.
 
Method Summary
 void characters(char[] buf, int offset, int len)
          Called by the SAX parsing engine when characters are read outside of any element tag.
 void endElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName)
          SAX ContentHandler method called when an end-element tag is encountered.
static void main(java.lang.String[] argv)
          Test the GrammarFileHandler.
 void startElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName, org.xml.sax.Attributes attrs)
          SAX ContentHandler method called when a start-element tag is encountered.
 
Methods inherited from class GrammarFileHandler
consumeText, error, ERROR, fatalError, readFile, setDocumentLocator, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_LEXICALCATEGORIES

static final int STATE_LEXICALCATEGORIES
See Also:
Constant Field Values

isEmbedded

boolean isEmbedded

savedCat

Symbol savedCat

savedFeature

Symbol savedFeature

savedFeatures

FeatureSet savedFeatures

savedIsHead

boolean savedIsHead
Constructor Detail

GapFeaturedGrammarFileHandler

public GapFeaturedGrammarFileHandler(GapFeaturedGrammar g)
Create a new GapFeaturedGrammarFileHandler to read into the given GapFeaturedGrammar.

Method Detail

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String sName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Description copied from class: GrammarFileHandler
SAX ContentHandler method called when a start-element tag is encountered.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class HeadFeaturedGrammarFileHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String sName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Description copied from class: GrammarFileHandler
SAX ContentHandler method called when an end-element tag is encountered.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class HeadFeaturedGrammarFileHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] buf,
                       int offset,
                       int len)
                throws org.xml.sax.SAXException
Description copied from class: GrammarFileHandler
Called by the SAX parsing engine when characters are read outside of any element tag. This can be called multiple times, such as when the text spans multiple lines (depends on whitespace treatment, whether the parser is validating, etc.). So the safe thing to do is just hold onto the text for later use when an end-element tag is reached (assuming we don't care about the actual form of the original text, but just its content, which is the case for us). We could be more careful, saving the text in states where we're expecting text and otherwise indicating a state-specific error, but frankly I don't care that much.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class HeadFeaturedGrammarFileHandler
Throws:
org.xml.sax.SAXException

main

public static void main(java.lang.String[] argv)
                 throws java.io.IOException
Description copied from class: GrammarFileHandler
Test the GrammarFileHandler.

Throws:
java.io.IOException