Package org.dom4j.io
Class STAXEventWriter
- java.lang.Object
 - 
- org.dom4j.io.STAXEventWriter
 
 
- 
- 
Constructor Summary
Constructors Constructor Description STAXEventWriter()STAXEventWriter(File file)Constructs aSTAXEventWriterthat writes events to the provided file.STAXEventWriter(OutputStream stream)Constructs aSTAXEventWriterthat writes events to the provided stream.STAXEventWriter(Writer writer)Constructs aSTAXEventWriterthat writes events to the provided character stream.STAXEventWriter(XMLEventConsumer consumer)Constructs aSTAXEventWriterthat writes events to the provided event stream. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributecreateAttribute(Attribute attr)CharacterscreateCharacters(CDATA cdata)Constructs a STAXCharactersevent from a DOM4JCDATA.CharacterscreateCharacters(Text text)Constructs a STAXCharactersevent from a DOM4JText.CommentcreateComment(Comment comment)DTDcreateDTD(DocumentType docType)Constructs a STAXDTDevent from a DOM4JDocumentType.EndDocumentcreateEndDocument(Document doc)Constructs a STAXEndDocumentevent from a DOM4JDocument.EndElementcreateEndElement(Element elem)Constructs a STAXEndElementevent from a DOM4JElement.NamespacecreateNamespace(Namespace ns)ProcessingInstructioncreateProcessingInstruction(ProcessingInstruction pi)Constructs a STAXProcessingInstructionevent from a DOM4JProcessingInstruction.QNamecreateQName(QName qname)StartDocumentcreateStartDocument(Document doc)Constructs a STAXStartDocumentevent from a DOM4JDocument.StartElementcreateStartElement(Element elem)Constructs a STAXStartElementevent from a DOM4JElement.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 DOM4JAttributeto the stream.voidwriteCDATA(CDATA cdata)Writes a DOM4JCDATAto the event stream.voidwriteChildNodes(Branch branch)Writes each child node within the providedBranchinstance.voidwriteComment(Comment comment)Writes a DOM4JCommentto the stream.voidwriteDocument(Document doc)Writes a DOM4JDocumentnode, and all its contents, to the stream.voidwriteDocumentType(DocumentType docType)Writes a DOM4JDocumentTypeto the stream.voidwriteElement(Element elem)Writes a DOM4JElementnode and its children to the stream.voidwriteEntity(Entity entity)Writes a DOM4JEntityto the stream.voidwriteNamespace(Namespace ns)Writes a DOM4JNamespaceto the stream.voidwriteNode(Node n)Writes a DOM4JNodeto the stream.voidwriteProcessingInstruction(ProcessingInstruction pi)Writes a DOM4JProcessingInstructionto the stream.voidwriteText(Text text)Writes a DOM4JTextto the stream. 
 - 
 
- 
- 
Constructor Detail
- 
STAXEventWriter
public STAXEventWriter()
 
- 
STAXEventWriter
public STAXEventWriter(File file) throws XMLStreamException, IOException
Constructs aSTAXEventWriterthat 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) throws XMLStreamException
Constructs aSTAXEventWriterthat 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) throws XMLStreamException
Constructs aSTAXEventWriterthat 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 aSTAXEventWriterthat writes events to the provided event stream.- Parameters:
 consumer- The event stream to which events will be written.
 
 - 
 
- 
Method Detail
- 
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.
 
 
- 
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.
 
- 
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.
 
 
- 
setEventFactory
public void setEventFactory(XMLEventFactory eventFactory)
Sets the event factory used to construct STAX events.- Parameters:
 eventFactory- The new event factory.
 
- 
writeNode
public void writeNode(Node n) throws XMLStreamException
Writes a DOM4JNodeto the stream. This method is simply a gateway to the overloaded methods such aswriteElement(Element).- Parameters:
 n- The DOM4JNodeto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
writeChildNodes
public void writeChildNodes(Branch branch) throws XMLStreamException
Writes each child node within the providedBranchinstance. This method simply iterates through theBranch's nodes and callswriteNode(Node).- Parameters:
 branch- The node whose children will be written to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
