org.dom4j.io

Class STAXEventWriter

public class STAXEventWriter extends Object

Writes DOM4J {@link 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(Writer writer)
Constructs a STAXEventWriter that writes events to the provided character stream.
STAXEventWriter(OutputStream stream)
Constructs a STAXEventWriter that writes events to the provided stream.
STAXEventWriter(XMLEventConsumer consumer)
Constructs a STAXEventWriter that writes events to the provided event stream.
Method Summary
AttributecreateAttribute(Attribute attr)
Constructs a STAX {@link javax.xml.stream.events.Attribute}event from a DOM4J {@link Attribute}.
CharacterscreateCharacters(Text text)
Constructs a STAX {@link Characters}event from a DOM4J {@link Text}.
CharacterscreateCharacters(CDATA cdata)
Constructs a STAX {@link Characters}event from a DOM4J {@link CDATA}.
CommentcreateComment(Comment comment)
Constructs a STAX {@link javax.xml.stream.events.Comment}event from a DOM4J {@link Comment}.
DTDcreateDTD(DocumentType docType)
Constructs a STAX {@link DTD}event from a DOM4J {@link DocumentType}.
EndDocumentcreateEndDocument(Document doc)
Constructs a STAX {@link EndDocument}event from a DOM4J {@link Document}.
EndElementcreateEndElement(Element elem)
Constructs a STAX {@link EndElement}event from a DOM4J {@link Element}.
NamespacecreateNamespace(Namespace ns)
Constructs a STAX {@link javax.xml.stream.events.Namespace}event from a DOM4J {@link Namespace}.
ProcessingInstructioncreateProcessingInstruction(ProcessingInstruction pi)
Constructs a STAX {@link javax.xml.stream.events.ProcessingInstruction} event from a DOM4J {@link ProcessingInstruction}.
QNamecreateQName(QName qname)
Constructs a STAX {@link QName}from a DOM4J {@link org.dom4j.QName}.
StartDocumentcreateStartDocument(Document doc)
Constructs a STAX {@link StartDocument}event from a DOM4J {@link Document}.
StartElementcreateStartElement(Element elem)
Constructs a STAX {@link StartElement}event from a DOM4J {@link Element}.
XMLEventConsumergetConsumer()
Returns a reference to the underlying event consumer to which events are written.
XMLEventFactorygetEventFactory()
Returns a reference to the event factory used to construct STAX events.
voidsetConsumer(XMLEventConsumer consumer)
Sets the underlying event consumer to which events are written.
voidsetEventFactory(XMLEventFactory eventFactory)
Sets the event factory used to construct STAX events.
voidwriteAttribute(Attribute attr)
Writes a DOM4J {@link Attribute}to the stream.
voidwriteCDATA(CDATA cdata)
Writes a DOM4J {@link CDATA}to the event stream.
voidwriteChildNodes(Branch branch)
Writes each child node within the provided {@link Branch}instance.
voidwriteComment(Comment comment)
Writes a DOM4J {@link Comment}to the stream.
voidwriteDocument(Document doc)
Writes a DOM4J {@link Document}node, and all its contents, to the stream.
voidwriteDocumentType(DocumentType docType)
Writes a DOM4J {@link DocumentType}to the stream.
voidwriteElement(Element elem)
Writes a DOM4J {@link Element}node and its children to the stream.
voidwriteEntity(Entity entity)
Writes a DOM4J {@link Entity}to the stream.
voidwriteNamespace(Namespace ns)
Writes a DOM4J {@link Namespace}to the stream.
voidwriteNode(Node n)
Writes a DOM4J {@link Node}to the stream.
voidwriteProcessingInstruction(ProcessingInstruction pi)
Writes a DOM4J {@link ProcessingInstruction}to the stream.
voidwriteText(Text text)
Writes a DOM4J {@link Text}to the stream.

Constructor Detail

STAXEventWriter

public STAXEventWriter()

STAXEventWriter

public STAXEventWriter(File file)
Constructs a STAXEventWriter that writes events to the provided file.

Parameters: file The file to which events will be written.

Throws: 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)
Constructs a STAXEventWriter that writes events to the provided character stream.

Parameters: writer The character stream to which events will be written.

Throws: XMLStreamException If an error occurs constructing an event writer from the character stream.

STAXEventWriter

public STAXEventWriter(OutputStream stream)
Constructs a STAXEventWriter that writes events to the provided stream.

Parameters: stream The output stream to which events will be written.

Throws: XMLStreamException If an error occurs constructing an event writer from the stream.

STAXEventWriter

