org.apache.cocoon.stax.converter
Class SAXForStAXPipelineWrapper

java.lang.Object
  extended by org.apache.cocoon.pipeline.component.AbstractPipelineComponent
      extended by org.apache.cocoon.stax.AbstractStAXPipelineComponent
          extended by org.apache.cocoon.stax.AbstractStAXProducer
              extended by org.apache.cocoon.stax.AbstractStAXTransformer
                  extended by org.apache.cocoon.stax.converter.SAXForStAXPipelineWrapper
All Implemented Interfaces:
XMLEventConsumer, Consumer, PipelineComponent, Producer, StAXConsumer, StAXPipelineComponent, StAXProducer

public class SAXForStAXPipelineWrapper
extends AbstractStAXTransformer
implements XMLEventConsumer

This class could be seen as the default implementation to use SAX components in StAX pipelines.

If an XMLEvent is pulled from the SAXForStAXPipelineWrapper by an StAXConsumer the SAXForStAXPipelineWrapper retrieves an XMLEvent from its StAXConsumer and translate it to an SAXEvent. Each event produced during calling the SAX-component are transformed to XMLEvents and are stored internally. If the SAX-component produced at least one XMLEvent all produced XMLEvents are returned. Otherwise the next event is pulled from the StAXProducer and the process is repeated.


Constructor Summary
SAXForStAXPipelineWrapper(SAXProducer saxTransformer)
          Constructs an Wrapper around an SAXTransformer and made it available to add it to an Pipeline only containing StAX- PipelineComponents.
 
Method Summary
 void add(XMLEvent event)
          
protected  void produceEvents()
          Template method which has to produce at least one XMLEvent and should add this to the internal Queue with the #add(XMLEvent) and #addAll(Collection) methods.
 void setConsumer(Consumer consumer)
          
 
Methods inherited from class org.apache.cocoon.stax.AbstractStAXTransformer
addAllEventsToQueue, addEventToQueue, getParent, hasNext, initiatePullProcessing, isQueueEmpty, nextEvent, peek, setParent
 
Methods inherited from class org.apache.cocoon.stax.AbstractStAXProducer
getConsumer
 
Methods inherited from class org.apache.cocoon.pipeline.component.AbstractPipelineComponent
finish, setConfiguration, setup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.pipeline.component.PipelineComponent
finish, setConfiguration, setup
 

Constructor Detail

SAXForStAXPipelineWrapper

public SAXForStAXPipelineWrapper(SAXProducer saxTransformer)
Constructs an Wrapper around an SAXTransformer and made it available to add it to an Pipeline only containing StAX- PipelineComponents.

Parameters:
The - Transformer which should be wrapped. As an SAXTransformer it have to implement the SAXProducer and the SAXConsumer interface. Since no transformer interface exists at the moment at the cocoon-sax project this way is chosen. But this may be changed later.
Method Detail

setConsumer

public void setConsumer(Consumer consumer)

Specified by:
setConsumer in interface Producer
Overrides:
setConsumer in class AbstractStAXProducer
See Also:
Producer.setConsumer(Consumer)

add

public void add(XMLEvent event)
         throws XMLStreamException

Specified by:
add in interface XMLEventConsumer
Throws:
XMLStreamException
See Also:
XMLEventConsumer.add(javax.xml.stream.events.XMLEvent)

produceEvents

protected void produceEvents()
                      throws XMLStreamException
Template method which has to produce at least one XMLEvent and should add this to the internal Queue with the #add(XMLEvent) and #addAll(Collection) methods. If no XMLEvent is added by this method to the internal Queue an exception is thrown.

Specified by:
produceEvents in class AbstractStAXTransformer
Throws:
XMLStreamException - thrown if the StAXProducer.nextEvent() or the StAXProducer.peek() method, called in the AbstractStAXTransformer.produceEvents() method throw any exceptions they have to be forwarded to the end of the pipeline.
See Also:
AbstractStAXTransformer.produceEvents()


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.