org.pentaho.reporting.libraries.xmlns.parser

Class RootXmlReadHandler

public class RootXmlReadHandler extends DefaultHandler

A base root SAX handler.

Author: Peter Becker Thomas Morgner

Constructor Summary
RootXmlReadHandler(ResourceManager manager, ResourceKey source, long version)
Creates a new root-handler using the given versioning information and resource-manager.
RootXmlReadHandler(ResourceManager manager, ResourceKey source, ResourceKey context, long version)
Creates a new root-handler using the given versioning information and resource-manager.
Method Summary
voidcharacters(char[] ch, int start, int length)
Process character data.
voiddelegate(XmlReadHandler handler, String uri, String tagName, Attributes attrs)
Delegate to another handler.
voidendElement(String originalUri, String localName, String qName)
Finish processing an element.
CommentHandlergetCommentHandler()
Returns the comment handler that is used to collect comments.
ResourceKeygetContext()
Returns the context key.
protected XmlReadHandlergetCurrentHandler()
Returns the current handler.
DependencyCollectorgetDependencyCollector()
Returns the current dependency collector for this parse-operation.
LocatorgetDocumentLocator()
Returns the current documentLocator.
ObjectgetHelperObject(String key)
Returns an object from the registry.
String[]getHelperObjectNames()
Returns the array of all currently registered helper-objects.
DefaultConfigurationgetParserConfiguration()
Returns the parser-configuration.
ResourceManagergetResourceManager()
Returns the resource-manager that is used to load external resources.
ObjectgetResult()
Tries to return the parse-result of the selected root-handler.
protected XmlReadHandlergetRootHandler()
Returns the root SAX handler.
ResourceKeygetSource()
Returns the source key.
protected voidinstallRootHandler(XmlReadHandler handler, String uri, String localName, Attributes attributes)
Sets and configures the root handle for the given root-level element.
protected voidinterceptFirstStartElement(String uri, String localName, String qName, Attributes attributes)
A helper call that allows to override the first call to the startElememt method.
booleanisFirstCall()
Checks, whether this is the first call to the handler.
protected voidpushDefaultNamespace(String nsuri)
Updates the current default namespace.
voidrecurse(XmlReadHandler handler, String uri, String tagName, Attributes attrs)
Start a new handler stack and delegate to another handler.
voidsetDocumentLocator(Locator locator)
Receive an object for locating the origin of SAX document events.
voidsetHelperObject(String key, Object value)
Adds an object to the registry.
protected voidsetRootHandler(XmlReadHandler handler)
Sets the root SAX handler.
voidstartDocument()
Starts processing a document.
voidstartElement(String originalUri, String localName, String qName, Attributes attributes)
Starts processing an element.
voidunwind(String uri, String tagName)
Hand control back to the previous handler.
protected AttributeswrapAttributes(Attributes attributes)

Constructor Detail

RootXmlReadHandler

public RootXmlReadHandler(ResourceManager manager, ResourceKey source, long version)
Creates a new root-handler using the given versioning information and resource-manager.

Parameters: manager the resource manager that loaded this xml-file. source the source-key that idenfies from where the file was loaded. version the versioning information for the root-file.

RootXmlReadHandler

public RootXmlReadHandler(ResourceManager manager, ResourceKey source, ResourceKey context, long version)
Creates a new root-handler using the given versioning information and resource-manager.

Parameters: manager the resource manager that loaded this xml-file. source the source-key that idenfies from where the file was loaded. context the key that should be used to resolve relative paths. version the versioning information for the root-file.

Method Detail

characters

public void characters(char[] ch, int start, int length)
Process character data.

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

Throws: SAXException if there is a parsing error.

delegate

public void delegate(XmlReadHandler handler, String uri, String tagName, Attributes attrs)
Delegate to another handler.

Parameters: handler the new handler. tagName the tag name. uri the namespace uri of the current tag. attrs the attributes.

Throws: SAXException if there is a problem with the parser.

endElement

public final void endElement(String originalUri, String localName, String qName)
Finish processing an element.

Parameters: originalUri the URI. localName the local name. qName the qName.

