Joda System API

org.joda.property.xml
Class SAXHandler

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--org.joda.property.xml.SAXHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class SAXHandler
extends org.xml.sax.helpers.DefaultHandler

SAXHandler is the event handler class for SAX events. It can be used either with or without SAXBuilder.

The handler is used by creating a new instance and passing it to the SAX event source. After the events have been sent, the getBean() method can be used to get the created bean.

Author:
Stephen Colebourne, Andy Lehane

Constructor Summary
SAXHandler()
          Create a new SAX event handler.
SAXHandler(java.lang.Class rootClass)
          Create a new SAX event handler.
SAXHandler(java.lang.Class rootClass, JodaFactory factory)
          Create a new SAX event handler.
 
Method Summary
 void characters(char[] text, int startIndex, int length)
          Handle the SAX event of text found within an element.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          Handle the SAX event of an element end tag.
 Bean getBean()
          Get the Bean read in, typically used once parsing is complete.
protected  java.lang.String getID(XMLData data)
          Get the id
protected  java.lang.String getIDREF(XMLData data)
          Get the idref
protected  java.lang.String getMapKey(XMLData data)
          Get the key into the map
 XMLMetaData getMetaData()
          Gets the metadata for XML output.
protected  boolean getNull(XMLData data)
          Get the null flag
protected  java.lang.Class getType(XMLData data)
          Get the type of the bean
 void setMetaData(XMLMetaData metaData)
          Sets the metaData for XML output.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Handle the SAX event of an element start tag.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
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

SAXHandler

public SAXHandler()
           throws java.io.IOException
Create a new SAX event handler.


SAXHandler

public SAXHandler(java.lang.Class rootClass)
           throws java.io.IOException
Create a new SAX event handler.


SAXHandler

public SAXHandler(java.lang.Class rootClass,
                  JodaFactory factory)
Create a new SAX event handler.

Method Detail

getBean

public Bean getBean()
Get the Bean read in, typically used once parsing is complete.

Returns:
the Bean

getMetaData

public XMLMetaData getMetaData()
Gets the metadata for XML output.

Returns:
the metadata

setMetaData

public void setMetaData(XMLMetaData metaData)
Sets the metaData for XML output.

Parameters:
metaData - the metaData to use

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Handle the SAX event of an element start tag.

The data provided includes all the attributes, except those 'belonging to' XML.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - namespace URI of the element, not supported
localName - the unprefixed name of the element
qName - the qualified name of the element, with the prefix
atts - SAX format attribute list
Throws:
org.xml.sax.SAXException - when an error occurs

characters

public void characters(char[] text,
                       int startIndex,
                       int length)
                throws org.xml.sax.SAXException
Handle the SAX event of text found within an element.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
text - the text found
startIndex - start index in the text array of the text
length - length of the text
Throws:
org.xml.sax.SAXException - when an error occurs

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Handle the SAX event of an element end tag. This event also occurs for empty elements.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - namespace URI of the element, not supported
localName - the unprefixed name of the element
qName - the qualified name of the element, with the prefix
Throws:
org.xml.sax.SAXException - when an error occurs

getType

protected java.lang.Class getType(XMLData data)
                           throws org.xml.sax.SAXException
Get the type of the bean

org.xml.sax.SAXException

getNull

protected boolean getNull(XMLData data)
                   throws org.xml.sax.SAXException
Get the null flag

org.xml.sax.SAXException

getID

protected java.lang.String getID(XMLData data)
                          throws org.xml.sax.SAXException
Get the id

org.xml.sax.SAXException

getIDREF

protected java.lang.String getIDREF(XMLData data)
                             throws org.xml.sax.SAXException
Get the idref

org.xml.sax.SAXException

getMapKey

protected java.lang.String getMapKey(XMLData data)
                              throws org.xml.sax.SAXException
Get the key into the map

org.xml.sax.SAXException

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.