Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.dom4j.io
Class STAXEventWriter

    java.lang.Object
      org.dom4j.io.STAXEventWriter

public class STAXEventWriter
extends Object

Writes DOM4J `Node`s to a StAX event stream. In addition the `createXXX` methods are provided to directly create STAX events from DOM4J nodes.

Author:
  Christian Niles

Constructor Summary
`STAXEventWriter()`
`STAXEventWriter(File file)` Constructs a `STAXEventWriter` that writes events to the provided file.
`STAXEventWriter(OutputStream stream)` Constructs a `STAXEventWriter` that writes events to the provided stream.
`STAXEventWriter(Writer writer)` Constructs a `STAXEventWriter` that writes events to the provided character stream.
`STAXEventWriter(javax.xml.stream.util.XMLEventConsumer consumer)` Constructs a `STAXEventWriter` that writes events to the provided event stream.

Method Summary
`javax.xml.stream.events.Attribute` | `createAttribute(Attribute attr)` Constructs a STAX `Attribute`event from a DOM4J `Attribute`.
`javax.xml.stream.events.Characters` | `createCharacters(CDATA cdata)` Constructs a STAX `Characters`event from a DOM4J `CDATA`.
`javax.xml.stream.events.Characters` | `createCharacters(Text text)` Constructs a STAX `Characters`event from a DOM4J `Text`.
`javax.xml.stream.events.Comment` | `createComment(Comment comment)` Constructs a STAX `Comment`event from a DOM4J `Comment`.
`javax.xml.stream.events.DTD` | `createDTD(DocumentType docType)` Constructs a STAX `DTD`event from a DOM4J `DocumentType`.
`javax.xml.stream.events.EndDocument` | `createEndDocument(Document doc)` Constructs a STAX `EndDocument`event from a DOM4J `Document`.
`javax.xml.stream.events.EndElement` | `createEndElement(Element elem)` Constructs a STAX `EndElement`event from a DOM4J `Element`.
`javax.xml.stream.events.Namespace` | `createNamespace(Namespace ns)` Constructs a STAX `Namespace`event from a DOM4J `Namespace`.
`javax.xml.stream.events.ProcessingInstruction` | `createProcessingInstruction(ProcessingInstruction pi)` Constructs a STAX `ProcessingInstruction` event from a DOM4J `ProcessingInstruction`.
`javax.xml.namespace.QName` | `createQName(QName qname)` Constructs a STAX `QName`from a DOM4J `QName`.
`javax.xml.stream.events.StartDocument` | `createStartDocument(Document doc)` Constructs a STAX `StartDocument`event from a DOM4J `Document`.
`javax.xml.stream.events.StartElement` | `createStartElement(Element elem)` Constructs a STAX `StartElement`event from a DOM4J `Element`.
`javax.xml.stream.util.XMLEventConsumer` | `getConsumer()` Returns a reference to the underlying event consumer to which events are written.
`javax.xml.stream.XMLEventFactory` | `getEventFactory()` Returns a reference to the event factory used to construct STAX events.
`void` | `setConsumer(javax.xml.stream.util.XMLEventConsumer consumer)` Sets the underlying event consumer to which events are written.
`void` | `setEventFactory(javax.xml.stream.XMLEventFactory eventFactory)` Sets the event factory used to construct STAX events.
`void` | `writeAttribute(Attribute attr)` Writes a DOM4J `Attribute`to the stream.
`void` | `writeCDATA(CDATA cdata)` Writes a DOM4J `CDATA`to the event stream.
`void` | `writeChildNodes(Branch branch)` Writes each child node within the provided `Branch`instance.
`void` | `writeComment(Comment comment)` Writes a DOM4J `Comment`to the stream.
`void` | `writeDocument(Document doc)` Writes a DOM4J `Document`node, and all its contents, to the stream.
`void` | `writeDocumentType(DocumentType docType)` Writes a DOM4J `DocumentType`to the stream.
`void` | `writeElement(Element elem)` Writes a DOM4J `Element`node and its children to the stream.
`void` | `writeEntity(Entity entity)` Writes a DOM4J `Entity`to the stream.
`void` | `writeNamespace(Namespace ns)` Writes a DOM4J `Namespace`to the stream.
`void` | `writeNode(Node n)` Writes a DOM4J `Node`to the stream.
`void` | `writeProcessingInstruction(ProcessingInstruction pi)` Writes a DOM4J `ProcessingInstruction`to the stream.
`void` | `writeText(Text text)` Writes a DOM4J `Text`to the stream.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### STAXEventWriter

    public STAXEventWriter()

