The StAXStreamOutputter can manage many styles of document formatting, from untouched to 'pretty' printed. The default is to output the document content exactly as created, but this can be changed by setting a new Format object:
Format#getPrettyFormat().
Format#getCompactFormat().
Format#getRawFormat().
All of the output*(...) methods will flush the
destination XMLEventConsumer before returning, and none of them
will close() the destination.
To omit output of the declaration use
. To omit printing of the
encoding in the declaration use Format#setOmitDeclaration.
Format#setOmitEncoding
If changing the Format settings are insufficient for your output
needs you can customise this StAXStreamOutputter further by setting a different
StAXEventProcessor with the
setStAXEventProcessor(StAXEventProcessor) method or an appropriate
constructor. A fully-enabled Abstract class
AbstractStAXEventProcessor is available to be further extended to
your needs if all you want to do is tweak some details.
| Modifier and Type | Class and Description |
|---|---|
| private static class | StAXEventOutputter.DefaultStAXEventProcessor
Create a final and static instance of the AbstractStAXEventProcessor The final part is important because it improves performance. |
| Modifier and Type | Field and Description |
|---|---|
| private static final XMLEventFactory | DEFAULTEVENTFACTORY
This constant StAXEventProcessor is used for all non-customised StAXStreamOutputters |
| private static final StAXEventOutputter. | DEFAULTPROCESSOR
This constant StAXEventProcessor is used for all non-customised StAXStreamOutputters |
| private XMLEventFactory | |
| private Format | |
| private StAXEventProcessor |
| Access | Constructor and Description |
|---|---|
| public | StAXEventOutputter(Format
The Format instance to use. This instance will be cloned() and as
a consequence, changes made to the specified format instance
will not be reflected in this StAXStreamOutputter. A null input
format indicates that StAXStreamOutputter should use the default
format, StAXEventProcessor Format#getRawFormat()The XMLOutputProcessor to delegate output to. If null the
StAXStreamOutputter will use the default XMLOutputProcessor. processor, XMLEventFactory The factory to use to create XMLEvent instances. eventfactory)This will create an |
| public | StAXEventOutputter()
This will create an |
| public | StAXEventOutputter(Format
The Format instance to use. This instance will be cloned() and as
a consequence, changes made to the specified format instance
will not be reflected in this StAXStreamOutputter. A null input
format indicates that StAXStreamOutputter should use the default
format)Format#getRawFormat()This will create an |
| public | StAXEventOutputter(StAXEventProcessor
The XMLOutputProcessor to delegate output to. If null the
StAXStreamOutputter will use the default XMLOutputProcessor. processor)This will create an |
| public | StAXEventOutputter(XMLEventFactory
The XMLEventFactory to use to create XMLEvent instances. eventfactory)This will create an |
| Modifier and Type | Method and Description |
|---|---|
| public StAXEventOutputter | |
| public XMLEventFactory | |
| public Format | Returns: the current Format instance used by this StAXStreamOutputter.Returns the current format in use by the StAXStreamOutputter. |
| public StAXEventProcessor | Returns: the current XMLOutputProcessor instance.Returns the current XMLOutputProcessor instance in use by the StAXStreamOutputter. |
| public final void | output(Document
Document to format.XMLEventConsumer to use.This will print the |
| public final void | output(DocType
DocType to output.XMLEventConsumer to use.Print out the |
| public final void | output(Element
Element to output.XMLEventConsumer to use.Print out an |
| public final void | output(List<? extends Content>
List of nodes.XMLEventConsumer to use.This will handle printing out a list of nodes. |
| public final void | output(CDATA
CDATA to output.XMLEventConsumer to use.Print out a |
| public final void | output(Text
Text to output.XMLEventConsumer to use.Print out a |
| public final void | output(Comment
Comment to output.XMLEventConsumer to use.Print out a |
| public final void | output(ProcessingInstruction
ProcessingInstruction to output.XMLEventConsumer to use.Print out a |
| public final void | output(EntityRef
EntityRef to output.XMLEventConsumer to use.Print out an |
| public final void | outputElementContent(Element
Element to output.XMLEventConsumer to use.This will handle printing out an |
| public void | |
| public void | |
| public void | setStAXEventProcessor(StAXEventProcessor
the new XMLOutputProcesor to use for output processor)Sets a new XMLOutputProcessor instance for this StAXStreamOutputter. |
| public String | Returns: a string listing the settings for this StAXStreamOutputter instanceOverrides java. |
| DEFAULTEVENTFACTORY | back to summary |
|---|---|
| private static final XMLEventFactory DEFAULTEVENTFACTORY This constant StAXEventProcessor is used for all non-customised StAXStreamOutputters | |
| DEFAULTPROCESSOR | back to summary |
|---|---|
| private static final StAXEventOutputter. This constant StAXEventProcessor is used for all non-customised StAXStreamOutputters | |
| myEventFactory | back to summary |
|---|---|
| private XMLEventFactory myEventFactory | |
| myFormat | back to summary |
|---|---|
| private Format myFormat | |
| myProcessor | back to summary |
|---|---|
| private StAXEventProcessor myProcessor | |
| StAXEventOutputter | back to summary |
|---|---|
| public StAXEventOutputter(Format format, StAXEventProcessor processor, XMLEventFactory eventfactory) This will create an Note the format object is cloned internally before use. If you
want to modify the Format after constructing the StAXStreamOutputter you can
modify the Format instance
| |
| StAXEventOutputter | back to summary |
|---|---|
| public StAXEventOutputter() This will create an | |
| StAXEventOutputter | back to summary |
|---|---|
| public StAXEventOutputter(Format format) This will create an Note the format object is cloned internally before use.
| |
| StAXEventOutputter | back to summary |
|---|---|
| public StAXEventOutputter(StAXEventProcessor processor) This will create an
| |
| StAXEventOutputter | back to summary |
|---|---|
| public StAXEventOutputter(XMLEventFactory eventfactory) This will create an
| |
| clone | back to summary |
|---|---|
| public StAXEventOutputter clone() Overrides java. Returns a cloned copy of this StAXStreamOutputter.
| |
| getEventFactory | back to summary |
|---|---|
public XMLEventFactory getEventFactory()
| |
| getFormat | back to summary |
|---|---|
| public Format getFormat() Returns the current format in use by the StAXStreamOutputter. Note the Format object returned is not a clone of the one used internally, thus, an StAXStreamOutputter instance is able to have its Format changed by changing the settings on the Format instance returned by this method.
| |
| getStAXStream | back to summary |
|---|---|
| public StAXEventProcessor getStAXStream() Returns the current XMLOutputProcessor instance in use by the StAXStreamOutputter.
| |
| output | back to summary |
|---|---|
| public final void output(Document doc, XMLEventConsumer out) throws XMLStreamException This will print the Warning using your own Writer may cause the outputter's preferred character encoding to be ignored. If you use encodings other than UTF-8, we recommend using the method that takes an OutputStream instead.
| |
| output | back to summary |
|---|---|
| public final void output(DocType doctype, XMLEventConsumer out) throws XMLStreamException Print out the
| |
| output | back to summary |
|---|---|
| public final void output(Element element, XMLEventConsumer out) throws XMLStreamException Print out an
| |
| output | back to summary |
|---|---|
| public final void output(List<? extends Content> list, XMLEventConsumer out) throws XMLStreamException This will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".
| |
| output | back to summary |
|---|---|
| public final void output(CDATA cdata, XMLEventConsumer out) throws XMLStreamException Print out a
| |
| output | back to summary |
|---|---|
| public final void output(Text text, XMLEventConsumer out) throws XMLStreamException Print out a
| |
| output | back to summary |
|---|---|
| public final void output(Comment comment, XMLEventConsumer out) throws XMLStreamException Print out a
| |
| output | back to summary |
|---|---|
| public final void output(ProcessingInstruction pi, XMLEventConsumer out) throws XMLStreamException Print out a
| |
| output | back to summary |
|---|---|
| public final void output(EntityRef entity, XMLEventConsumer out) throws XMLStreamException Print out an
| |
| outputElementContent | back to summary |
|---|---|
| public final void outputElementContent(Element element, XMLEventConsumer out) throws XMLStreamException This will handle printing out an
| |
| setEventFactory | back to summary |
|---|---|
public void setEventFactory(XMLEventFactory myEventFactory)
| |
| setFormat | back to summary |
|---|---|
| public void setFormat(Format newFormat) Sets the new format logic for the StAXStreamOutputter. Note the Format object is cloned internally before use.
| |
| setStAXEventProcessor | back to summary |
|---|---|
| public void setStAXEventProcessor(StAXEventProcessor processor) Sets a new XMLOutputProcessor instance for this StAXStreamOutputter. Note the processor object is expected to be thread-safe.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Return a string listing of the settings for this StAXStreamOutputter instance. | |
The JDOM user can change the actual XMLOutputProcessor with the
StAXEventOutputter#setStAXEventProcessor(StAXEventProcessor) method.
| Access | Constructor and Description |
|---|---|
| private |
| DefaultStAXEventProcessor | back to summary |
|---|---|
| private DefaultStAXEventProcessor() | |