Class RootXmlReadHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.pentaho.reporting.libraries.xmlns.parser.RootXmlReadHandler
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
- Direct Known Subclasses:
MultiplexRootElementHandler
public class RootXmlReadHandler extends org.xml.sax.helpers.DefaultHandlerA base root SAX handler.- Author:
- Peter Becker, Thomas Morgner
-
-
Constructor Summary
Constructors Constructor Description RootXmlReadHandler(org.pentaho.reporting.libraries.resourceloader.ResourceManager manager, org.pentaho.reporting.libraries.resourceloader.ResourceKey source, long version)Creates a new root-handler using the given versioning information and resource-manager.RootXmlReadHandler(org.pentaho.reporting.libraries.resourceloader.ResourceManager manager, org.pentaho.reporting.libraries.resourceloader.ResourceKey source, org.pentaho.reporting.libraries.resourceloader.ResourceKey context, long version)Creates a new root-handler using the given versioning information and resource-manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Process character data.voiddelegate(XmlReadHandler handler, java.lang.String uri, java.lang.String tagName, org.xml.sax.Attributes attrs)Delegate to another handler.voidendElement(java.lang.String originalUri, java.lang.String localName, java.lang.String qName)Finish processing an element.CommentHandlergetCommentHandler()Returns the comment handler that is used to collect comments.org.pentaho.reporting.libraries.resourceloader.ResourceKeygetContext()Returns the context key.org.pentaho.reporting.libraries.resourceloader.DependencyCollectorgetDependencyCollector()Returns the current dependency collector for this parse-operation.org.xml.sax.LocatorgetDocumentLocator()Returns the current documentLocator.java.lang.ObjectgetHelperObject(java.lang.String key)Returns an object from the registry.java.lang.String[]getHelperObjectNames()Returns the array of all currently registered helper-objects.org.pentaho.reporting.libraries.base.config.DefaultConfigurationgetParserConfiguration()Returns the parser-configuration.org.pentaho.reporting.libraries.resourceloader.ResourceManagergetResourceManager()Returns the resource-manager that is used to load external resources.java.lang.ObjectgetResult()Tries to return the parse-result of the selected root-handler.org.pentaho.reporting.libraries.resourceloader.ResourceKeygetSource()Returns the source key.booleanisFirstCall()Checks, whether this is the first call to the handler.voidrecurse(XmlReadHandler handler, java.lang.String uri, java.lang.String tagName, org.xml.sax.Attributes attrs)Start a new handler stack and delegate to another handler.voidsetDocumentLocator(org.xml.sax.Locator locator)Receive an object for locating the origin of SAX document events.voidsetHelperObject(java.lang.String key, java.lang.Object value)Adds an object to the registry.voidstartDocument()Starts processing a document.voidstartElement(java.lang.String originalUri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)Starts processing an element.voidunwind(java.lang.String uri, java.lang.String tagName)Hand control back to the previous handler.
-
-
-
Constructor Detail
-
RootXmlReadHandler
public RootXmlReadHandler(org.pentaho.reporting.libraries.resourceloader.ResourceManager manager, org.pentaho.reporting.libraries.resourceloader.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(org.pentaho.reporting.libraries.resourceloader.ResourceManager manager, org.pentaho.reporting.libraries.resourceloader.ResourceKey source, org.pentaho.reporting.libraries.resourceloader.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
-
getContext
public org.pentaho.reporting.libraries.resourceloader.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.
-
getResourceManager
public org.pentaho.reporting.libraries.resourceloader.ResourceManager getResourceManager()
Returns the resource-manager that is used to load external resources.- Returns:
- the resource-manager.
-
isFirstCall
public boolean isFirstCall()
Checks, whether this is the first call to the handler.- Returns:
- true, if this is the first call, false otherwise.
-
getSource
public org.pentaho.reporting.libraries.resourceloader.ResourceKey getSource()
Returns the source key. This key points to the file or stream that is currently parsed.- Returns:
- the source key.
-
getDependencyCollector
public org.pentaho.reporting.libraries.resourceloader.DependencyCollector getDependencyCollector()
Returns the current dependency collector for this parse-operation. The Collector allows to check compound-keys for changes.- Returns:
- the dependency collector.
-
getCommentHandler
public CommentHandler getCommentHandler()
Returns the comment handler that is used to collect comments.- Returns:
- the comment handler.
-
getParserConfiguration
public org.pentaho.reporting.libraries.base.config.DefaultConfiguration getParserConfiguration()
Returns the parser-configuration. This can be use to configure the parsing process.- Returns:
- the parser's configuration.
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.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.- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler- Overrides:
setDocumentLocatorin classorg.xml.sax.helpers.DefaultHandler- Parameters:
locator- the documentLocator.
-
getDocumentLocator
public org.xml.sax.Locator getDocumentLocator()
Returns the current documentLocator.- Returns:
- the documentLocator.
-
setHelperObject
public void setHelperObject(java.lang.String key, java.lang.Object value)Adds an object to the registry.- Parameters:
key- the key.value- the object.
-
getHelperObject
public java.lang.Object getHelperObject(java.lang.String key)
Returns an object from the registry.- Parameters:
key- the key.- Returns:
- The object.
-
getHelperObjectNames
public java.lang.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.
-
recurse
public void recurse(XmlReadHandler handler, java.lang.String uri, java.lang.String tagName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
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:
org.xml.sax.SAXException- if there is a problem with the parser.
-
delegate
public void delegate(XmlReadHandler handler, java.lang.String uri, java.lang.String tagName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
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:
org.xml.sax.SAXException- if there is a problem with the parser.
-
unwind
public void unwind(java.lang.String uri, java.lang.String tagName) throws org.xml.sax.SAXExceptionHand control back to the previous handler.- Parameters:
tagName- the tagname.uri- the namespace uri of the current tag.- Throws:
org.xml.sax.SAXException- if there is a problem with the parser.
-
startDocument
public void startDocument() throws org.xml.sax.SAXExceptionStarts processing a document.- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
startDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException- not in this implementation.
-
startElement
public final void startElement(java.lang.String originalUri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXExceptionStarts processing an element.- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
originalUri- the URI.localName- the local name.qName- the qName.attributes- the attributes.- Throws:
org.xml.sax.SAXException- if there is a parsing problem.
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionProcess character data.- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Parameters:
ch- the character buffer.start- the start index.length- the length of the character data.- Throws:
org.xml.sax.SAXException- if there is a parsing error.
-
endElement
public final void endElement(java.lang.String originalUri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXExceptionFinish processing an element.- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
originalUri- the URI.localName- the local name.qName- the qName.- Throws:
org.xml.sax.SAXException- if there is a parsing error.
-
getResult
public java.lang.Object getResult() throws org.xml.sax.SAXExceptionTries to return the parse-result of the selected root-handler.- Returns:
- the parse-result.
- Throws:
org.xml.sax.SAXException- if an error occurs.
-
-