gnu.xml.pipeline

Class TeeConsumer

public final class TeeConsumer extends Object implements EventConsumer, ContentHandler, DTDHandler, LexicalHandler, DeclHandler

Fans its events out to two other consumers, a "tee" filter stage in an event pipeline. Networks can be assembled with multiple output points.

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).

Version: $Date: 2001/10/24 22:50:33 $

Author: David Brownell

Constructor Summary
TeeConsumer(EventConsumer car, EventConsumer cdr)
Constructs a consumer which sends all its events to the first consumer, and then the second one.
Method Summary
voidattributeDecl(String eName, String aName, String type, String mode, String value)
voidcharacters(char[] ch, int start, int length)
voidcomment(char[] ch, int start, int length)
voidelementDecl(String name, String model)
voidendCDATA()
voidendDocument()
voidendDTD()
voidendElement(String uri, String localName, String qName)
voidendEntity(String name)
voidendPrefixMapping(String prefix)
voidexternalEntityDecl(String name, String publicId, String systemId)
ContentHandlergetContentHandler()
Returns the content handler being used.
DTDHandlergetDTDHandler()
Returns the dtd handler being used.
EventConsumergetFirst()
Returns the first pipeline to get event calls.
ObjectgetProperty(String id)
Returns the declaration or lexical handler being used.
EventConsumergetRest()
Returns the second pipeline to get event calls.
voidignorableWhitespace(char[] ch, int start, int length)
voidinternalEntityDecl(String name, String value)
voidnotationDecl(String name, String publicId, String systemId)
voidprocessingInstruction(String target, String data)
voidsetDocumentLocator(Locator locator)
voidsetErrorHandler(ErrorHandler handler)
Provides the error handler to both subsequent nodes of this filter stage.
voidskippedEntity(String name)
voidstartCDATA()
voidstartDocument()
voidstartDTD(String name, String publicId, String systemId)
voidstartElement(String uri, String localName, String qName, Attributes atts)
voidstartEntity(String name)
voidstartPrefixMapping(String prefix, String uri)
voidunparsedEntityDecl(String name, String publicId, String systemId, String notationName)

Constructor Detail

TeeConsumer

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 events cdr The second consumer to get the events

Method Detail

attributeDecl

public void attributeDecl(String eName, String aName, String type, String mode, String value)

characters

public void characters(char[] ch, int start, int length)

comment

public void comment(char[] ch, int start, int length)

elementDecl

public void elementDecl(String name, String model)

endCDATA

public void endCDATA()

endDocument

public void endDocument()

endDTD

public void endDTD()

endElement

public void endElement(String uri, String localName, String qName)

endEntity

public void endEntity(String name)

endPrefixMapping

public void endPrefixMapping(String prefix)

externalEntityDecl

public void externalEntityDecl(String name, String publicId, String systemId)

getContentHandler

public final ContentHandler getContentHandler()
Returns the content handler being used.

getDTDHandler

public final DTDHandler getDTDHandler()
Returns the dtd handler being used.

getFirst

public EventConsumer getFirst()
Returns the first pipeline to get event calls.

getProperty

public final Object getProperty(String id)
Returns the declaration or lexical handler being used.

getRest

public EventConsumer getRest()
Returns the second pipeline to get event calls.

ignorableWhitespace

public void ignorableWhitespace(char[] ch, int start, int length)

internalEntityDecl

public void internalEntityDecl(String name, String value)

notationDecl

public void notationDecl(String name, String publicId, String systemId)

processingInstruction

public void processingInstruction(String target, String data)

setDocumentLocator

public void setDocumentLocator(Locator locator)

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Provides the error handler to both subsequent nodes of this filter stage.

skippedEntity

public void skippedEntity(String name)

startCDATA

public void startCDATA()

startDocument

public void startDocument()

startDTD

public void startDTD(String name, String publicId, String systemId)

startElement

public void startElement(String uri, String localName, String qName, Attributes atts)

startEntity

public void startEntity(String name)

startPrefixMapping

public void startPrefixMapping(String prefix, String uri)

unparsedEntityDecl

public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)

Source code is under GPL (with library exception) in the JAXP project at http://www.gnu.org/software/classpathx/jaxp
This documentation was derived from that source code on 2013-01-12.