Class STAXEventWriter
java.lang.Object
org.dom4j.io.STAXEventWriter
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate XMLEventConsumerThe event stream to which events are written.private XMLEventFactoryThe event factory used to construct events.private XMLOutputFactory -
Constructor Summary
ConstructorsConstructorDescriptionSTAXEventWriter(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
Modifier and TypeMethodDescriptioncreateAttribute(Attribute attr) createCharacters(CDATA cdata) Constructs a STAXCharactersevent from a DOM4JCDATA.createCharacters(Text text) Constructs a STAXCharactersevent from a DOM4JText.createComment(Comment comment) createDTD(DocumentType docType) Constructs a STAXDTDevent from a DOM4JDocumentType.Constructs a STAXEndDocumentevent from a DOM4JDocument.createEndElement(Element elem) Constructs a STAXEndElementevent from a DOM4JElement.private EntityReferencecreateEntityReference(Entity entity) Constructs a STAXEntityReferenceevent from a DOM4JEntity.Constructs a STAXProcessingInstructionevent from a DOM4JProcessingInstruction.createQName(QName qname) Constructs a STAXStartDocumentevent from a DOM4JDocument.createStartElement(Element elem) Constructs a STAXStartElementevent from a DOM4JElement.Returns a reference to the underlying event consumer to which events are written.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.voidWrites a DOM4JNamespaceto the stream.voidWrites a DOM4JNodeto the stream.voidWrites a DOM4JProcessingInstructionto the stream.voidWrites a DOM4JTextto the stream.
-
Field Details
-
consumer
The event stream to which events are written. -
factory
The event factory used to construct events. -
outputFactory
-
-
Constructor Details
-
STAXEventWriter
public STAXEventWriter() -
STAXEventWriter
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
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
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
Constructs aSTAXEventWriterthat writes events to the provided event stream.- Parameters:
consumer- The event stream to which events will be written.
-
-
Method Details
-
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
Sets the underlying event consumer to which events are written.- Parameters:
consumer- The event consumer to which events should be written.
-
getEventFactory
Returns a reference to the event factory used to construct STAX events.- Returns:
- The event factory used to construct STAX events.
-
setEventFactory
Sets the event factory used to construct STAX events.- Parameters:
eventFactory- The new event factory.
-
writeNode
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
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
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
Constructs a STAXStartElementevent from a DOM4JElement.- Parameters:
elem- TheElementfrom which to construct the event.- Returns:
- The newly constructed
StartElementevent.
-
createEndElement
Constructs a STAXEndElementevent from a DOM4JElement.- Parameters:
elem- TheElementfrom which to construct the event.- Returns:
- The newly constructed
EndElementevent.
-
writeAttribute
Writes a DOM4JAttributeto the stream.- Parameters:
attr- TheAttributeto write to the stream.- Throws:
XMLStreamException- If an error occurs writing to the stream.
-
createAttribute
-
writeNamespace
Writes a DOM4JNamespaceto the stream.- Parameters:
ns- TheNamespaceto write to the stream.- Throws:
XMLStreamException- If an error occurs writing to the stream.
-
createNamespace
-
writeText
Writes a DOM4JTextto the stream.- Parameters:
text- TheTextto write to the stream.- Throws:
XMLStreamException- If an error occurs writing to the stream.
-
createCharacters
Constructs a STAXCharactersevent from a DOM4JText.- Parameters:
text- TheTextfrom which to construct the event.- Returns:
- The constructed
Charactersevent.
-
writeCDATA
Writes a DOM4JCDATAto the event stream.- Parameters:
cdata- TheCDATAto write to the stream.- Throws:
XMLStreamException- If an error occurs writing to the stream.
-
createCharacters
Constructs a STAXCharactersevent from a DOM4JCDATA.- Parameters:
cdata- TheCDATAfrom which to construct the event.- Returns:
- The newly constructed
Charactersevent.
-
writeComment
Writes a DOM4JCommentto the stream.- Parameters:
comment- TheCommentto write to the stream.- Throws:
XMLStreamException- If an error occurs writing to the stream.
-
createComment
-
writeProcessingInstruction
Writes a DOM4JProcessingInstructionto the stream.- Parameters:
pi- TheProcessingInstructionto write to the stream.- Throws:
XMLStreamException- If an error occurs writing to the stream.
-
createProcessingInstruction
Constructs a STAXProcessingInstructionevent from a DOM4JProcessingInstruction.- Parameters:
pi- TheProcessingInstructionfrom which to construct the event.- Returns:
- The constructed
ProcessingInstructionevent.
-
writeEntity
Writes a DOM4JEntityto the stream.- Parameters:
entity- TheEntityto write to the stream.- Throws:
XMLStreamException- If an error occurs writing to the stream.
-
createEntityReference
Constructs a STAXEntityReferenceevent from a DOM4JEntity.- Parameters:
entity- TheEntityfrom which to construct the event.- Returns:
- The constructed
EntityReferenceevent.
-
writeDocumentType
Writes a DOM4JDocumentTypeto the stream.- Parameters:
docType- TheDocumentTypeto write to the stream.- Throws:
XMLStreamException- If an error occurs writing to the stream.
-
createDTD
Constructs a STAXDTDevent from a DOM4JDocumentType.- Parameters:
docType- TheDocumentTypefrom which to construct the event.- Returns:
- The constructed
DTDevent. - Throws:
RuntimeException- DOCUMENT ME!
-
writeDocument
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
Constructs a STAXStartDocumentevent from a DOM4JDocument.- Parameters:
doc- TheDocumentfrom which to construct the event.- Returns:
- The constructed
StartDocumentevent.
-
createEndDocument
Constructs a STAXEndDocumentevent from a DOM4JDocument.- Parameters:
doc- TheDocumentfrom which to construct the event.- Returns:
- The constructed
EndDocumentevent.
-
createQName
-