public final class StAXStreamReader
extends java.lang.Object
implements java.lang.Cloneable
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.
Constructor and Description |
---|
StAXStreamReader()
|
StAXStreamReader(Format format)
This will create an
XMLOutputter with the specified format
characteristics. |
StAXStreamReader(Format format,
StAXStreamReaderProcessor processor)
This will create an
XMLOutputter with the specified format
characteristics. |
StAXStreamReader(StAXStreamReader that)
This will create an
XMLOutputter with the same
customisations set in the given XMLOutputter instance. |
StAXStreamReader(StAXStreamReaderProcessor processor)
This will create an
XMLOutputter with the specified
XMLOutputProcessor. |
Modifier and Type | Method and Description |
---|---|
StAXStreamReader |
clone()
Returns a cloned copy of this XMLOutputter.
|
Format |
getFormat()
Returns the current format in use by the XMLOutputter.
|
StAXStreamReaderProcessor |
getStAXAsStreamProcessor()
Returns the current XMLOutputProcessor instance in use by the
StAXStreamReader.
|
javax.xml.stream.XMLStreamReader |
output(Document doc)
This will expose the
as a StAX XMLStreamReader. |
void |
setFormat(Format newFormat)
Sets the new format logic for the XMLOutputter.
|
void |
setStAXAsStreamProcessor(StAXStreamReaderProcessor processor)
Sets a new StAXStreamReaderProcessor instance for this StAXStreamReader.
|
java.lang.String |
toString()
Return a string listing of the settings for this XMLOutputter instance.
|
public StAXStreamReader(Format format, StAXStreamReaderProcessor processor)
XMLOutputter
with the specified format
characteristics.
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 getFormat()
returns.
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.getRawFormat()
processor
- The XMLOutputProcessor to delegate output to. If null the
XMLOutputter will use the default XMLOutputProcessor.public StAXStreamReader()
public StAXStreamReader(StAXStreamReader that)
XMLOutputter
with the same
customisations set in the given XMLOutputter
instance. Note
that XMLOutputter two = one.clone();
would work equally
well.that
- the XMLOutputter to clonepublic StAXStreamReader(Format format)
XMLOutputter
with the specified format
characteristics.
Note: the format object is cloned internally before use.
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.getRawFormat()
public StAXStreamReader(StAXStreamReaderProcessor processor)
XMLOutputter
with the specified
XMLOutputProcessor.processor
- The XMLOutputProcessor to delegate output to. If null the
XMLOutputter will use the default XMLOutputProcessor.public void setFormat(Format newFormat)
newFormat
- the format to use for subsequent outputgetFormat()
public Format getFormat()
public StAXStreamReaderProcessor getStAXAsStreamProcessor()
public void setStAXAsStreamProcessor(StAXStreamReaderProcessor processor)
processor
- the new XMLOutputProcesor to use for outputpublic final javax.xml.stream.XMLStreamReader output(Document doc)
Document
as a StAX XMLStreamReader.doc
- Document
to format.java.lang.NullPointerException
- if the specified content is null.public StAXStreamReader clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2021 Jason Hunter, Brett McLaughlin. All Rights Reserved.