### STAXEventWriter

    public STAXEventWriter(File file)
                    throws javax.xml.stream.XMLStreamException,
                           IOException

  Constructs a `STAXEventWriter` that writes events to the provided file.

Parameters:
  `file` - The file to which events will be written.
Throws:
  `javax.xml.stream.XMLStreamException` - If an error occurs creating an event writer from the file.
  `IOException` - If an error occurs openin the file for writing.

### STAXEventWriter

    public STAXEventWriter(Writer writer)
                    throws javax.xml.stream.XMLStreamException

  Constructs a `STAXEventWriter` that writes events to the provided character stream.

Parameters:
  `writer` - The character stream to which events will be written.
Throws:
  `javax.xml.stream.XMLStreamException` - If an error occurs constructing an event writer from the character stream.

### STAXEventWriter

    public STAXEventWriter(OutputStream stream)
                    throws javax.xml.stream.XMLStreamException

  Constructs a `STAXEventWriter` that writes events to the provided stream.

Parameters:
  `stream` - The output stream to which events will be written.
Throws:
  `javax.xml.stream.XMLStreamException` - If an error occurs constructing an event writer from the stream.

### STAXEventWriter

    public STAXEventWriter(javax.xml.stream.util.XMLEventConsumer consumer)

  Constructs a `STAXEventWriter` that writes events to the provided event stream.

Parameters:
  `consumer` - The event stream to which events will be written.

Method Detail

### getConsumer

    public javax.xml.stream.util.XMLEventConsumer getConsumer()

  Returns a reference to the underlying event consumer to which events are written.

  Returns:
    The underlying event consumer to which events are written.

### setConsumer

    public void setConsumer(javax.xml.stream.util.XMLEventConsumer consumer)

  Sets the underlying event consumer to which events are written.

  Parameters:
    `consumer` - The event consumer to which events should be written.

### getEventFactory

    public javax.xml.stream.XMLEventFactory getEventFactory()

  Returns a reference to the event factory used to construct STAX events.

  Returns:
    The event factory used to construct STAX events.

### setEventFactory

    public void setEventFactory(javax.xml.stream.XMLEventFactory eventFactory)

  Sets the event factory used to construct STAX events.

  Parameters:
    `eventFactory` - The new event factory.

### writeNode

    public void writeNode(Node n)
                   throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `Node`to the stream. This method is simply a gateway to the overloaded methods such as .

  Parameters:
    `n` - The DOM4J `Node`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### writeChildNodes

    public void writeChildNodes(Branch branch)
                         throws javax.xml.stream.XMLStreamException

  Writes each child node within the provided `Branch`instance. This method simply iterates through the `Branch`'s nodes and calls `writeNode(Node)`.

  Parameters:
    `branch` - The node whose children will be written to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### writeElement

    public void writeElement(Element elem)
                      throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `Element`node and its children to the stream.

  Parameters:
    `elem` - The `Element`node to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### createStartElement

    public javax.xml.stream.events.StartElement createStartElement(Element elem)

  Constructs a STAX `StartElement`event from a DOM4J `Element`.

  Parameters:
    `elem` - The `Element`from which to construct the event.
  Returns:
    The newly constructed `StartElement`event.

### createEndElement

    public javax.xml.stream.events.EndElement createEndElement(Element elem)

  Constructs a STAX `EndElement`event from a DOM4J `Element`.

  Parameters:
    `elem` - The `Element`from which to construct the event.
  Returns:
    The newly constructed `EndElement`event.

### writeAttribute

    public void writeAttribute(Attribute attr)
                        throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `Attribute`to the stream.

  Parameters:
    `attr` - The `Attribute`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### createAttribute

    public javax.xml.stream.events.Attribute createAttribute(Attribute attr)

  Constructs a STAX `Attribute`event from a DOM4J `Attribute`.

  Parameters:
    `attr` - The `Attribute`from which to construct the event.
  Returns:
    The newly constructed `Attribute` event.

