FreeHEP API
Version current

org.freehep.xml.util
Class SAXTraverser

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.freehep.xml.util.SAXTraverser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class SAXTraverser
extends DefaultHandler

A utility for working with SAX parsers. A heirarchy of SAXTraversers can be used to maintain state while parsing an XML file.

Version:
$Id: SAXTraverser.java,v 1.4 2002/07/20 00:43:58 tonyj Exp $
Author:
tonyj
Source Code:
SAXTraverser.java

Constructor Summary
SAXTraverser()
           
 
Method Summary
 void endElement(String namespaceURI, String localName, String qName)
           
protected  SAXTraverser handleElement(String name, Attributes attrs)
          Override this to handle the start of new sub elements Return the SAXTraverser to be used for the sub node, or this to continue using the current traverser.
protected  void handleElementAttributes(Attributes atts)
          Override to handle node attributes
protected  void handleEndElement(String name)
          Override this to handle the end of an element
protected  void handleSubElement(SAXTraverser sub)
          Override this to be notified of sub nodes of the current node
 void setReader(XMLReader reader)
          Attach an XMLReader to this traverser.
 void startElement(String namespaceURI, String localName, String qName, Attributes attrs)
           
 boolean toBoolean(String value)
          Utility routine to convert a String to a boolean
 byte toByte(String value)
          Utility routine to convert a String to a byte
 double toDouble(String value)
          Utility routine to convert a String to a double
 float toFloat(String value)
          Utility routine to convert a String to a float
 int toInt(String value)
          Utility routine to convert a String to an int
 long toLong(String value)
          Utility routine to convert a String to a long
 short toShort(String value)
          Utility routine to convert a String to a short
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXTraverser

public SAXTraverser()
Method Detail

setReader

public void setReader(XMLReader reader)
Attach an XMLReader to this traverser. Registers this SAXTraverser as the content handler for the reader.


startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes attrs)
                  throws SAXException
Throws:
SAXException

endElement

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

handleElementAttributes

protected void handleElementAttributes(Attributes atts)
                                throws SAXException
Override to handle node attributes

Throws:
SAXException

handleEndElement

protected void handleEndElement(String name)
                         throws SAXException
Override this to handle the end of an element

Throws:
SAXException

handleSubElement

protected void handleSubElement(SAXTraverser sub)
                         throws SAXException
Override this to be notified of sub nodes of the current node

Throws:
SAXException

handleElement

protected SAXTraverser handleElement(String name,
                                     Attributes attrs)
                              throws SAXException
Override this to handle the start of new sub elements Return the SAXTraverser to be used for the sub node, or this to continue using the current traverser.

Returns:
The SAXTraverser to be used as the content handler for the sub node
Throws:
SAXException

toBoolean

public boolean toBoolean(String value)
                  throws BadXMLException
Utility routine to convert a String to a boolean

Throws:
BadXMLException

toDouble

public double toDouble(String value)
                throws SAXException
Utility routine to convert a String to a double

Throws:
SAXException

toFloat

public float toFloat(String value)
              throws SAXException
Utility routine to convert a String to a float

Throws:
SAXException

toInt

public int toInt(String value)
          throws SAXException
Utility routine to convert a String to an int

Throws:
SAXException

toShort

public short toShort(String value)
              throws SAXException
Utility routine to convert a String to a short

Throws:
SAXException

toLong

public long toLong(String value)
            throws SAXException
Utility routine to convert a String to a long

Throws:
SAXException

toByte

public byte toByte(String value)
            throws SAXException
Utility routine to convert a String to a byte

Throws:
SAXException

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.