The StAXStreamReader 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().
There is only one method that exposes
a JDOM Document as a StAX Stream.
output(Document)
If changing the Format settings are insufficient for your output
needs you can customise this StAXStreamReader further by setting a different
StAXStreamReaderProcessor with the
setStAXAsStreamProcessor(StAXStreamReaderProcessor) method or an appropriate
constructor. A fully-enabled Abstract class
AbstractStAXStreamReaderProcessor 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 | StAXStreamReader.DefaultStAXAsStreamProcessor
Create a final and static instance of the StAXStreamReaderProcessor The final part is important because it improves performance. |
| Modifier and Type | Field and Description |
|---|---|
| private static final StAXStreamReader. | DEFAULTPROCESSOR
This constant XMLOutputProcessor is used for all non-customised XMLOutputters |
| private Format | |
| private StAXStreamReaderProcessor |
| Access | Constructor and Description |
|---|---|
| public | StAXStreamReader(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 XMLOutputter. A null input
format indicates that XMLOutputter should use the default
format, StAXStreamReaderProcessor Format#getRawFormat()The XMLOutputProcessor to delegate output to. If null the
XMLOutputter will use the default XMLOutputProcessor. processor)This will create an |
| public | StAXStreamReader()
This will create an |
| public | StAXStreamReader(StAXStreamReader
the XMLOutputter to clone that)This will create an |
| public | StAXStreamReader(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 XMLOutputter. A null input
format indicates that XMLOutputter should use the default
format)Format#getRawFormat()This will create an |
| public | StAXStreamReader(StAXStreamReaderProcessor
The XMLOutputProcessor to delegate output to. If null the
XMLOutputter will use the default XMLOutputProcessor. processor)This will create an |
| Modifier and Type | Method and Description |
|---|---|
| public StAXStreamReader | |
| public Format | Returns: the current Format instance used by this XMLOutputter.Returns the current format in use by the XMLOutputter. |
| public StAXStreamReaderProcessor | Returns: the current XMLOutputProcessor instance.Returns the current XMLOutputProcessor instance in use by the StAXStreamReader. |
| public final XMLStreamReader | |
| public void | |
| public void | setStAXAsStreamProcessor(StAXStreamReaderProcessor
the new XMLOutputProcesor to use for output processor)Sets a new StAXStreamReaderProcessor instance for this StAXStreamReader. |
| public String | Returns: a string listing the settings for this XMLOutputter instanceOverrides java. |
| DEFAULTPROCESSOR | back to summary |
|---|---|
| private static final StAXStreamReader. This constant XMLOutputProcessor is used for all non-customised XMLOutputters | |
| myFormat | back to summary |
|---|---|
| private Format myFormat | |
| myProcessor | back to summary |
|---|---|
| private StAXStreamReaderProcessor myProcessor | |
| StAXStreamReader | back to summary |
|---|---|
| public StAXStreamReader(Format format, StAXStreamReaderProcessor processor) This will create an Note the format object is cloned internally before use. If you
want to modify the Format after constructing the XMLOutputter you can
modify the Format instance
| |
| StAXStreamReader | back to summary |
|---|---|
| public StAXStreamReader() This will create an | |
| StAXStreamReader | back to summary |
|---|---|
| public StAXStreamReader(StAXStreamReader that) This will create an
| |
| StAXStreamReader | back to summary |
|---|---|
| public StAXStreamReader(Format format) This will create an Note the format object is cloned internally before use.
| |
| StAXStreamReader | back to summary |
|---|---|
| public StAXStreamReader(StAXStreamReaderProcessor processor) This will create an
| |
| clone | back to summary |
|---|---|
| public StAXStreamReader clone() Overrides java. Returns a cloned copy of this XMLOutputter.
| |
| getFormat | back to summary |
|---|---|
| public Format getFormat() Returns the current format in use by the XMLOutputter. Note the Format object returned is not a clone of the one used internally, thus, an XMLOutputter instance is able to have its Format changed by changing the settings on the Format instance returned by this method.
| |
| getStAXAsStreamProcessor | back to summary |
|---|---|
| public StAXStreamReaderProcessor getStAXAsStreamProcessor() Returns the current XMLOutputProcessor instance in use by the StAXStreamReader.
| |
| output | back to summary |
|---|---|
| public final XMLStreamReader output(Document doc) This will expose the
| |
| setFormat | back to summary |
|---|---|
| public void setFormat(Format newFormat) Sets the new format logic for the XMLOutputter. Note the Format object is cloned internally before use.
| |
| setStAXAsStreamProcessor | back to summary |
|---|---|
| public void setStAXAsStreamProcessor(StAXStreamReaderProcessor processor) Sets a new StAXStreamReaderProcessor instance for this StAXStreamReader. 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 XMLOutputter instance. | |
The JDOM user can change the actual XMLOutputProcessor with the
StAXStreamReader#setStAXAsStreamProcessor(StAXStreamReaderProcessor) method.
| Access | Constructor and Description |
|---|---|
| private |
| DefaultStAXAsStreamProcessor | back to summary |
|---|---|
| private DefaultStAXAsStreamProcessor() | |