public class DelegatingHandler extends SimpleElementHandler
DelegatingHandler is a SAX filter that routes events
to embedded handlers based on their element embedding. Although
delegating handler can be embedded inside one another for recursive
embedding, it is more efficient to use instances of DelegateHandler below the top level. This allows what would
otherwise be recursion on the execution stack to be represented
internally to this class. Directly embedding delegating handlers
may lead to stack overflow.
Together with delegate handlers, delegating handlers implement some of the same functionality as the Apache Commons Digester. The difference is that there are no XPath specifications in LingPipe's delegating handler and all delegation is handled programatically in one step, not by pattern matching as in XPath. The result is that LingPipe's handlers will be much more efficient than the Digester's in situations where their functionality is adequate.
CDATA_ATTS_TYPE, EMPTY_ATTS, NO_OP_DEFAULT_HANDLER| Constructor and Description |
|---|
DelegatingHandler()
Construct a delegating handler with delegation depth 512.
|
DelegatingHandler(int maxDelegationDepth)
Construct a delegating handler with up to the specified maximum
delegation depth.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Call delegated or ignored.
|
void |
endElement(String namespaceURI,
String localName,
String qName)
Call is delegated to the delegate and may trigger a finish
delegate callback.
|
void |
endPrefixMapping(String prefix)
Call delegated.
|
void |
error(SAXParseException exception)
Call delegated.
|
void |
fatalError(SAXParseException exception)
Call delegated.
|
void |
finishDelegate(String qName,
org.xml.sax.helpers.DefaultHandler handler)
This method will be called whenever the close tag for the
specified element is found.
|
org.xml.sax.helpers.DefaultHandler |
getDelegate(String qName)
Returns the delegate for the specified qualified element name.
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Call ignored.
|
void |
notationDecl(String name,
String publicId,
String systemId)
Call delegated.
|
void |
processingInstruction(String target,
String data)
Call delegated.
|
InputSource |
resolveEntity(String publicId,
String systemId)
Call delegated.
|
void |
setDelegate(String qName,
org.xml.sax.helpers.DefaultHandler handler)
Set the specified handler to handle events contains in the the
specified element.
|
void |
setDocumentLocator(Locator locator)
Call delegated.
|
void |
skippedEntity(String name)
Call delegated.
|
void |
startDocument()
Sets this handler to start a new document by resetting
any internal state.
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
Call delegated.
|
void |
startPrefixMapping(String prefix,
String uri)
Call delegated.
|
void |
unparsedEntityDecl(String name,
String publicId,
String systemId,
String notationName)
Call delegated.
|
void |
warning(SAXParseException exception)
Call delegated.
|
addSimpleAttribute, characters, characters, characters, characters, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, endSimpleElement, endSimpleElement, startEndSimpleElement, startEndSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElementendDocumentpublic DelegatingHandler(int maxDelegationDepth)
maxDelegationDepth - Maximum delegation depth.public DelegatingHandler()
public void setDelegate(String qName, org.xml.sax.helpers.DefaultHandler handler)
DelegateHandler, it should be constructed to
contain this delegating handler to ensure cooperation on
delegation. Setting the delegate handler to null
will remove any existing delegation for the specified element.
Note that the element is specified by means of its qualified name, not its base name or URL plus base name.
qName - Qualified name of element.handler - Handler to accept delegated events.IllegalArgumentException - If the handler is a delegate
handler that is tied to a different delegating handler.public void finishDelegate(String qName, org.xml.sax.helpers.DefaultHandler handler)
This is a default no-operation implementation. Subclasses may override it to handle the end of delegates.
qName - Qualified name of element that finished.handler - Handler that was delegated to handle the
specified element.public org.xml.sax.helpers.DefaultHandler getDelegate(String qName)
null.qName - Qualified name of delegated element.public void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerSAXException - if the contained hanlder throws a SAX
exception.public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - The URI identifying the name space, or
null if there isn't one.localName - Local name of element.qName - Qualified name of element, which is prefixed with
the name space URI and a colon if it is non-null, and is equal
to local name if there is no name space specified.atts - Attributes for this element.SAXException - if the contained hanlder throws a SAX
exception.public void endElement(String namespaceURI, String localName, String qName) throws SAXException
endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - The URI identifying the name space, or
null if there isn't one.localName - Local name of element.qName - Qualified name of element, which is prefixed with
the name space URI and a colon if it is non-null, and is equal
to local name if there is no name space specified.SAXException - if the contained handler throws a SAX
exception.public void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerch - Character array containing characters to handle.start - Index of first character to handle.length - Number of characters to handle.SAXException - if the contained hanlder throws a SAX
exception.public void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class org.xml.sax.helpers.DefaultHandlerch - Character array containing characters to handle.start - Index of first character to handle.length - Number of characters to handle.SAXException - if the contained hanlder throws a SAX
exception.public void processingInstruction(String target, String data) throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class org.xml.sax.helpers.DefaultHandlertarget - The processing instruction target.data - The processing instruction data, or
null if none is supplied.SAXException - if the contained hanlder throws a SAX
exception.public void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class org.xml.sax.helpers.DefaultHandlerprefix - The namespace prefix being declared.uri - The namespace URI mapped to the prefix.SAXException - if the contained hanlder throws a SAX
exception.public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping in interface ContentHandlerendPrefixMapping in class org.xml.sax.helpers.DefaultHandlerprefix - The namespace prefix being declared.SAXException - if the contained hanlder throws a SAX
exception.public void skippedEntity(String name) throws SAXException
skippedEntity in interface ContentHandlerskippedEntity in class org.xml.sax.helpers.DefaultHandlername - The name of the skipped entity.SAXException - if the contained hanlder throws a SAX
exception.public void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlersetDocumentLocator in class org.xml.sax.helpers.DefaultHandlerlocator - A locator for all SAX document events.SAXException - if the contained hanlder throws a SAX
exception.public InputSource resolveEntity(String publicId, String systemId) throws SAXException
resolveEntity in interface EntityResolverresolveEntity in class org.xml.sax.helpers.DefaultHandlerpublicId - The public identifier, or null if
none is available.systemId - The system identifier provided in the XML
document.SAXException - if the contained hanlder throws a SAX
exception.public void error(SAXParseException exception) throws SAXException
error in interface ErrorHandlererror in class org.xml.sax.helpers.DefaultHandlerexception - The error information, encoded as an exception.SAXException - if the contained hanlder throws a SAX
exception.public void fatalError(SAXParseException exception) throws SAXException
fatalError in interface ErrorHandlerfatalError in class org.xml.sax.helpers.DefaultHandlerexception - The fatal error information, encoded as an
exception.SAXException - if the contained hanlder throws a SAX
exception.public void warning(SAXParseException exception) throws SAXException
warning in interface ErrorHandlerwarning in class org.xml.sax.helpers.DefaultHandlerexception - The warning information, encoded as an exception.SAXException - if the contained hanlder throws a SAX
exception.public void notationDecl(String name, String publicId, String systemId) throws SAXException
notationDecl in interface DTDHandlernotationDecl in class org.xml.sax.helpers.DefaultHandlername - The notation name.publicId - The notation public identifier, or
null if none is available.systemId - The notation system identifier.SAXException - if the contained hanlder throws a SAX
exception.public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException
unparsedEntityDecl in interface DTDHandlerunparsedEntityDecl in class org.xml.sax.helpers.DefaultHandlername - The entity name.publicId - The entity public identifier, or
null if none is available.systemId - The entity system identifier.notationName - The name of the associated notation.SAXException - if the contained hanlder throws a SAX
exception.Copyright © 2016 Alias-i, Inc.. All rights reserved.