org.jfree.xml.parser

Class RootXmlReadHandler

Implemented Interfaces:
Configuration, Serializable

public abstract class RootXmlReadHandler
extends FrontendDefaultHandler

A base root SAX handler.

Field Summary

Fields inherited from class org.jfree.xml.FrontendDefaultHandler

CONTENTBASE_KEY

Constructor Summary

RootXmlReadHandler()
Creates a new root SAX handler.

Method Summary

protected void
addDefaultMappings()
protected void
addManualMapping(Class classToRead, Class handler)
Adds a mapping between a class and the handler for the class.
protected void
addMultiplexMapping(Class baseClass, String typeAttr, MultiplexMappingEntry[] mdef)
Adds a multiplex mapping.
void
characters(char[] ch, int start, int length)
Process character data.
XmlReadHandler
createHandler(Class classToRead, String tagName, Attributes atts)
Creates a SAX handler for the specified class.
void
delegate(XmlReadHandler handler, String tagName, Attributes attrs)
Delegate to another handler.
void
endElement(String uri, String localName, String qName)
Finish processing an element.
protected XmlReadHandler
getCurrentHandler()
Returns the current handler.
abstract ObjectFactory
getFactoryLoader()
Returns the object factory.
Object
getHelperObject(String key)
Returns an object from the registry.
Object
getResult()
Returns the parse result.
protected XmlReadHandler
getRootHandler()
Returns the root SAX handler.
protected Class
loadClass(String className)
Loads the given class, and ignores all exceptions which may occur during the loading.
protected XmlReadHandler
loadHandlerClass(String className)
Loads the given class, and ignores all exceptions which may occur during the loading.
void
recurse(XmlReadHandler handler, String tagName, Attributes attrs)
Start a new handler stack and delegate to another handler.
void
setHelperObject(String key, Object value)
Adds an object to the registry.
protected void
setRootHandler(XmlReadHandler handler)
Sets the root SAX handler.
void
startDocument()
Starts processing a document.
void
startElement(String uri, String localName, String qName, Attributes attributes)
Starts processing an element.
void
unwind(String tagName)
Hand control back to the previous handler.

Methods inherited from class org.jfree.xml.FrontendDefaultHandler

findPropertyKeys, getCommentHandler, getConfigProperties, getConfigProperty, getConfigProperty, getContentBase, getLocator, getResult, newInstance, setConfigProperty, setDocumentLocator

Constructor Details

RootXmlReadHandler

public RootXmlReadHandler()
Creates a new root SAX handler.

Method Details

addDefaultMappings

protected void addDefaultMappings()

addManualMapping

protected void addManualMapping(Class classToRead,
                                Class handler)
Adds a mapping between a class and the handler for the class.
Parameters:
classToRead - the class.
handler - the handler class.

addMultiplexMapping

protected void addMultiplexMapping(Class baseClass,
                                   String typeAttr,
                                   MultiplexMappingEntry[] mdef)
Adds a multiplex mapping.
Parameters:
baseClass - the base class.
typeAttr - the type attribute.
mdef - the mapping entry.

characters

public void characters(char[] ch,
                       int start,
                       int length)
            throws SAXException
Process character data.
Parameters:
ch - the character buffer.
start - the start index.
length - the length of the character data.

createHandler

public XmlReadHandler createHandler(Class classToRead,
                                    String tagName,
                                    Attributes atts)
            throws XmlReaderException
Creates a SAX handler for the specified class.
Parameters:
classToRead - the class.
tagName - the tag name.
atts - the attributes.
Returns:
a SAX handler.
Throws:
XmlReaderException - if there is a problem with the reader.

delegate

public void delegate(XmlReadHandler handler,
                     String tagName,
                     Attributes attrs)
            throws XmlReaderException,
                   SAXException
Delegate to another handler.
Parameters:
handler - the new handler.
tagName - the tag name.
attrs - the attributes.
Throws:
XmlReaderException - if there is a problem with the reader.

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
            throws SAXException
Finish processing an element.
Parameters:
uri - the URI.
localName - the local name.
qName - the qName.

getCurrentHandler

protected XmlReadHandler getCurrentHandler()
Returns the current handler.
Returns:
The current handler.

getFactoryLoader

public abstract ObjectFactory getFactoryLoader()
Returns the object factory.
Returns:
The object factory.

getHelperObject

public Object getHelperObject(String key)
Returns an object from the registry.
Parameters:
key - the key.
Returns:
The object.

getResult

public Object getResult()
            throws SAXException
Returns the parse result. This method is called at the end of the parsing process and expects the generated object.
Overrides:
getResult in interface FrontendDefaultHandler
Returns:
the object.

getRootHandler

protected XmlReadHandler getRootHandler()
Returns the root SAX handler.
Returns:
the root SAX handler.

loadClass

protected Class loadClass(String className)
            throws XmlReaderException
Loads the given class, and ignores all exceptions which may occur during the loading. If the class was invalid, null is returned instead.
Parameters:
className - the name of the class to be loaded.
Returns:
the class or null.
Throws:
XmlReaderException - if there is a reader error.

loadHandlerClass

protected XmlReadHandler loadHandlerClass(String className)
            throws XmlReaderException
Loads the given class, and ignores all exceptions which may occur during the loading. If the class was invalid, null is returned instead.
Parameters:
className - the name of the class to be loaded.
Returns:
the class or null.
Throws:
XmlReaderException - if there is a reader error.

recurse

public void recurse(XmlReadHandler handler,
                    String tagName,
                    Attributes attrs)
            throws XmlReaderException,
                   SAXException
Start a new handler stack and delegate to another handler.
Parameters:
handler - the handler.
tagName - the tag name.
attrs - the attributes.
Throws:
XmlReaderException - if there is a problem with the reader.

setHelperObject

public void setHelperObject(String key,
                            Object value)
Adds an object to the registry.
Parameters:
key - the key.
value - the object.

setRootHandler

protected void setRootHandler(XmlReadHandler handler)
Sets the root SAX handler.
Parameters:
handler - the SAX handler.

startDocument

public void startDocument()
            throws SAXException
Starts processing a document.

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
            throws SAXException
Starts processing an element.
Parameters:
uri - the URI.
localName - the local name.
qName - the qName.
attributes - the attributes.

unwind

public void unwind(String tagName)
            throws SAXException,
                   XmlReaderException
Hand control back to the previous handler.
Parameters:
tagName - the tagname.
Throws:
XmlReaderException - if there is a problem with the reader.