### writeNamespace

    public void writeNamespace(Namespace ns)
                        throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `Namespace`to the stream.

  Parameters:
    `ns` - The `Namespace`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### createNamespace

    public javax.xml.stream.events.Namespace createNamespace(Namespace ns)

  Constructs a STAX `Namespace`event from a DOM4J `Namespace`.

  Parameters:
    `ns` - The `Namespace`from which to construct the event.
  Returns:
    The constructed `Namespace`event.

### writeText

    public void writeText(Text text)
                   throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `Text`to the stream.

  Parameters:
    `text` - The `Text`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### createCharacters

    public javax.xml.stream.events.Characters createCharacters(Text text)

  Constructs a STAX `Characters`event from a DOM4J `Text`.

  Parameters:
    `text` - The `Text`from which to construct the event.
  Returns:
    The constructed `Characters`event.

### writeCDATA

    public void writeCDATA(CDATA cdata)
                    throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `CDATA`to the event stream.

  Parameters:
    `cdata` - The `CDATA`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### createCharacters

    public javax.xml.stream.events.Characters createCharacters(CDATA cdata)

  Constructs a STAX `Characters`event from a DOM4J `CDATA`.

  Parameters:
    `cdata` - The `CDATA`from which to construct the event.
  Returns:
    The newly constructed `Characters`event.

### writeComment

    public void writeComment(Comment comment)
                      throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `Comment`to the stream.

  Parameters:
    `comment` - The `Comment`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### createComment

    public javax.xml.stream.events.Comment createComment(Comment comment)

  Constructs a STAX `Comment`event from a DOM4J `Comment`.

  Parameters:
    `comment` - The `Comment`from which to construct the event.
  Returns:
    The constructed `Comment`event.

### writeProcessingInstruction

    public void writeProcessingInstruction(ProcessingInstruction pi)
                                    throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `ProcessingInstruction`to the stream.

  Parameters:
    `pi` - The `ProcessingInstruction`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### createProcessingInstruction

    public javax.xml.stream.events.ProcessingInstruction createProcessingInstruction(ProcessingInstruction pi)

  Constructs a STAX `ProcessingInstruction` event from a DOM4J `ProcessingInstruction`.

  Parameters:
    `pi` - The `ProcessingInstruction`from which to construct the event.
  Returns:
    The constructed `ProcessingInstruction` event.

### writeEntity

    public void writeEntity(Entity entity)
                     throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `Entity`to the stream.

  Parameters:
    `entity` - The `Entity`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### writeDocumentType

    public void writeDocumentType(DocumentType docType)
                           throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `DocumentType`to the stream.

  Parameters:
    `docType` - The `DocumentType`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### createDTD

    public javax.xml.stream.events.DTD createDTD(DocumentType docType)

  Constructs a STAX `DTD`event from a DOM4J `DocumentType`.

  Parameters:
    `docType` - The `DocumentType`from which to construct the event.
  Returns:
    The constructed `DTD`event.
  Throws:
    `RuntimeException` - DOCUMENT ME!

### writeDocument

    public void writeDocument(Document doc)
                       throws javax.xml.stream.XMLStreamException

  Writes a DOM4J `Document`node, and all its contents, to the stream.

  Parameters:
    `doc` - The `Document`to write to the stream.
  Throws:
    `javax.xml.stream.XMLStreamException` - If an error occurs writing to the stream.

### createStartDocument

    public javax.xml.stream.events.StartDocument createStartDocument(Document doc)

  Constructs a STAX `StartDocument`event from a DOM4J `Document`.

  Parameters:
    `doc` - The `Document`from which to construct the event.
  Returns:
    The constructed `StartDocument`event.

### createEndDocument

    public javax.xml.stream.events.EndDocument createEndDocument(Document doc)

  Constructs a STAX `EndDocument`event from a DOM4J `Document`.

  Parameters:
    `doc` - The `Document`from which to construct the event.
  Returns:
    The constructed `EndDocument`event.

### createQName

    public javax.xml.namespace.QName createQName(QName qname)

  Constructs a STAX `QName`from a DOM4J `QName`.

  Parameters:
    `qname` - The `QName`from which to construct the STAX `QName`.
  Returns:
    The constructed `QName`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 MetaStuff Ltd.. All Rights Reserved.