|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opennms.bb.common.utils.MultiplexContentHandler
This class is designed to allow for multiple ContentHandler object to process the same input stream. If a single stream can contain multiple documents that can be identified by the first element in the document, then this handler will choose the appropiate document and forward all calls to the selected document.
The only caveat is that several calls can occur prior to the first element and those calls will be forwarded to all handlers until the first start element is processed. For more information see the ContentHandler interface in the Xerces 1.1.3 documentation.
Inner Class Summary | |
private static class |
MultiplexContentHandler.ElementInfo
The element info tag that associates a tag name and a namespace, if any. |
Field Summary | |
private org.xml.sax.ContentHandler |
m_curDocHandler
The content handler that is processing the current document. |
private Map |
m_handlers
The map used to track ElementInfo to ContentHandler |
Constructor Summary | |
MultiplexContentHandler()
Creates a new instance of the class that can be used to multiplex between different content handlers based on the initial tag. |
Method Summary | |
void |
characters(char[] data,
int offset,
int length)
Called when character data is encountered. |
Object |
deregister(String localName)
Removes the registration for a content handler based on the top level tag for the handler. |
Object |
deregister(String localName,
String uri)
Removes the registration for of a content handler for the specific namespace and name. |
void |
endDocument()
Called when the end of the document is reached. |
void |
endElement(String uri,
String localName,
String qName)
Called when the end tag for an element is reached. |
void |
endPrefixMapping(String prefix)
Called when a prefix namespace URI ending. |
void |
ignorableWhitespace(char[] data,
int offset,
int length)
Called when ignorable whtespace characters are encountered. |
void |
processingInstruction(String target,
String data)
Called when a processing instructions are encountered. |
void |
register(String localName,
org.xml.sax.ContentHandler handler)
Registers a new content handler for the tag. |
void |
register(String localName,
String uri,
org.xml.sax.ContentHandler handler)
Registers a new content handler for the tag and namespace. |
void |
setDocumentLocator(org.xml.sax.Locator locator)
Sets the document locator in the current content handler. |
void |
skippedEntity(String name)
Receives notification of a skipped entity. |
void |
startDocument()
Called when a new document is started. |
void |
startElement(String uri,
String localName,
String qName,
org.xml.sax.Attributes attributes)
Called for each new element encountered in the document. |
void |
startPrefixMapping(String prefix,
String uri)
Called when a new namespace URI is being mapped. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private Map m_handlers
private org.xml.sax.ContentHandler m_curDocHandler
Constructor Detail |
public MultiplexContentHandler()
Method Detail |
public void register(String localName, org.xml.sax.ContentHandler handler)
localName
- The toplevel tag for the handlerhandler
- The handler for the tag.Map.put(java.lang.Object, java.lang.Object)
public void register(String localName, String uri, org.xml.sax.ContentHandler handler)
localName
- The toplevel tag for the handleruri
- The namespace of the tag.handler
- The handler for the tag.Map.put(java.lang.Object, java.lang.Object)
public Object deregister(String localName)
localName
- The toplevel tag fo the handler.Map.remove(java.lang.Object)
public Object deregister(String localName, String uri)
localName
- The toplevel tag nameuri
- The namespace of the tagMap.remove(java.lang.Object)
public void startDocument() throws org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
- Thrown if a content handler throws the exception.public void endDocument() throws org.xml.sax.SAXException
endDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
- Thrown if a no content handler
is currently defined, or the content handler throws the exception.public void startElement(String uri, String localName, String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
uri
- The namespace URI for this tag.localName
- The local, non-qualified tag that is startingqName
- The fully qualified namespace tag.attributes
- The attributes for the element.org.xml.sax.SAXException
- Thrown if a no content handler
is currently defined, the content handler throws the exception,
or there is no content handler found for the new document.public void endElement(String uri, String localName, String qName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
uri
- The namespace URI for this tag.localName
- The local, non-qualified tag that is startingqName
- The fully qualified namespace tag.org.xml.sax.SAXException
- Thrown if a no content handler
is currently defined, or the content handler throws the exception.public void startPrefixMapping(String prefix, String uri) throws org.xml.sax.SAXException
startPrefixMapping
in interface org.xml.sax.ContentHandler
prefix
- The prefix to map to the URI.uri
- The namespace URI.org.xml.sax.SAXException
- Thrown if a no content handler
is currently defined, or the content handler throws the exception.public void endPrefixMapping(String prefix) throws org.xml.sax.SAXException
endPrefixMapping
in interface org.xml.sax.ContentHandler
prefix
- The prefix that is ending.org.xml.sax.SAXException
- Thrown if a no content handler
is currently defined, or the content handler throws the exception.public void processingInstruction(String target, String data) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.ContentHandler
target
- Processing targetdata
- The processing data.org.xml.sax.SAXException
- Thrown if a no content handler
is currently defined, or the content handler throws the exception.public void skippedEntity(String name) throws org.xml.sax.SAXException
skippedEntity
in interface org.xml.sax.ContentHandler
name
- The skipped entity.org.xml.sax.SAXException
- Thrown if a no content handler
is currently defined, or the content handler throws the exception.public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
locator
- The document locator.public void ignorableWhitespace(char[] data, int offset, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in interface org.xml.sax.ContentHandler
data
- The buffer containing the data.offset
- The offset of the data in the buffer.length
- The length of data in the buffer.org.xml.sax.SAXException
- Thrown if no content handler is registered
or the content handler encounters an error.public void characters(char[] data, int offset, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
data
- The buffer containing the data.offset
- The offset of the data in the buffer.length
- The length of data in the buffer.org.xml.sax.SAXException
- Thrown if there is no content
handler registered or the content handler encounters an error.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |