com.bbn.swede.core.dom
Class OASTStringHandler

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

public class OASTStringHandler
extends OASTHandler

A customized OAST handler for String-based SAX parses. Because random access against strings in memory is efficient, this handler locates nodes as they are parsed, rather than relying on the caller to locate all nodes en masse after the fact.

Author:
jlerner

Field Summary
protected  boolean _bDummy
          A value of true indicates that the parser was given a dummy root tag.
protected  String _sText
          The text being parsed by the SAX parser.
 
Fields inherited from class com.bbn.swede.core.dom.OASTHandler
_nodeCurrent, _root
 
Constructor Summary
OASTStringHandler(OASTNode root, String sText)
          Creates an OAST string handler.
OASTStringHandler(OASTNode root, String sText, boolean bDummy)
          Creates an OAST string handler that optionally ignores the first tag found by the parser.
 
Method Summary
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.
 
Methods inherited from class com.bbn.swede.core.dom.OASTHandler
characters, dispose, endElement, processAttributes, setDocumentLocator, startDocument, startElement
 
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

_sText

protected String _sText
The text being parsed by the SAX parser. This should be the full text handed to the parser, including any shennanigans required to fool it into doing a partial parse.


_bDummy

protected boolean _bDummy
A value of true indicates that the parser was given a dummy root tag.

Constructor Detail

OASTStringHandler

public OASTStringHandler(OASTNode root,
                         String sText)
Creates an OAST string handler. The text provided at construction should be the same node text handed to the parser. The location code assumes there is no dummy node to ignore.

Parameters:
root - The node to serve as the root for the string parse.
sText - The node text being parsed.

OASTStringHandler

public OASTStringHandler(OASTNode root,
                         String sText,
                         boolean bDummy)
Creates an OAST string handler that optionally ignores the first tag found by the parser. This constructor must be used when the text given to SAX had <a></a> wrapped around it to ensure the presence of a root tag. In this case, the text provided to the handler should be the original text being parsed, not including the dummy root tag.

Parameters:
root - The node to serve as the root for the string parse.
sText - The node text being parsed.
bDummy - true if the parser was given a dummy root tag, false if not. A true value has the effect of making the handler ignore the first tag it is told to handle.
Method Detail

locateNode

protected void locateNode(OASTNode parent,
                          Literal lit)
Description copied from class: OASTHandler
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.

Overrides:
locateNode in class OASTHandler
Parameters:
parent - The parent of the node to locate
lit - The literal node to locate

locateNode

protected void locateNode(OASTNode parent,
                          AttributeNode node)
Description copied from class: OASTHandler
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.

Overrides:
locateNode in class OASTHandler
Parameters:
parent - The parent of the node to locate
node - The attribute node to locate

locateNodeBegin

protected void locateNodeBegin(OASTNode node)
Description copied from class: OASTHandler
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.

Overrides:
locateNodeBegin in class OASTHandler
Parameters:
node - The tag node to locate

locateNodeEnd

protected void locateNodeEnd(OASTNode node)
Description copied from class: OASTHandler
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.

Overrides:
locateNodeEnd in class OASTHandler
Parameters:
node - The tag node to locate

locateRootNode

protected void locateRootNode(OASTNode root)
Description copied from class: OASTHandler
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.

Overrides:
locateRootNode in class OASTHandler
Parameters:
root - The root node


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