Throws: SAXException if there is a parsing error.

getCommentHandler

public CommentHandler getCommentHandler()
Returns the comment handler that is used to collect comments.

Returns: the comment handler.

getContext

public ResourceKey getContext()
Returns the context key. This key may specity a base context for loading resources. (It behaves like the 'base-url' setting of HTML and allows to reference external resources as relative paths without being bound to the original location of the xml file.)

Returns: the context.

getCurrentHandler

protected XmlReadHandler getCurrentHandler()
Returns the current handler.

Returns: The current handler.

getDependencyCollector

public DependencyCollector getDependencyCollector()
Returns the current dependency collector for this parse-operation. The Collector allows to check compound-keys for changes.

Returns: the dependency collector.

getDocumentLocator

public Locator getDocumentLocator()
Returns the current documentLocator.

Returns: the documentLocator.

getHelperObject

public Object getHelperObject(String key)
Returns an object from the registry.

Parameters: key the key.

Returns: The object.

getHelperObjectNames

public String[] getHelperObjectNames()
Returns the array of all currently registered helper-objects. Helper objects are used as simple communication process between the various handler implementations.

Returns: the helper object names.

getParserConfiguration

public DefaultConfiguration getParserConfiguration()
Returns the parser-configuration. This can be use to configure the parsing process.

Returns: the parser's configuration.

getResourceManager

public ResourceManager getResourceManager()
Returns the resource-manager that is used to load external resources.

Returns: the resource-manager.

getResult

public Object getResult()
Tries to return the parse-result of the selected root-handler.

Returns: the parse-result.

Throws: SAXException if an error occurs.

getRootHandler

protected XmlReadHandler getRootHandler()
Returns the root SAX handler.

Returns: the root SAX handler.

getSource

public ResourceKey getSource()
Returns the source key. This key points to the file or stream that is currently parsed.

Returns: the source key.

installRootHandler

protected void installRootHandler(XmlReadHandler handler, String uri, String localName, Attributes attributes)
Sets and configures the root handle for the given root-level element.

Parameters: handler the read handler for the root element. uri the uri of the root elements namespace. localName the local tagname of the root element. attributes the attributes of the root element.

Throws: SAXException if something goes wrong.

interceptFirstStartElement

protected void interceptFirstStartElement(String uri, String localName, String qName, Attributes attributes)
A helper call that allows to override the first call to the startElememt method. This allows the implementation of an multiplexing parser, which requires the information from the root-level elements.

Parameters: uri the namespace uri of the current tag. localName the unqualified tag-name. qName the qualified tag-name. attributes the attributes of the current element.

Throws: SAXException if something goes wrong.

isFirstCall

public boolean isFirstCall()
Checks, whether this is the first call to the handler.

Returns: true, if this is the first call, false otherwise.

pushDefaultNamespace

protected final void pushDefaultNamespace(String nsuri)
Updates the current default namespace.

Parameters: nsuri the uri of the current namespace.

recurse

public void recurse(XmlReadHandler handler, String uri, String tagName, Attributes attrs)
Start a new handler stack and delegate to another handler.

Parameters: handler the handler. uri the namespace uri of the current tag. tagName the tag name. attrs the attributes.

Throws: SAXException if there is a problem with the parser.

setDocumentLocator

public void setDocumentLocator(Locator locator)
Receive an object for locating the origin of SAX document events.

The documentLocator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the documentLocator is probably not sufficient for use with a search engine.

Parameters: locator the documentLocator.

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()
Starts processing a document.

Throws: SAXException not in this implementation.

startElement

public final void startElement(String originalUri, String localName, String qName, Attributes attributes)
Starts processing an element.

Parameters: originalUri the URI. localName the local name. qName the qName. attributes the attributes.

Throws: SAXException if there is a parsing problem.

unwind

public void unwind(String uri, String tagName)
Hand control back to the previous handler.

Parameters: tagName the tagname. uri the namespace uri of the current tag.

Throws: SAXException if there is a problem with the parser.

wrapAttributes

protected Attributes wrapAttributes(Attributes attributes)