Package org.jfree.xml.parser
Class RootXmlReadHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.jfree.xml.FrontendDefaultHandler
org.jfree.xml.parser.RootXmlReadHandler
- All Implemented Interfaces:
Serializable
,Cloneable
,Configuration
,ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
A base root SAX handler.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SimpleObjectFactory
Maps classes to handlers.private Stack
The current handlers.private HashMap
The object registry.private Stack
??.private XmlReadHandler
The root handler.private boolean
Fields inherited from class org.jfree.xml.FrontendDefaultHandler
CONTENTBASE_KEY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adds the default mappings.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.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.private XmlReadHandler
findHandlerForClass
(Class classToRead, Attributes atts, ArrayList history) Finds a handler for the specified class.protected XmlReadHandler
Returns the current handler.abstract ObjectFactory
Returns the object factory.getHelperObject
(String key) Returns an object from the registry.Returns ???.protected XmlReadHandler
Returns the root SAX handler.protected Class
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
Starts processing a document.void
startElement
(String uri, String localName, String qName, Attributes attributes) Starts processing an element.void
Hand control back to the previous handler.Methods inherited from class org.jfree.xml.FrontendDefaultHandler
clone, findPropertyKeys, getCommentHandler, getConfigProperties, getConfigProperty, getConfigProperty, getContentBase, getLocator, newInstance, setConfigProperty, setDocumentLocator
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
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
currentHandlers
The current handlers. -
outerScopes
??. -
rootHandler
The root handler. -
objectRegistry
The object registry. -
classToHandlerMapping
Maps classes to handlers. -
rootHandlerInitialized
private boolean rootHandlerInitialized
-
-
Constructor Details
-
RootXmlReadHandler
public RootXmlReadHandler()Creates a new root SAX handler.
-
-
Method Details
-
addDefaultMappings
protected void addDefaultMappings()Adds the default mappings. -
getFactoryLoader
Returns the object factory.- Returns:
- The object factory.
-
addManualMapping
Adds a mapping between a class and the handler for the class.- Parameters:
classToRead
- the class.handler
- the handler class.
-
addMultiplexMapping
Adds a multiplex mapping.- Parameters:
baseClass
- the base class.typeAttr
- the type attribute.mdef
- the mapping entry.
-
setHelperObject
Adds an object to the registry.- Parameters:
key
- the key.value
- the object.
-
getHelperObject
Returns an object from the registry.- Parameters:
key
- the key.- Returns:
- The object.
-
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.
-
findHandlerForClass
private XmlReadHandler findHandlerForClass(Class classToRead, Attributes atts, ArrayList history) throws XmlReaderException Finds a handler for the specified class.- Parameters:
classToRead
- the class to be read.atts
- the attributes.history
- the history.- Returns:
- A handler for the specified class.
- Throws:
XmlReaderException
- if there is a problem with the reader.
-
setRootHandler
Sets the root SAX handler.- Parameters:
handler
- the SAX handler.
-
getRootHandler
Returns the root SAX handler.- Returns:
- the root SAX handler.
-
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.SAXException
- if there is a problem with the parser.
-
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.SAXException
- if there is a problem with the parser.
-
unwind
Hand control back to the previous handler.- Parameters:
tagName
- the tagname.- Throws:
SAXException
- if there is a problem with the parser.XmlReaderException
- if there is a problem with the reader.
-
getCurrentHandler
Returns the current handler.- Returns:
- The current handler.
-
startDocument
Starts processing a document.- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
- not in this implementation.
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException Starts processing an element.- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Parameters:
uri
- the URI.localName
- the local name.qName
- the qName.attributes
- the attributes.- Throws:
SAXException
- if there is a parsing problem.
-
characters
Process character data.- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Parameters:
ch
- the character buffer.start
- the start index.length
- the length of the character data.- Throws:
SAXException
- if there is a parsing error.
-
endElement
Finish processing an element.- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Parameters:
uri
- the URI.localName
- the local name.qName
- the qName.- Throws:
SAXException
- if there is a parsing error.
-
loadHandlerClass
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.
-
loadClass
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.
-
getResult
Returns ???.- Specified by:
getResult
in classFrontendDefaultHandler
- Returns:
- ???.
- Throws:
SAXException
- ???.
-