org.dom4j.io

Class STAXEventWriter

public class STAXEventWriter extends Object

Writes DOM4J Nodes 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 javax.xml.stream.events.Attributeevent from a DOM4J Attribute.
CharacterscreateCharacters(Text text)
Constructs a STAX Charactersevent from a DOM4J Text.
CharacterscreateCharacters(CDATA cdata)
Constructs a STAX Charactersevent from a DOM4J CDATA.
CommentcreateComment(Comment comment)
Constructs a STAX javax.xml.stream.events.Commentevent from a DOM4J Comment.
DTDcreateDTD(DocumentType docType)
Constructs a STAX DTDevent from a DOM4J DocumentType.
EndDocumentcreateEndDocument(Document doc)
Constructs a STAX EndDocumentevent from a DOM4J Document.
EndElementcreateEndElement(Element elem)
Constructs a STAX EndElementevent from a DOM4J Element.
NamespacecreateNamespace(Namespace ns)
Constructs a STAX javax.xml.stream.events.Namespaceevent from a DOM4J Namespace.
ProcessingInstructioncreateProcessingInstruction(ProcessingInstruction pi)
Constructs a STAX javax.xml.stream.events.ProcessingInstruction event from a DOM4J ProcessingInstruction.
QNamecreateQName(QName qname)
Constructs a STAX QNamefrom a DOM4J QName.
StartDocumentcreateStartDocument(Document doc)
Constructs a STAX StartDocumentevent from a DOM4J Document.
StartElementcreateStartElement(Element elem)
Constructs a STAX StartElementevent from a DOM4J 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 Attributeto the stream.
voidwriteCDATA(CDATA cdata)
Writes a DOM4J CDATAto the event stream.
voidwriteChildNodes(Branch branch)
Writes each child node within the provided Branchinstance.
voidwriteComment(Comment comment)
Writes a DOM4J Commentto the stream.
voidwriteDocument(Document doc)
Writes a DOM4J Documentnode, and all its contents, to the stream.
voidwriteDocumentType(DocumentType docType)
Writes a DOM4J DocumentTypeto the stream.
voidwriteElement(Element elem)
Writes a DOM4J Elementnode and its children to the stream.
voidwriteEntity(Entity entity)
Writes a DOM4J Entityto the stream.
voidwriteNamespace(Namespace ns)
Writes a DOM4J Namespaceto the stream.
voidwriteNode(Node n)
Writes a DOM4J Nodeto the stream.
voidwriteProcessingInstruction(ProcessingInstruction pi)
Writes a DOM4J ProcessingInstructionto the stream.
voidwriteText(Text text)
Writes a DOM4J Textto 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 javax.xml.stream.events.Attributeevent from a DOM4J Attribute.

Parameters: attr The Attributefrom which to construct the event.

Returns: The newly constructed javax.xml.stream.events.Attribute event.

createCharacters

public Characters createCharacters(Text text)
Constructs a STAX Charactersevent from a DOM4J Text.

Parameters: text The Textfrom which to construct the event.

Returns: The constructed Charactersevent.

createCharacters

public Characters createCharacters(CDATA cdata)
Constructs a STAX Charactersevent from a DOM4J CDATA.

Parameters: cdata The CDATAfrom which to construct the event.

Returns: The newly constructed Charactersevent.

createComment

public Comment createComment(Comment comment)
Constructs a STAX javax.xml.stream.events.Commentevent from a DOM4J Comment.

Parameters: comment The Commentfrom which to construct the event.

Returns: The constructed javax.xml.stream.events.Commentevent.

createDTD

public DTD createDTD(DocumentType docType)
Constructs a STAX DTDevent from a DOM4J DocumentType.

Parameters: docType The DocumentTypefrom which to construct the event.

Returns: The constructed DTDevent.

Throws: RuntimeException DOCUMENT ME!

createEndDocument

public EndDocument createEndDocument(Document doc)
Constructs a STAX EndDocumentevent from a DOM4J Document.

Parameters: doc The Documentfrom which to construct the event.

Returns: The constructed EndDocumentevent.

createEndElement

public EndElement createEndElement(Element elem)
Constructs a STAX EndElementevent from a DOM4J Element.

Parameters: elem The Elementfrom which to construct the event.

Returns: The newly constructed EndElementevent.

createNamespace

public Namespace createNamespace(Namespace ns)
Constructs a STAX javax.xml.stream.events.Namespaceevent from a DOM4J Namespace.

Parameters: ns The Namespacefrom which to construct the event.

Returns: The constructed javax.xml.stream.events.Namespaceevent.

createProcessingInstruction

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

Parameters: pi The ProcessingInstructionfrom which to construct the event.

Returns: The constructed javax.xml.stream.events.ProcessingInstruction event.

createQName

public QName createQName(QName qname)
Constructs a STAX QNamefrom a DOM4J QName.

Parameters: qname The QNamefrom which to construct the STAX QName.

Returns: The constructed QName.

createStartDocument

public StartDocument createStartDocument(Document doc)
Constructs a STAX StartDocumentevent from a DOM4J Document.

Parameters: doc The Documentfrom which to construct the event.

Returns: The constructed StartDocumentevent.

createStartElement

public StartElement createStartElement(Element elem)
Constructs a STAX StartElementevent from a DOM4J Element.

Parameters: elem The Elementfrom which to construct the event.

Returns: The newly constructed StartElementevent.

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 Attributeto the stream.

Parameters: attr The Attributeto write to the stream.

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

writeCDATA

public void writeCDATA(CDATA cdata)
Writes a DOM4J CDATAto the event stream.

Parameters: cdata The CDATAto 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 Branchinstance. This method simply iterates through the Branch's nodes and calls writeNode.

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 Commentto the stream.

Parameters: comment The Commentto write to the stream.

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

writeDocument

public void writeDocument(Document doc)
Writes a DOM4J Documentnode, and all its contents, to the stream.

Parameters: doc The Documentto write to the stream.

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

writeDocumentType

public void writeDocumentType(DocumentType docType)
Writes a DOM4J DocumentTypeto the stream.

Parameters: docType The DocumentTypeto write to the stream.

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

writeElement

public void writeElement(Element elem)
Writes a DOM4J Elementnode and its children to the stream.

Parameters: elem The Elementnode to write to the stream.

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

writeEntity

public void writeEntity(Entity entity)
Writes a DOM4J Entityto the stream.

Parameters: entity The Entityto write to the stream.

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

writeNamespace

public void writeNamespace(Namespace ns)
Writes a DOM4J Namespaceto the stream.

Parameters: ns The Namespaceto write to the stream.

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

writeNode

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

Parameters: n The DOM4J Nodeto write to the stream.

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

writeProcessingInstruction

public void writeProcessingInstruction(ProcessingInstruction pi)
Writes a DOM4J ProcessingInstructionto the stream.

Parameters: pi The ProcessingInstructionto write to the stream.

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

writeText

public void writeText(Text text)
Writes a DOM4J Textto the stream.

Parameters: text The Textto 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