Class AbstractXmlReadHandler
java.lang.Object
org.pentaho.reporting.libraries.xmlns.parser.AbstractXmlReadHandler
- All Implemented Interfaces:
XmlReadHandler
- Direct Known Subclasses:
IgnoreAnyChildReadHandler,PropertiesReadHandler,StringReadHandler
A base class for implementing an
XmlReadHandler. This class
takes care of all the delegation management.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) This method is called to process the character data between element tags.protected MapCreates a working copy of the current parse state.protected voidDone parsing.final 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.Returns the locator as provided by the XML parser.Returns the root handler for the parsing.Returns the tag name.getUri()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 typetargetClass.protected ObjectperformExternalParsing(String file, Class targetClass, Map map) Parses an external file using LibLoader and returns the parsed result as an object of typetargetClass.final voidstartElement(String uri, String tagName, Attributes attrs) This method is called at the start of an element.protected voidstartParsing(Attributes attrs) Starts parsing.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler
getObject
-
Constructor Details
-
AbstractXmlReadHandler
protected AbstractXmlReadHandler()Creates a new handler.
-
-
Method Details
-
init
Initialises the handler.- Specified by:
initin interfaceXmlReadHandler- Parameters:
rootHandler- the root handler.tagName- the tag name.uri- the namespace uri.- Throws:
SAXException- if an parser-error occured.
-
startElement
This method is called at the start of an element.- Specified by:
startElementin interfaceXmlReadHandler- Parameters:
tagName- the tag name.attrs- the attributes.uri- the namespace uri.- Throws:
SAXException- if there is a parsing error.
-
characters
This method is called to process the character data between element tags.- Specified by:
charactersin interfaceXmlReadHandler- Parameters:
ch- the character buffer.start- the start index.length- the length.- Throws:
SAXException- if there is a parsing error.
-
endElement
This method is called at the end of an element.- Specified by:
endElementin interfaceXmlReadHandler- Parameters:
tagName- the tag name.uri- the namespace uri.- Throws:
SAXException- if there is a parsing error.
-
startParsing
Starts parsing.- Parameters:
attrs- the attributes.- Throws:
SAXException- if there is a parsing error.
-
doneParsing
Done parsing.- Throws:
SAXException- if there is a parsing error.
-
isSameNamespace
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.
-
getHandlerForChild
protected XmlReadHandler getHandlerForChild(String uri, String tagName, Attributes atts) throws SAXException 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.
-
getTagName
Returns the tag name.- Returns:
- the tag name.
-
getUri
Returns the uri of the element. The URI identifies the namespace.- Returns:
- the element's URI.
-
getRootHandler
Returns the root handler for the parsing.- Returns:
- the root handler.
-
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.
-
performExternalParsing
protected Object performExternalParsing(String file, Class targetClass) throws ParseException, org.pentaho.reporting.libraries.resourceloader.ResourceLoadingException Parses an external file using LibLoader and returns the parsed result as an object of typetargetClass. 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.org.pentaho.reporting.libraries.resourceloader.ResourceLoadingException- if there was an IO error loading the resource.- See Also:
-
performExternalParsing
protected Object performExternalParsing(String file, Class targetClass, Map map) throws ParseException, org.pentaho.reporting.libraries.resourceloader.ResourceLoadingException Parses an external file using LibLoader and returns the parsed result as an object of typetargetClass. 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.org.pentaho.reporting.libraries.resourceloader.ResourceLoadingException- if there was an IO error loading the resource.- See Also:
-
deriveParseParameters
Creates a working copy of the current parse state.- Returns:
- the derived parse-parameters.
-