gate.config
Class ConfigXmlHandler

java.lang.Object
  |
  +--org.xml.sax.HandlerBase
        |
        +--gate.config.ConfigXmlHandler
All Implemented Interfaces:
org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ConfigXmlHandler
extends org.xml.sax.HandlerBase

This is a SAX handler for processing gate.xml files.


Field Summary
private  Stack contentStack
          A stack to stuff PCDATA onto for reading back at element ends.
private  FeatureMap currentAttributeMap
          A feature map representation of the current element's attribute list
private  org.xml.sax.AttributeList currentAttributes
          The current element's attribute list
private static boolean DEBUG
          Debug flag
private  CreoleRegister register
          The register object that we add CREOLE directories to during parsing.
private  URL sourceUrl
          The source URL of the config file being parsed.
private  SystemData systemData
          The current resource data object
 
Constructor Summary
ConfigXmlHandler(URL configUrl)
          Construction
 
Method Summary
protected  FeatureMap attributeListToParameterList()
          Utility method to convert the current SAX attribute list to a FeatureMap
 void characters(char[] text, int start, int length)
          Called when the SAX parser encounts text (PCDATA) in the XML doc
private  void checkStack(String methodName, String elementName)
          Utility function to throw exceptions on stack errors.
protected  void createResource(String resourceTypeName, List resourceList)
          Utility method to create a resource and add to appropriate list.
 void endDocument()
          Called when the SAX parser encounts the end of the XML document
 void endElement(String elementName)
          Called when the SAX parser encounts the end of an XML element.
 void error(org.xml.sax.SAXParseException ex)
          Called for parse errors.
 void fatalError(org.xml.sax.SAXParseException ex)
          Called for fatal errors.
 void ignorableWhitespace(char[] ch, int start, int length)
          Called when the SAX parser encounts white space
 void startDocument()
          Called when the SAX parser encounts the beginning of the XML document
 void startElement(String elementName, org.xml.sax.AttributeList atts)
          Called when the SAX parser encounts the beginning of an XML element
 void warning(org.xml.sax.SAXParseException ex)
          Called for warnings.
 
Methods inherited from class org.xml.sax.HandlerBase
notationDecl, processingInstruction, resolveEntity, setDocumentLocator, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

contentStack

private Stack contentStack
A stack to stuff PCDATA onto for reading back at element ends. (Probably redundant to have a stack as we only push one item onto it. Probably. Ok, so I should check, but a) it works, b) I'm bald already and c) life is short.)

systemData

private SystemData systemData
The current resource data object

currentAttributes

private org.xml.sax.AttributeList currentAttributes
The current element's attribute list

currentAttributeMap

private FeatureMap currentAttributeMap
A feature map representation of the current element's attribute list

DEBUG

private static final boolean DEBUG
Debug flag

sourceUrl

private URL sourceUrl
The source URL of the config file being parsed.

register

private CreoleRegister register
The register object that we add CREOLE directories to during parsing.
Constructor Detail

ConfigXmlHandler

public ConfigXmlHandler(URL configUrl)
Construction
Method Detail

startDocument

public void startDocument()
                   throws GateSaxException
Called when the SAX parser encounts the beginning of the XML document
Overrides:
startDocument in class org.xml.sax.HandlerBase

endDocument

public void endDocument()
                 throws GateSaxException
Called when the SAX parser encounts the end of the XML document
Overrides:
endDocument in class org.xml.sax.HandlerBase

startElement

public void startElement(String elementName,
                         org.xml.sax.AttributeList atts)
Called when the SAX parser encounts the beginning of an XML element
Overrides:
startElement in class org.xml.sax.HandlerBase

checkStack

private void checkStack(String methodName,
                        String elementName)
                 throws GateSaxException
Utility function to throw exceptions on stack errors.

endElement

public void endElement(String elementName)
                throws GateSaxException
Called when the SAX parser encounts the end of an XML element. This is actions happen.
Overrides:
endElement in class org.xml.sax.HandlerBase

characters

public void characters(char[] text,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Called when the SAX parser encounts text (PCDATA) in the XML doc
Overrides:
characters in class org.xml.sax.HandlerBase

createResource

protected void createResource(String resourceTypeName,
                              List resourceList)
                       throws GateSaxException
Utility method to create a resource and add to appropriate list. Parameters for the resource are pulled out of the current attribute list.

attributeListToParameterList

protected FeatureMap attributeListToParameterList()
Utility method to convert the current SAX attribute list to a FeatureMap

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Called when the SAX parser encounts white space
Overrides:
ignorableWhitespace in class org.xml.sax.HandlerBase

error

public void error(org.xml.sax.SAXParseException ex)
           throws org.xml.sax.SAXException
Called for parse errors.
Overrides:
error in class org.xml.sax.HandlerBase

fatalError

public void fatalError(org.xml.sax.SAXParseException ex)
                throws org.xml.sax.SAXException
Called for fatal errors.
Overrides:
fatalError in class org.xml.sax.HandlerBase

warning

public void warning(org.xml.sax.SAXParseException ex)
             throws org.xml.sax.SAXException
Called for warnings.
Overrides:
warning in class org.xml.sax.HandlerBase