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 XMLStreamWriter 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
StAXStreamProcessor with the
setStAXStreamProcessor(StAXStreamProcessor) method or an appropriate
constructor. A fully-enabled Abstract class
AbstractStAXStreamProcessor 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 | StAXStreamOutputter.DefaultStAXStreamProcessor
Create a final and static instance of the AbstractStAXStreamProcessor The final part is important because it improves performance. |
| Modifier and Type | Field and Description |
|---|---|
| private static final StAXStreamOutputter. | DEFAULTPROCESSOR
This constant StAXStreamProcessor is used for all non-customised StAXStreamOutputters |
| private Format | |
| private StAXStreamProcessor |
| Access | Constructor and Description |
|---|---|
| public | StAXStreamOutputter(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, StAXStreamProcessor Format#getRawFormat()The XMLOutputProcessor to delegate output to. If null the
StAXStreamOutputter will use the default XMLOutputProcessor. processor)This will create an |
| public | StAXStreamOutputter()
This will create an |
| public | StAXStreamOutputter(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 | StAXStreamOutputter(StAXStreamProcessor
The XMLOutputProcessor to delegate output to. If null the
StAXStreamOutputter will use the default XMLOutputProcessor. processor)This will create an |
| Modifier and Type | Method and Description |
|---|---|
| public StAXStreamOutputter | |
| public Format | Returns: the current Format instance used by this StAXStreamOutputter.Returns the current format in use by the StAXStreamOutputter. |
| public StAXStreamProcessor | Returns: the current XMLOutputProcessor instance.Returns the current XMLOutputProcessor instance in use by the StAXStreamOutputter. |
| public final void | output(Document
Document to format.XMLStreamWriter to use.This will print the |
| public final void | output(DocType
DocType to output.XMLStreamWriter to use.Print out the |
| public final void | output(Element
Element to output.XMLStreamWriter to use.Print out an |
| public final void | output(List<? extends Content>
List of nodes.XMLStreamWriter to use.This will handle printing out a list of nodes. |
| public final void | output(CDATA
CDATA to output.XMLStreamWriter to use.Print out a |
| public final void | |
| public final void | output(Comment
Comment to output.XMLStreamWriter to use.Print out a |
| public final void | output(ProcessingInstruction
ProcessingInstruction to output.XMLStreamWriter to use.Print out a |
| public final void | output(EntityRef
EntityRef to output.XMLStreamWriter to use.Print out an |
| public final void | outputElementContent(Element
Element to output.XMLStreamWriter to use.This will handle printing out an |
| public void | |
| public void | setStAXStreamProcessor(StAXStreamProcessor
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. |
| DEFAULTPROCESSOR | back to summary |
|---|---|
| private static final StAXStreamOutputter. This constant StAXStreamProcessor is used for all non-customised StAXStreamOutputters | |
| myFormat | back to summary |
|---|---|
| private Format myFormat | |
| myProcessor | back to summary |
|---|---|
| private StAXStreamProcessor myProcessor | |
| StAXStreamOutputter | back to summary |
|---|---|
| public StAXStreamOutputter(Format format, StAXStreamProcessor processor) 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
| |
| StAXStreamOutputter | back to summary |
|---|---|
| public StAXStreamOutputter() This will create an | |
| StAXStreamOutputter | back to summary |
|---|---|
| public StAXStreamOutputter(Format format) This will create an Note the format object is cloned internally before use.
| |
| StAXStreamOutputter | back to summary |
|---|---|
| public StAXStreamOutputter(StAXStreamProcessor processor) This will create an
| |
| clone | back to summary |
|---|---|
| public StAXStreamOutputter clone() Overrides java. Returns a cloned copy of this StAXStreamOutputter.
| |
| 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 StAXStreamProcessor getStAXStream() Returns the current XMLOutputProcessor instance in use by the StAXStreamOutputter.
| |
| output | back to summary |
|---|---|
| public final void output(Document doc, XMLStreamWriter 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, XMLStreamWriter out) throws XMLStreamException Print out the
| |
| output | back to summary |
|---|---|
| public final void output(Element element, XMLStreamWriter out) throws XMLStreamException Print out an
| |
| output | back to summary |
|---|---|
| public final void output(List<? extends Content> list, XMLStreamWriter 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, XMLStreamWriter out) throws XMLStreamException Print out a
| |
| output | back to summary |
|---|---|
| public final void output(Text text, XMLStreamWriter out) throws XMLStreamException Print out a
| |
| output | back to summary |
|---|---|
| public final void output(Comment comment, XMLStreamWriter out) throws XMLStreamException Print out a
| |
| output | back to summary |
|---|---|
| public final void output(ProcessingInstruction pi, XMLStreamWriter out) throws XMLStreamException Print out a
| |
| output | back to summary |
|---|---|
| public final void output(EntityRef entity, XMLStreamWriter out) throws XMLStreamException Print out an
| |
| outputElementContent | back to summary |
|---|---|
| public final void outputElementContent(Element element, XMLStreamWriter out) throws XMLStreamException This will handle printing out an
| |
| 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.
| |
| setStAXStreamProcessor | back to summary |
|---|---|
| public void setStAXStreamProcessor(StAXStreamProcessor 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
StAXStreamOutputter#setStAXStreamProcessor(StAXStreamProcessor) method.
| Access | Constructor and Description |
|---|---|
| private |
| DefaultStAXStreamProcessor | back to summary |
|---|---|
| private DefaultStAXStreamProcessor() | |