Class Parser
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.jfree.xml.FrontendDefaultHandler
-
- org.jfree.xml.Parser
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Configuration
,org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
public abstract class Parser extends FrontendDefaultHandler
The Parser handles the SAXEvents and forwards the event call to the currently active ElementDefinitionHandler. Contains methods to manage and configure the parsing process.An initial report definition handler must be set before the parser can be used.
- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONTENTBASE_KEY
A key for the content base.
-
Constructor Summary
Constructors Constructor Description Parser()
Creates a new parser.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
characters(char[] ch, int start, int length)
Receive notification of character data inside an element.void
endDocument()
Receive notification of the end of the document.void
endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
Receive notification of the end of an element.java.lang.String[]
getComments()
Returns the currently collected comments.java.lang.Object
getHelperObject(java.lang.String key)
Returns a helper object.ElementDefinitionHandler
getInitialFactory()
Returns the initial handler.abstract Parser
getInstance()
Returns a new instance of the parser.abstract java.lang.Object
getResult()
Returns the parsed result object after the parsing is complete.FrontendDefaultHandler
newInstance()
Returns a new instance ofFrontendDefaultHandler
.ElementDefinitionHandler
peekFactory()
Reads a handler off the stack without removing it.ElementDefinitionHandler
popFactory()
Pops a handler from the stack.void
pushFactory(ElementDefinitionHandler factory)
Pushes a handler onto the stack.void
setHelperObject(java.lang.String key, java.lang.Object value)
Sets a helper object.void
setInitialFactory(ElementDefinitionHandler factory)
Sets the initial handler.void
startDocument()
Receive notification of the beginning of the document.void
startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
Receive notification of the start of an element.-
Methods inherited from class org.jfree.xml.FrontendDefaultHandler
clone, findPropertyKeys, getCommentHandler, getConfigProperties, getConfigProperty, getConfigProperty, getContentBase, getLocator, setConfigProperty, setDocumentLocator
-
-
-
-
Field Detail
-
CONTENTBASE_KEY
public static final java.lang.String CONTENTBASE_KEY
A key for the content base.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Parser
public Parser()
Creates a new parser.
-
-
Method Detail
-
getComments
public java.lang.String[] getComments()
Returns the currently collected comments.- Returns:
- the comments.
-
pushFactory
public void pushFactory(ElementDefinitionHandler factory)
Pushes a handler onto the stack.- Parameters:
factory
- the handler.
-
peekFactory
public ElementDefinitionHandler peekFactory()
Reads a handler off the stack without removing it.- Returns:
- The handler.
-
popFactory
public ElementDefinitionHandler popFactory()
Pops a handler from the stack.- Returns:
- The handler.
-
endDocument
public void endDocument() throws org.xml.sax.SAXException
Receive notification of the end of the document.By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of a document (such as finalising a tree or closing an output file).
- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.endDocument()
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
Receive notification of the beginning of the document.By default, do nothing. Application writers may override this method in a subclass to take specific actions at the beginning of a document (such as allocating the root node of a tree or creating an output file).
- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.startDocument()
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
Receive notification of character data inside an element.By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).
- Specified by:
characters
in interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in classorg.xml.sax.helpers.DefaultHandler
- Parameters:
ch
- the characters.start
- the start position in the character array.length
- the number of characters to use from the character array.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.characters(char[], int, int)
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
Receive notification of the end of an element.By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
- Specified by:
endElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in classorg.xml.sax.helpers.DefaultHandler
- Parameters:
uri
- the URI.localName
- the element type name.qName
- the name.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
Receive notification of the start of an element.By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in classorg.xml.sax.helpers.DefaultHandler
- Parameters:
uri
- the URI.localName
- the element type name.qName
- the name.attributes
- the specified or defaulted attributes.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
-
setInitialFactory
public void setInitialFactory(ElementDefinitionHandler factory)
Sets the initial handler.- Parameters:
factory
- the initial handler.
-
getInitialFactory
public ElementDefinitionHandler getInitialFactory()
Returns the initial handler.- Returns:
- The initial handler.
-
setHelperObject
public void setHelperObject(java.lang.String key, java.lang.Object value)
Sets a helper object.- Parameters:
key
- the key.value
- the value.
-
getHelperObject
public java.lang.Object getHelperObject(java.lang.String key)
Returns a helper object.- Parameters:
key
- the key.- Returns:
- The object.
-
getInstance
public abstract Parser getInstance()
Returns a new instance of the parser.- Returns:
- a new instance of the parser.
-
newInstance
public final FrontendDefaultHandler newInstance()
Returns a new instance ofFrontendDefaultHandler
.- Specified by:
newInstance
in classFrontendDefaultHandler
- Returns:
- A new instance.
-
getResult
public abstract java.lang.Object getResult()
Returns the parsed result object after the parsing is complete. Calling this function during the parsing is undefined and may result in an IllegalStateException.- Specified by:
getResult
in classFrontendDefaultHandler
- Returns:
- the parsed result.
-
-