com.bbn.swede.core.dom
Class OASTHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bycom.bbn.swede.core.dom.OASTHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
Direct Known Subclasses:
OASTStringHandler

public class OASTHandler
extends DefaultHandler

SAX2 event handler for parsing an OWL file into an OAST.

Author:
jlerner

Field Summary
protected  OASTNode _nodeCurrent
          The node currently being handled.
protected  OASTNode _root
          The root node of the parse.
 
Constructor Summary
OASTHandler(OASTNode root)
          Creates an OASTHandler.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void dispose()
          Cleans up resources used by the handler.
 void endElement(String uri, String localName, String qName)
           
protected  void locateNode(OASTNode parent, AttributeNode node)
          Called after an attribute is parsed to set its location.
protected  void locateNode(OASTNode parent, Literal lit)
          Called after CDATA is parsed to set the literal node's location.
protected  void locateNodeBegin(OASTNode node)
          Called after an open tag is parsed to set the tag node's start offset.
protected  void locateNodeEnd(OASTNode node)
          Called after a close tag is parsed to set the tag node's length.
protected  void locateRootNode(OASTNode root)
          Called at the beginning of the parse to set the size and position of the root element for the parse.
protected  void processAttributes(OASTNode parent, Attributes attributes)
          Helper method for parsing the attributes found for a begin tag.
 void setDocumentLocator(Locator locator)
           
 void startDocument()
           
 void startElement(String uri, String localName, String qName, Attributes attributes)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_root

protected OASTNode _root
The root node of the parse.


_nodeCurrent

protected OASTNode _nodeCurrent
The node currently being handled.

Constructor Detail

OASTHandler

public OASTHandler(OASTNode root)
Creates an OASTHandler.

Parameters:
root - The node to treat as the document root
Method Detail

locateNode

protected void locateNode(OASTNode parent,
                          Literal lit)
Called after CDATA is parsed to set the literal node's location. The default implementation does nothing, so nodes will have to be located en masse after the parse is complete.

Parameters:
parent - The parent of the node to locate
lit - The literal node to locate

locateNode

protected void locateNode(OASTNode parent,
                          AttributeNode node)
Called after an attribute is parsed to set its location. The default implementation does nothing, so nodes will have to be located en masse after the parse is complete.

Parameters:
parent - The parent of the node to locate
node - The attribute node to locate

locateNodeBegin

protected void locateNodeBegin(OASTNode node)
Called after an open tag is parsed to set the tag node's start offset. The default implementation does nothing, so nodes will have to be located en masse after the parse is complete.

Parameters:
node - The tag node to locate

locateNodeEnd

protected void locateNodeEnd(OASTNode node)
Called after a close tag is parsed to set the tag node's length. The default implementation does nothing, so nodes will have to be located en masse after the parse is complete.

Parameters:
node - The tag node to locate

locateRootNode

protected void locateRootNode(OASTNode root)
Called at the beginning of the parse to set the size and position of the root element for the parse. The default implementation does nothing, so nodes will have to be located en masse after the parse is complete.

Parameters:
root - The root node

dispose

public void dispose()
Cleans up resources used by the handler.


setDocumentLocator

public void setDocumentLocator(Locator locator)

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Throws:
SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
Throws:
SAXException

processAttributes

protected void processAttributes(OASTNode parent,
                                 Attributes attributes)
Helper method for parsing the attributes found for a begin tag. Each individual attribute in the collection is added to the OAST as an attribute node, with the begin tag node as its parent.

Parameters:
parent - The begin tag node
attributes - The collection of attributes associated with the begin tag.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Throws:
SAXException

startDocument

public void startDocument()
                   throws SAXException
Throws:
SAXException


Copyright © 2004-2005 BBN Technologies. All Rights Reserved.