public STAXEventWriter(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

createAttribute

public Attribute createAttribute(Attribute attr)
Constructs a STAX {@link javax.xml.stream.events.Attribute}event from a DOM4J {@link Attribute}.

Parameters: attr The {@link Attribute}from which to construct the event.

Returns: The newly constructed {@link javax.xml.stream.events.Attribute} event.

createCharacters

public Characters createCharacters(Text text)
Constructs a STAX {@link Characters}event from a DOM4J {@link Text}.

Parameters: text The {@link Text}from which to construct the event.

Returns: The constructed {@link Characters}event.

createCharacters

public Characters createCharacters(CDATA cdata)
Constructs a STAX {@link Characters}event from a DOM4J {@link CDATA}.

Parameters: cdata The {@link CDATA}from which to construct the event.

Returns: The newly constructed {@link Characters}event.

createComment

public Comment createComment(Comment comment)
Constructs a STAX {@link javax.xml.stream.events.Comment}event from a DOM4J {@link Comment}.

Parameters: comment The {@link Comment}from which to construct the event.

Returns: The constructed {@link javax.xml.stream.events.Comment}event.

createDTD

public DTD createDTD(DocumentType docType)
Constructs a STAX {@link DTD}event from a DOM4J {@link DocumentType}.

Parameters: docType The {@link DocumentType}from which to construct the event.

Returns: The constructed {@link DTD}event.

Throws: RuntimeException DOCUMENT ME!

createEndDocument

public EndDocument createEndDocument(Document doc)
Constructs a STAX {@link EndDocument}event from a DOM4J {@link Document}.

Parameters: doc The {@link Document}from which to construct the event.

Returns: The constructed {@link EndDocument}event.

createEndElement

public EndElement createEndElement(Element elem)
Constructs a STAX {@link EndElement}event from a DOM4J {@link Element}.

Parameters: elem The {@link Element}from which to construct the event.

Returns: The newly constructed {@link EndElement}event.

createNamespace

public Namespace createNamespace(Namespace ns)
Constructs a STAX {@link javax.xml.stream.events.Namespace}event from a DOM4J {@link Namespace}.

Parameters: ns The {@link Namespace}from which to construct the event.

Returns: The constructed {@link javax.xml.stream.events.Namespace}event.

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(ProcessingInstruction pi)
Constructs a STAX {@link javax.xml.stream.events.ProcessingInstruction} event from a DOM4J {@link ProcessingInstruction}.

Parameters: pi The {@link ProcessingInstruction}from which to construct the event.

Returns: The constructed {@link javax.xml.stream.events.ProcessingInstruction} event.

createQName

public QName createQName(QName qname)
Constructs a STAX {@link QName}from a DOM4J {@link org.dom4j.QName}.

Parameters: qname The {@link org.dom4j.QName}from which to construct the STAX {@link QName}.

Returns: The constructed {@link QName}.

createStartDocument

public StartDocument createStartDocument(Document doc)
Constructs a STAX {@link StartDocument}event from a DOM4J {@link Document}.

Parameters: doc The {@link Document}from which to construct the event.

Returns: The constructed {@link StartDocument}event.

createStartElement

public StartElement createStartElement(Element elem)
Constructs a STAX {@link StartElement}event from a DOM4J {@link Element}.

Parameters: elem The {@link Element}from which to construct the event.

Returns: The newly constructed {@link StartElement}event.

getConsumer

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

getEventFactory

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

Returns: The event factory used to construct STAX events.

setConsumer

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

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

setEventFactory

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

Parameters: eventFactory The new event factory.

writeAttribute

public void writeAttribute(Attribute attr)
Writes a DOM4J {@link Attribute}to the stream.

Parameters: attr The {@link Attribute}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeCDATA

public void writeCDATA(CDATA cdata)
Writes a DOM4J {@link CDATA}to the event stream.

Parameters: cdata The {@link CDATA}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeChildNodes

public void writeChildNodes(Branch branch)
Writes each child node within the provided {@link Branch}instance. This method simply iterates through the {@link Branch}'s nodes and calls {@link #writeNode(Node)}.

Parameters: branch The node whose children will be written to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeComment

public void writeComment(Comment comment)
Writes a DOM4J {@link Comment}to the stream.

Parameters: comment The {@link Comment}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeDocument

public void writeDocument(Document doc)
Writes a DOM4J {@link Document}node, and all its contents, to the stream.

Parameters: doc The {@link Document}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeDocumentType

public void writeDocumentType(DocumentType docType)
Writes a DOM4J {@link DocumentType}to the stream.

Parameters: docType The {@link DocumentType}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeElement

public void writeElement(Element elem)
Writes a DOM4J {@link Element}node and its children to the stream.

Parameters: elem The {@link Element}node to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeEntity

public void writeEntity(Entity entity)
Writes a DOM4J {@link Entity}to the stream.

Parameters: entity The {@link Entity}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeNamespace

public void writeNamespace(Namespace ns)
Writes a DOM4J {@link Namespace}to the stream.

Parameters: ns The {@link Namespace}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeNode

public void writeNode(Node n)
Writes a DOM4J {@link Node}to the stream. This method is simply a gateway to the overloaded methods such as {@link#writeElement(Element)}.

Parameters: n The DOM4J {@link Node}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeProcessingInstruction

public void writeProcessingInstruction(ProcessingInstruction pi)
Writes a DOM4J {@link ProcessingInstruction}to the stream.

Parameters: pi The {@link ProcessingInstruction}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

writeText

public void writeText(Text text)
Writes a DOM4J {@link Text}to the stream.

Parameters: text The {@link Text}to write to the stream.

Throws: XMLStreamException If an error occurs writing to the stream.

Copyright B) 2005 MetaStuff Ltd. All Rights Reserved. Hosted by

SourceForge