Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
gnu.xml.pipeline.TeeConsumer
public final class TeeConsumer
extends java.lang.Object
implements EventConsumer, ContentHandler, DTDHandler, LexicalHandler, DeclHandler
Error handling should be simple if you remember that exceptions you throw will cancel later stages in that callback's pipeline, and generally the producer will stop if it sees such an exception. You may want to protect your pipeline against such backflows, making a kind of reverse filter (or valve?) so that certain exceptions thrown by your pipeline will caught and handled before the producer sees them. Just use a "try/catch" block, rememebering that really important cleanup tasks should be in "finally" clauses.
That issue isn't unique to "tee" consumers, but tee consumers have the additional twist that exceptions thrown by the first consumer will cause the second consumer not to see the callback (except for the endDocument callback, which signals state cleanup).
Constructor Summary | |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
ContentHandler |
|
DTDHandler |
|
EventConsumer |
|
Object |
|
EventConsumer |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
public TeeConsumer(EventConsumer car, EventConsumer cdr)
Constructs a consumer which sends all its events to the first consumer, and then the second one. If the first consumer throws an exception, the second one will not see the event which caused that exception to be reported.
- Parameters:
car
- The first consumer to get the eventscdr
- The second consumer to get the events
public void attributeDecl(String eName, String aName, String type, String mode, String value) throws SAXException
- Specified by:
- attributeDecl in interface DeclHandler
public void characters(ch[] , int start, int length) throws SAXException
- Specified by:
- characters in interface ContentHandler
public void comment(ch[] , int start, int length) throws SAXException
- Specified by:
- comment in interface LexicalHandler
public void elementDecl(String name, String model) throws SAXException
- Specified by:
- elementDecl in interface DeclHandler
public void endDocument() throws SAXException
- Specified by:
- endDocument in interface ContentHandler
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
- endElement in interface ContentHandler
public void endEntity(String name) throws SAXException
- Specified by:
- endEntity in interface LexicalHandler
public void endPrefixMapping(String prefix) throws SAXException
- Specified by:
- endPrefixMapping in interface ContentHandler
public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException
- Specified by:
- externalEntityDecl in interface DeclHandler
public final ContentHandler getContentHandler()
Returns the content handler being used.
- Specified by:
- getContentHandler in interface EventConsumer
public final DTDHandler getDTDHandler()
Returns the dtd handler being used.
- Specified by:
- getDTDHandler in interface EventConsumer
public final Object getProperty(String id) throws SAXNotRecognizedException
Returns the declaration or lexical handler being used.
- Specified by:
- getProperty in interface EventConsumer
public void ignorableWhitespace(ch[] , int start, int length) throws SAXException
- Specified by:
- ignorableWhitespace in interface ContentHandler
public void internalEntityDecl(String name, String value) throws SAXException
- Specified by:
- internalEntityDecl in interface DeclHandler
public void notationDecl(String name, String publicId, String systemId) throws SAXException
- Specified by:
- notationDecl in interface DTDHandler
public void processingInstruction(String target, String data) throws SAXException
- Specified by:
- processingInstruction in interface ContentHandler
public void setDocumentLocator(Locator locator)
- Specified by:
- setDocumentLocator in interface ContentHandler
public void setErrorHandler(ErrorHandler handler)
Provides the error handler to both subsequent nodes of this filter stage.
- Specified by:
- setErrorHandler in interface EventConsumer
public void skippedEntity(String name) throws SAXException
- Specified by:
- skippedEntity in interface ContentHandler
public void startCDATA() throws SAXException
- Specified by:
- startCDATA in interface LexicalHandler
public void startDTD(String name, String publicId, String systemId) throws SAXException
- Specified by:
- startDTD in interface LexicalHandler
public void startDocument() throws SAXException
- Specified by:
- startDocument in interface ContentHandler
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
- Specified by:
- startElement in interface ContentHandler
public void startEntity(String name) throws SAXException
- Specified by:
- startEntity in interface LexicalHandler
public void startPrefixMapping(String prefix, String uri) throws SAXException
- Specified by:
- startPrefixMapping in interface ContentHandler