javanet.staxutils
Class XMLEventConsumerDelegate

java.lang.Object
  extended byjavanet.staxutils.XMLEventConsumerDelegate
All Implemented Interfaces:
XMLEventConsumer

public class XMLEventConsumerDelegate
extends java.lang.Object
implements XMLEventConsumer

Writes all events to a wrapped XMLEventConsumer, and provides convenience methods for creating events written to the internal consumer.

Version:
$Revision: 1.4 $
Author:
Christian Niles

Constructor Summary
XMLEventConsumerDelegate(XMLEventConsumer consumer)
           
XMLEventConsumerDelegate(XMLEventConsumer consumer, XMLEventFactory factory)
           
 
Method Summary
 void add(XMLEvent event)
           
 void addCData(java.lang.String content)
          Creates and adds a CDATA Characters event.
 void addComment(java.lang.String comment)
          Creates and adds a Comment event.
 void addDTD(java.lang.String dtd)
          Creates and adds a DTD event.
 void addEndDocument()
          Creates and adds an EndDocument event.
 void addEndElement(QName name)
          Creates and adds an EndElement event.
 void addEndElement(QName name, java.util.Iterator namespaces)
          Creates and adds an EndElement event.
 void addEndElement(java.lang.String localName)
          Creates and adds an EndElement event.
 void addEndElement(java.lang.String localName, java.util.Iterator namespaces)
          Creates and adds an EndElement event.
 void addEndElement(java.lang.String ns, java.lang.String localName)
          Creates and adds an EndElement event.
 void addEndElement(java.lang.String ns, java.lang.String localName, java.util.Iterator namespaces)
          Creates and adds an EndElement event.
 void addIgnorableSpace(java.lang.String content)
          Creates and adds an ignorable space Characters event.
 void addSpace(java.lang.String content)
          Creates and adds a whitespace Characters event.
 void addStartDocument()
          Creates and adds a StartDocument event.
 void addStartDocument(java.lang.String encoding)
          Creates and adds a StartDocument event.
 void addStartDocument(java.lang.String encoding, java.lang.String version)
          Creates and adds a StartDocument event.
 void addStartDocument(java.lang.String encoding, java.lang.String version, boolean standalone)
          Creates and adds a StartDocument event.
 void addStartElement(QName name, java.util.Iterator attributes, java.util.Iterator namespaces, NamespaceContext context)
          Creates and adds a StartElement event.
 void addStartElement(QName name, NamespaceContext context)
          Creates and adds a StartElement event.
 void addStartElement(java.lang.String localName, java.util.Iterator attributes, java.util.Iterator namespaces, NamespaceContext context)
          Creates and adds a StartElement event.
 void addStartElement(java.lang.String localName, NamespaceContext context)
          Creates and adds a StartElement event.
 void addStartElement(java.lang.String ns, java.lang.String localName, java.util.Iterator attributes, java.util.Iterator namespaces, NamespaceContext context)
          Creates and adds a StartElement event.
 void addStartElement(java.lang.String ns, java.lang.String localName, NamespaceContext context)
          Creates and adds a StartElement event.
 void addText(java.lang.String content)
          Creates and adds a Characters event.
 void addTextElement(QName name, boolean text, NamespaceContext context)
          Adds a boolean text element with no attributes or namespace declarations.
 void addTextElement(QName name, double text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(QName name, float text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(QName name, int text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(QName name, long text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(QName name, java.lang.Number text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(QName name, java.lang.String text, NamespaceContext context)
          Adds a simple text element with no attributes or namespace declarations.
 void addTextElement(java.lang.String name, boolean text, NamespaceContext context)
          Adds a boolean text element with no attributes or namespace declarations.
 void addTextElement(java.lang.String name, double text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(java.lang.String name, float text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(java.lang.String name, int text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(java.lang.String name, long text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(java.lang.String name, java.lang.Number text, NamespaceContext context)
          Adds a text element with no attributes or namespace declarations.
 void addTextElement(java.lang.String name, java.lang.String text, NamespaceContext context)
          Adds a simple text element with no attributes or namespace declarations.
 XMLEventConsumer getConsumer()
          Returns a reference to the underlying XMLEventConsumer to which events are added.
 XMLEventFactory getEventFactory()
          Returns a reference to the XMLEventFactory used to construct events.
 void setConsumer(XMLEventConsumer consumer)
          Sets the underlying XMLEventConsumer to which events are added.
 void setEventFactory(XMLEventFactory factory)
          Sets the XMLEventFactory used to construct events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLEventConsumerDelegate

public XMLEventConsumerDelegate(XMLEventConsumer consumer)

XMLEventConsumerDelegate

public XMLEventConsumerDelegate(XMLEventConsumer consumer,
                                XMLEventFactory factory)
Method Detail

getConsumer

public XMLEventConsumer getConsumer()
Returns a reference to the underlying XMLEventConsumer to which events are added.

Returns:
The underlying XMLEventConsumer to which events are added.

setConsumer

public void setConsumer(XMLEventConsumer consumer)
Sets the underlying XMLEventConsumer to which events are added.

Parameters:
consumer - The new XMLEventConsumer.

getEventFactory

public XMLEventFactory getEventFactory()
Returns a reference to the XMLEventFactory used to construct events.

Returns:
The XMLEventFactory used to construct events.

setEventFactory

public void setEventFactory(XMLEventFactory factory)
Sets the XMLEventFactory used to construct events.

Parameters:
factory - The new XMLEventFactory.

add

public void add(XMLEvent event)
         throws XMLStreamException
Specified by:
add in interface XMLEventConsumer
Throws:
XMLStreamException

addDTD

public void addDTD(java.lang.String dtd)
            throws XMLStreamException
Creates and adds a DTD event.

Parameters:
dtd - The DTD content, as per XMLEventFactory.createDTD(String).
Throws:
XMLStreamException - If an error occurs adding the event.

addCData

public void addCData(java.lang.String content)
              throws XMLStreamException
Creates and adds a CDATA Characters event.

Parameters:
content - The CDATA content, as per XMLEventFactory.createCData(String).
Throws:
XMLStreamException - If an error occurs adding the event.

addText

public void addText(java.lang.String content)
             throws XMLStreamException
Creates and adds a Characters event.

Parameters:
content - The text content, as per XMLEventFactory.createCharacters(String).
Throws:
XMLStreamException - If an error occurs adding the event.

addIgnorableSpace

public void addIgnorableSpace(java.lang.String content)
                       throws XMLStreamException
Creates and adds an ignorable space Characters event.

Parameters:
content - The ignorable whitespace, as per XMLEventFactory.createIgnorableSpace(String).
Throws:
XMLStreamException - If an error occurs adding the event.

addSpace

public void addSpace(java.lang.String content)
              throws XMLStreamException
Creates and adds a whitespace Characters event.

Parameters:
content - The whitespace, as per XMLEventFactory.createIgnorableSpace(String).
Throws:
XMLStreamException - If an error occurs adding the event.

addComment

public void addComment(java.lang.String comment)
                throws XMLStreamException
Creates and adds a Comment event.

Parameters:
comment - The comment text, as per XMLEventFactory.createComment(String).
Throws:
XMLStreamException - If an error occurs adding the event.

addStartDocument

public void addStartDocument()
                      throws XMLStreamException
Creates and adds a StartDocument event.

Throws:
XMLStreamException - If an error occurs adding the event.
See Also:
XMLEventFactory.createStartDocument()

addStartDocument

public void addStartDocument(java.lang.String encoding)
                      throws XMLStreamException
Creates and adds a StartDocument event.

Parameters:
encoding - The encoding to specify in the xml declaration.
Throws:
XMLStreamException - If an error occurs adding the event.
See Also:
XMLEventFactory.createStartDocument(String)

addStartDocument

public void addStartDocument(java.lang.String encoding,
                             java.lang.String version)
                      throws XMLStreamException
Creates and adds a StartDocument event.

Parameters:
encoding - The encoding to include in the xml declaration.
version - The XML version to include in the xml declaration.
Throws:
XMLStreamException - If an error occurs adding the event.
See Also:
XMLEventFactory.createStartDocument(String, String)

addStartDocument

public void addStartDocument(java.lang.String encoding,
                             java.lang.String version,
                             boolean standalone)
                      throws XMLStreamException
Creates and adds a StartDocument event.

Parameters:
encoding - The encoding to include in the xml declaration.
version - The XML version to include in the xml declaration.
standalone - The standalone value to include in the xml declaration.
Throws:
XMLStreamException - If an error occurs adding the event.
See Also:
XMLEventFactory.createStartDocument(String, String, boolean)

addEndDocument

public void addEndDocument()
                    throws XMLStreamException
Creates and adds an EndDocument event.

Throws:
XMLStreamException - If an error occurs adding the event.
See Also:
XMLEventFactory.createEndDocument()

addStartElement

public void addStartElement(java.lang.String localName,
                            NamespaceContext context)
                     throws XMLStreamException
Creates and adds a StartElement event.

Parameters:
localName - The local name of the element.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding the event.

addStartElement

public void addStartElement(java.lang.String localName,
                            java.util.Iterator attributes,
                            java.util.Iterator namespaces,
                            NamespaceContext context)
                     throws XMLStreamException
Creates and adds a StartElement event.

Parameters:
localName - The local name of the element.
attributes - An Iterator over the element's attributes.
namespaces - An Iterator over the element's namespaces.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding the event.

addStartElement

public void addStartElement(java.lang.String ns,
                            java.lang.String localName,
                            NamespaceContext context)
                     throws XMLStreamException
Creates and adds a StartElement event.

Parameters:
ns - The element's namespace URI.
localName - The local name of the element.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding the event.

addStartElement

public void addStartElement(java.lang.String ns,
                            java.lang.String localName,
                            java.util.Iterator attributes,
                            java.util.Iterator namespaces,
                            NamespaceContext context)
                     throws XMLStreamException
Creates and adds a StartElement event.

Parameters:
ns - The element's namespace URI.
localName - The local name of the element.
attributes - An Iterator over the element's attributes.
namespaces - An Iterator over the element's namespaces.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding the event.

addStartElement

public void addStartElement(QName name,
                            NamespaceContext context)
                     throws XMLStreamException
Creates and adds a StartElement event.

Parameters:
name - The qualified element name.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding the event.

addStartElement

public void addStartElement(QName name,
                            java.util.Iterator attributes,
                            java.util.Iterator namespaces,
                            NamespaceContext context)
                     throws XMLStreamException
Creates and adds a StartElement event.

Parameters:
name - The qualified element name.
attributes - An Iterator over the element's attributes.
namespaces - An Iterator over the element's namespaces.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding the event.

addEndElement

public void addEndElement(java.lang.String localName)
                   throws XMLStreamException
Creates and adds an EndElement event.

Parameters:
localName - The unqualified element name.
Throws:
XMLStreamException - If an error occurs adding the event.

addEndElement

public void addEndElement(java.lang.String localName,
                          java.util.Iterator namespaces)
                   throws XMLStreamException
Creates and adds an EndElement event.

Parameters:
localName - The unqualified element name.
namespaces - An Iterator over the element's namespaces that are going out of scope.
Throws:
XMLStreamException - If an error occurs adding the event.

addEndElement

public void addEndElement(java.lang.String ns,
                          java.lang.String localName)
                   throws XMLStreamException
Creates and adds an EndElement event.

Parameters:
ns - The element namespace.
localName - The element name.
Throws:
XMLStreamException - If an error occurs adding the event.

addEndElement

public void addEndElement(java.lang.String ns,
                          java.lang.String localName,
                          java.util.Iterator namespaces)
                   throws XMLStreamException
Creates and adds an EndElement event.

Parameters:
ns - The element namespace.
localName - The element name.
namespaces - An Iterator over the element's namespaces that are going out of scope.
Throws:
XMLStreamException - If an error occurs adding the event.

addEndElement

public void addEndElement(QName name)
                   throws XMLStreamException
Creates and adds an EndElement event.

Parameters:
name - The element name.
Throws:
XMLStreamException - If an error occurs adding the event.
See Also:
XMLEventFactory.createEndElement(QName, Iterator)

addEndElement

public void addEndElement(QName name,
                          java.util.Iterator namespaces)
                   throws XMLStreamException
Creates and adds an EndElement event.

Parameters:
name - The element name.
namespaces - An Iterator over the element's namespaces that are going out of scope.
Throws:
XMLStreamException - If an error occurs adding the event.
See Also:
XMLEventFactory.createEndElement(QName, Iterator)

addTextElement

public void addTextElement(java.lang.String name,
                           java.lang.String text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a simple text element with no attributes or namespace declarations.

Parameters:
name - The unqualified element name.
text - The text content, which may be null
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(QName name,
                           java.lang.String text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a simple text element with no attributes or namespace declarations.

Parameters:
name - The element name.
text - The text content, which may be null
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(java.lang.String name,
                           boolean text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a boolean text element with no attributes or namespace declarations.

Parameters:
name - The unqualified element name.
text - The boolean content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(QName name,
                           boolean text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a boolean text element with no attributes or namespace declarations.

Parameters:
name - The element name.
text - The boolean content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(java.lang.String name,
                           int text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The unqualified element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(QName name,
                           int text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(java.lang.String name,
                           long text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The unqualified element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(QName name,
                           long text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(java.lang.String name,
                           float text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The unqualified element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(QName name,
                           float text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(java.lang.String name,
                           double text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The unqualified element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(QName name,
                           double text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(java.lang.String name,
                           java.lang.Number text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The unqualified element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.

addTextElement

public void addTextElement(QName name,
                           java.lang.Number text,
                           NamespaceContext context)
                    throws XMLStreamException
Adds a text element with no attributes or namespace declarations.

Parameters:
name - The element name.
text - The element content.
context - The element's NamespaceContext, or null.
Throws:
XMLStreamException - If an error occurs adding an event.