Enum OutputType
- All Implemented Interfaces:
Serializable
,Comparable<OutputType>
,java.lang.constant.Constable
Creates
XMLStreamWriter
from a given output. This enumeration allows to analyze the output type
only once before to create as many instances of XMLStreamWriter
as needed for that output.
The enumeration order is the preference order (i.e. we will test if the object already implements the
XMLStreamWriter
interface before to test for OutputStream
, Writer
, etc.).- Since:
- 0.8
- Version:
- 0.8
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe output is an instance of Java I/OWriter
.The output is an instance of STAXXMLEventWriter
.The output is an instance of DOMNode
.The output is an instance of XMLResult
, which is itself a wrapper around another kind of result.The output is an instance of SAXContentHandler
.The output is already an instance ofXMLStreamWriter
.The output is an instance of Java I/OOutputStream
. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
OutputType
(Class<?> outputType, InputType inputType) Creates a new enumeration for the given type of output. -
Method Summary
Modifier and TypeMethodDescription(package private) abstract XMLStreamWriter
create
(StaxDataStore ds, Object s) Creates a XML writer for the given output.(package private) static OutputType
Returns aWriterFactory
for the given output type.(package private) Closeable
Returns a reader for the data written by the given writer, ornull
if we cannot read the data.static OutputType
Returns the enum constant of this type with the specified name.static OutputType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
STAX
The output is already an instance ofXMLStreamWriter
. That output is returned directly. -
STREAM
The output is an instance of Java I/OOutputStream
. Encoding depends on the data store character encoding. -
CHARACTERS
The output is an instance of Java I/OWriter
. -
RESULT
The output is an instance of XMLResult
, which is itself a wrapper around another kind of result. -
NODE
The output is an instance of DOMNode
. -
SAX
The output is an instance of SAXContentHandler
. -
EVENT
The output is an instance of STAXXMLEventWriter
.
-
-
Field Details
-
outputType
The kind of output that this enumeration can handle. -
inputType
The input type from the same framework (StAX, DOM, etc) than this output type.
-
-
Constructor Details
-
OutputType
Creates a new enumeration for the given type of output.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
create
Creates a XML writer for the given output.- Parameters:
ds
- the data store for which to create writer instances.s
- the output stream or the storage object (URL, etc).- Returns:
- the XML writer.
- Throws:
XMLStreamException
- if the XML writer creation failed.
-
snapshot
Returns a reader for the data written by the given writer, ornull
if we cannot read the data. If non-null, the value returned by this method is a snapshot of the given stream content, i.e. changes in the output stream will not affect the returned input stream or reader. In particular, contrarily toIOUtilities.toInputStream(AutoCloseable)
this method does not invalidate the output stream.The returned input can be used by
inputType
.- Parameters:
s
- the output from which to get the data that we wrote.- Returns:
- the input for the data written by the given stream, or
null
if none.
-
forType
Returns aWriterFactory
for the given output type. Thetype
argument given to this method shall be the class of thes
argument to be given increate(StaxDataStore, Object)
calls.- Parameters:
type
- the type of the output stream or storage object (URL, etc).- Returns:
- a factory for the given stream or storage type, or
null
if the given type is not recognized.
-