Class StAXStreamReader
- All Implemented Interfaces:
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:
- For pretty-print output, use
.Format.getPrettyFormat()
- For whitespace-normalised output, use
.Format.getCompactFormat()
- For unmodified-format output, use
.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.
- Since:
- JDOM 2.1.0
- Author:
- Rolf Lear
-
Constructor Summary
ConstructorsConstructorDescriptionStAXStreamReader
(Format format) This will create anXMLOutputter
with the specified format characteristics.StAXStreamReader
(Format format, StAXStreamReaderProcessor processor) This will create anXMLOutputter
with the specified format characteristics.This will create anXMLOutputter
with the same customisations set in the givenXMLOutputter
instance.StAXStreamReader
(StAXStreamReaderProcessor processor) This will create anXMLOutputter
with the specified XMLOutputProcessor. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a cloned copy of this XMLOutputter.Returns the current format in use by the XMLOutputter.Returns the current XMLOutputProcessor instance in use by the StAXStreamReader.final XMLStreamReader
This will expose the
as a StAX XMLStreamReader.Document
void
Sets the new format logic for the XMLOutputter.void
Sets a new StAXStreamReaderProcessor instance for this StAXStreamReader.toString()
Return a string listing of the settings for this XMLOutputter instance.
-
Constructor Details
-
StAXStreamReader
This will create anXMLOutputter
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.- Parameters:
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 defaultFormat.getRawFormat()
processor
- The XMLOutputProcessor to delegate output to. If null the XMLOutputter will use the default XMLOutputProcessor.
-
StAXStreamReader
public StAXStreamReader() -
StAXStreamReader
This will create anXMLOutputter
with the same customisations set in the givenXMLOutputter
instance. Note thatXMLOutputter two = one.clone();
would work equally well.- Parameters:
that
- the XMLOutputter to clone
-
StAXStreamReader
This will create anXMLOutputter
with the specified format characteristics.Note: the format object is cloned internally before use.
- Parameters:
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 defaultFormat.getRawFormat()
-
StAXStreamReader
This will create anXMLOutputter
with the specified XMLOutputProcessor.- Parameters:
processor
- The XMLOutputProcessor to delegate output to. If null the XMLOutputter will use the default XMLOutputProcessor.
-
-
Method Details
-
setFormat
Sets the new format logic for the XMLOutputter. Note the Format object is cloned internally before use.- Parameters:
newFormat
- the format to use for subsequent output- See Also:
-
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.- Returns:
- the current Format instance used by this XMLOutputter.
-
getStAXAsStreamProcessor
Returns the current XMLOutputProcessor instance in use by the StAXStreamReader.- Returns:
- the current XMLOutputProcessor instance.
-
setStAXAsStreamProcessor
Sets a new StAXStreamReaderProcessor instance for this StAXStreamReader. Note the processor object is expected to be thread-safe.- Parameters:
processor
- the new XMLOutputProcesor to use for output
-
output
This will expose the
as a StAX XMLStreamReader.Document
- Parameters:
doc
-Document
to format.- Returns:
- The XMLStreamReader representing the input Document.
- Throws:
NullPointerException
- if the specified content is null.
-
clone
Returns a cloned copy of this XMLOutputter. -
toString
Return a string listing of the settings for this XMLOutputter instance.
-