writeElement
public void writeElement(Element elem) throws XMLStreamException
Writes a DOM4JElementnode and its children to the stream.- Parameters:
 elem- TheElementnode to write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
createStartElement
public StartElement createStartElement(Element elem)
Constructs a STAXStartElementevent from a DOM4JElement.- Parameters:
 elem- TheElementfrom which to construct the event.- Returns:
 - The newly constructed 
StartElementevent. 
 
- 
createEndElement
public EndElement createEndElement(Element elem)
Constructs a STAXEndElementevent from a DOM4JElement.- Parameters:
 elem- TheElementfrom which to construct the event.- Returns:
 - The newly constructed 
EndElementevent. 
 
- 
writeAttribute
public void writeAttribute(Attribute attr) throws XMLStreamException
Writes a DOM4JAttributeto the stream.- Parameters:
 attr- TheAttributeto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
writeNamespace
public void writeNamespace(Namespace ns) throws XMLStreamException
Writes a DOM4JNamespaceto the stream.- Parameters:
 ns- TheNamespaceto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
writeText
public void writeText(Text text) throws XMLStreamException
Writes a DOM4JTextto the stream.- Parameters:
 text- TheTextto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
createCharacters
public Characters createCharacters(Text text)
Constructs a STAXCharactersevent from a DOM4JText.- Parameters:
 text- TheTextfrom which to construct the event.- Returns:
 - The constructed 
Charactersevent. 
 
- 
writeCDATA
public void writeCDATA(CDATA cdata) throws XMLStreamException
Writes a DOM4JCDATAto the event stream.- Parameters:
 cdata- TheCDATAto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
createCharacters
public Characters createCharacters(CDATA cdata)
Constructs a STAXCharactersevent from a DOM4JCDATA.- Parameters:
 cdata- TheCDATAfrom which to construct the event.- Returns:
 - The newly constructed 
Charactersevent. 
 
- 
writeComment
public void writeComment(Comment comment) throws XMLStreamException
Writes a DOM4JCommentto the stream.- Parameters:
 comment- TheCommentto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
writeProcessingInstruction
public void writeProcessingInstruction(ProcessingInstruction pi) throws XMLStreamException
Writes a DOM4JProcessingInstructionto the stream.- Parameters:
 pi- TheProcessingInstructionto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
createProcessingInstruction
public ProcessingInstruction createProcessingInstruction(ProcessingInstruction pi)
Constructs a STAXProcessingInstructionevent from a DOM4JProcessingInstruction.- Parameters:
 pi- TheProcessingInstructionfrom which to construct the event.- Returns:
 - The constructed 
ProcessingInstructionevent. 
 
- 
writeEntity
public void writeEntity(Entity entity) throws XMLStreamException
Writes a DOM4JEntityto the stream.- Parameters:
 entity- TheEntityto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
writeDocumentType
public void writeDocumentType(DocumentType docType) throws XMLStreamException
Writes a DOM4JDocumentTypeto the stream.- Parameters:
 docType- TheDocumentTypeto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
createDTD
public DTD createDTD(DocumentType docType)
Constructs a STAXDTDevent from a DOM4JDocumentType.- Parameters:
 docType- TheDocumentTypefrom which to construct the event.- Returns:
 - The constructed 
DTDevent. - Throws:
 RuntimeException- DOCUMENT ME!
 
- 
writeDocument
public void writeDocument(Document doc) throws XMLStreamException
Writes a DOM4JDocumentnode, and all its contents, to the stream.- Parameters:
 doc- TheDocumentto write to the stream.- Throws:
 XMLStreamException- If an error occurs writing to the stream.
 
- 
createStartDocument
public StartDocument createStartDocument(Document doc)
Constructs a STAXStartDocumentevent from a DOM4JDocument.- Parameters:
 doc- TheDocumentfrom which to construct the event.- Returns:
 - The constructed 
StartDocumentevent. 
 
- 
createEndDocument
public EndDocument createEndDocument(Document doc)
Constructs a STAXEndDocumentevent from a DOM4JDocument.- Parameters:
 doc- TheDocumentfrom which to construct the event.- Returns:
 - The constructed 
EndDocumentevent. 
 
 - 
 
 -