org.pentaho.reporting.libraries.xmlns.parser

Class AbstractXmlReadHandler

public abstract class AbstractXmlReadHandler extends Object implements XmlReadHandler

A base class for implementing an XmlReadHandler. This class takes care of all the delegation management.
Constructor Summary
protected AbstractXmlReadHandler()
Creates a new handler.
Method Summary
voidcharacters(char[] ch, int start, int length)
This method is called to process the character data between element tags.
protected MapderiveParseParameters()
Creates a working copy of the current parse state.
protected voiddoneParsing()
Done parsing.
voidendElement(String uri, String tagName)
This method is called at the end of an element.
protected XmlReadHandlergetHandlerForChild(String uri, String tagName, Attributes atts)
Returns the handler for a child element.
LocatorgetLocator()
Returns the locator as provided by the XML parser.
RootXmlReadHandlergetRootHandler()
Returns the root handler for the parsing.
StringgetTagName()
Returns the tag name.
StringgetUri()
Returns the uri of the element.
voidinit(RootXmlReadHandler rootHandler, String uri, String tagName)
Initialises the handler.
protected booleanisSameNamespace(String namespaceURI)
Checks whether the given url denotes the same namespace as the element's namespace.
protected ObjectperformExternalParsing(String file, Class targetClass)
Parses an external file using LibLoader and returns the parsed result as an object of type targetClass.
protected ObjectperformExternalParsing(String file, Class targetClass, Map map)
Parses an external file using LibLoader and returns the parsed result as an object of type targetClass.
voidstartElement(String uri, String tagName, Attributes attrs)
This method is called at the start of an element.
protected voidstartParsing(Attributes attrs)
Starts parsing.

Constructor Detail

AbstractXmlReadHandler

protected AbstractXmlReadHandler()
Creates a new handler.

Method Detail

characters

public void characters(char[] ch, int start, int length)
This method is called to process the character data between element tags.

Parameters: ch the character buffer. start the start index. length the length.

Throws: SAXException if there is a parsing error.

deriveParseParameters

protected Map deriveParseParameters()
Creates a working copy of the current parse state.

Returns: the derived parse-parameters.

UNKNOWN: ObjectAllocationInLoop as this is a cloning operation.

doneParsing

protected void doneParsing()
Done parsing.

Throws: SAXException if there is a parsing error.

endElement

public final void endElement(String uri, String tagName)
This method is called at the end of an element.

Parameters: tagName the tag name.

Throws: SAXException if there is a parsing error.

getHandlerForChild

protected XmlReadHandler getHandlerForChild(String uri, String tagName, Attributes atts)
Returns the handler for a child element.

Parameters: uri the URI of the namespace of the current element. tagName the tag name. atts the attributes.

Returns: the handler or null, if the tagname is invalid.

Throws: SAXException if there is a parsing error.

getLocator

public Locator getLocator()
Returns the locator as provided by the XML parser. This method may return null if the XML parser has no locator support.

Returns: the locator or null.

getRootHandler

public RootXmlReadHandler getRootHandler()
Returns the root handler for the parsing.

Returns: the root handler.

getTagName

public String getTagName()
Returns the tag name.

Returns: the tag name.

getUri

public String getUri()
Returns the uri of the element. The URI identifies the namespace.

Returns: the element's URI.

init

public void init(RootXmlReadHandler rootHandler, String uri, String tagName)
Initialises the handler.

Parameters: rootHandler the root handler. tagName the tag name.

isSameNamespace

protected boolean isSameNamespace(String namespaceURI)
Checks whether the given url denotes the same namespace as the element's namespace.

Parameters: namespaceURI the namespace that should be tested.

Returns: true, if the namespace matches the element's namespace,false otherwise.

performExternalParsing

protected Object performExternalParsing(String file, Class targetClass)
Parses an external file using LibLoader and returns the parsed result as an object of type targetClass. The file is given as relative pathname (relative to the current source file). The current helper-methods are used as parse-parameters for the external parsing.

Parameters: file the file to be parsed. targetClass the target type of the parse operation.

Returns: the result, never null.

Throws: ParseException if parsing the result failed for some reason. ResourceLoadingException if there was an IO error loading the resource.

See Also: deriveParseParameters AbstractXmlReadHandler

performExternalParsing

protected Object performExternalParsing(String file, Class targetClass, Map map)
Parses an external file using LibLoader and returns the parsed result as an object of type targetClass. The file is given as relative pathname (relative to the current source file). The current helper-methods are used as parse-parameters for the external parsing.

Parameters: file the file to be parsed. targetClass the target type of the parse operation. map the map of parse parameters.

Returns: the result, never null.

Throws: ParseException if parsing the result failed for some reason. ResourceLoadingException if there was an IO error loading the resource.

See Also: deriveParseParameters

startElement

public final void startElement(String uri, String tagName, Attributes attrs)
This method is called at the start of an element.

Parameters: tagName the tag name. attrs the attributes.

Throws: SAXException if there is a parsing error.

startParsing

protected void startParsing(Attributes attrs)
Starts parsing.

Parameters: attrs the attributes.

Throws: SAXException if there is a parsing error.