public final class SMOutputFactory extends Object
SMOutputDocument
and SMRootFragment
) instances,
which are roots (global for documents, or local for fragments)
of output content.
Note about life-cycle of root-level outputter objects: once
you are done with a root-level outputter, you MUST
call SMRootFragment.closeRoot()
method to ensure that
all content is flushed to the underlying stream writer
Factory also has convenience method(s) for accessing a shared
global instance of a default XMLOutputFactory
.
Constructor and Description |
---|
SMOutputFactory(XMLOutputFactory staxF) |
Modifier and Type | Method and Description |
---|---|
SMOutputDocument |
createOutputDocument(File f)
Factory method for constructing output object that represents
a complete xml document including xml declaration and will
contain root element plus other optional elements (doctype
declaration, comment(s), PI(s)).
|
SMOutputDocument |
createOutputDocument(OutputStream out)
Factory method for constructing output object that represents
a complete xml document including xml declaration and will
contain root element plus other optional elements (doctype
declaration, comment(s), PI(s)).
|
SMOutputDocument |
createOutputDocument(Writer w)
Factory method for constructing output object that represents
a complete xml document including xml declaration and will
contain root element plus other optional elements (doctype
declaration, comment(s), PI(s)).
|
static SMOutputDocument |
createOutputDocument(XMLStreamWriter sw)
Factory method for constructing output object that represents
a complete xml document including xml declaration and will
contain root element plus other optional elements (doctype
declaration, comment(s), PI(s)).
|
static SMOutputDocument |
createOutputDocument(XMLStreamWriter sw,
String version,
String encoding,
boolean standAlone)
Factory method for constructing output object that represents
a complete xml document including xml declaration and will
contain root element plus other optional elements (doctype
declaration, comment(s), PI(s)).
|
SMRootFragment |
createOutputFragment(File resultFile)
Factory method for constructing output object that represents
root-level of an xml fragment; container that can contain
non-element markup (comments, PIs), textual data and
zero or more elements.
|
SMRootFragment |
createOutputFragment(OutputStream out)
Factory method for constructing output object that represents
root-level of an xml fragment; container that can contain
non-element markup (comments, PIs), textual data and
zero or more elements.
|
SMRootFragment |
createOutputFragment(Writer w)
Factory method for constructing output object that represents
root-level of an xml fragment; container that can contain
non-element markup (comments, PIs), textual data and
zero or more elements.
|
static SMRootFragment |
createOutputFragment(XMLStreamWriter sw)
Factory method for constructing output object that represents
root-level of an xml fragment; container that can contain
non-element markup (comments, PIs), textual data and
zero or more elements.
|
org.codehaus.stax2.XMLStreamWriter2 |
createStax2Writer(File f)
Method for constructing Stax stream writer to write xml content
to specified file.
|
org.codehaus.stax2.XMLStreamWriter2 |
createStax2Writer(OutputStream out)
Method for constructing Stax stream writer to write xml content
to specified output stream.
|
org.codehaus.stax2.XMLStreamWriter2 |
createStax2Writer(Writer w)
Method for constructing Stax stream writer to write xml content
using specified Writer.
|
static SMOutputFactory |
getGlobalSMOutputFactory()
Convenience method that will get a lazily constructed shared
SMOutputFactory instance. |
static XMLOutputFactory |
getGlobalXMLOutputFactory()
Convenience method that will get a lazily constructed shared
XMLOutputFactory instance. |
XMLOutputFactory |
getStaxFactory()
Method for accessing Stax output factory this StaxMate
output factory was constructed with.
|
public SMOutputFactory(XMLOutputFactory staxF)
public XMLOutputFactory getStaxFactory()
public static SMOutputDocument createOutputDocument(XMLStreamWriter sw) throws XMLStreamException
Note that after you have completed output using the
result object (and its children), you must call
SMRootFragment.closeRoot()
method to ensure that
all the content is properly output via underlying stream writer.
Note: you can not use this method to construct fragments,
for this purpose check out createOutputFragment(javax.xml.stream.XMLStreamWriter)
.
XMLStreamException
public SMOutputDocument createOutputDocument(File f) throws XMLStreamException
Note that after you have completed output using the
result object (and its children), you must call
SMRootFragment.closeRoot()
method to ensure that
all the content is properly output via underlying stream writer.
Note: you can not use this method to construct fragments,
for this purpose check out createOutputFragment(javax.xml.stream.XMLStreamWriter)
.
XMLStreamException
public SMOutputDocument createOutputDocument(OutputStream out) throws XMLStreamException
Note that after you have completed output using the
result object (and its children), you must call
SMRootFragment.closeRoot()
method to ensure that
all the content is properly output via underlying stream writer.
Note: you can not use this method to construct fragments,
for this purpose check out createOutputFragment(javax.xml.stream.XMLStreamWriter)
.
XMLStreamException
public SMOutputDocument createOutputDocument(Writer w) throws XMLStreamException
Note that after you have completed output using the
result object (and its children), you must call
SMRootFragment.closeRoot()
method to ensure that
all the content is properly output via underlying stream writer.
Note: you can not use this method to construct fragments,
for this purpose check out createOutputFragment(javax.xml.stream.XMLStreamWriter)
.
XMLStreamException
public static SMOutputDocument createOutputDocument(XMLStreamWriter sw, String version, String encoding, boolean standAlone) throws XMLStreamException
Note: you can not use this method to construct fragments,
for this purpose check out createOutputFragment(javax.xml.stream.XMLStreamWriter)
.
XMLStreamException
public static SMRootFragment createOutputFragment(XMLStreamWriter sw) throws XMLStreamException
Note that after you have completed output using the
result object (and its children), you must call
SMRootFragment.closeRoot()
method to ensure that
all the content is properly output via underlying stream writer.
Note: you can not use this method to construct actual documents,
for this purpose check out createOutputDocument(javax.xml.stream.XMLStreamWriter)
.
XMLStreamException
public SMRootFragment createOutputFragment(File resultFile) throws XMLStreamException
Note that after you have completed output using the
result object (and its children), you must call
SMRootFragment.closeRoot()
method to ensure that
all the content is properly output via underlying stream writer.
Note: you can not use this method to construct actual documents,
for this purpose check out createOutputDocument(javax.xml.stream.XMLStreamWriter)
.
resultFile
- file xml contents get written toXMLStreamException
public SMRootFragment createOutputFragment(OutputStream out) throws XMLStreamException
Note that after you have completed output using the
result object (and its children), you must call
SMRootFragment.closeRoot()
method to ensure that
all the content is properly output via underlying stream writer.
Note: you can not use this method to construct actual documents,
for this purpose check out createOutputDocument(javax.xml.stream.XMLStreamWriter)
.
out
- Output stream through with xml contents get writtenXMLStreamException
public SMRootFragment createOutputFragment(Writer w) throws XMLStreamException
Note that after you have completed output using the
result object (and its children), you must call
SMRootFragment.closeRoot()
method to ensure that
all the content is properly output via underlying stream writer.
Note: you can not use this method to construct actual documents,
for this purpose check out createOutputDocument(javax.xml.stream.XMLStreamWriter)
.
w
- Writer used for writing xml contentsXMLStreamException
public org.codehaus.stax2.XMLStreamWriter2 createStax2Writer(File f) throws XMLStreamException
Encoding used will be UTF-8.
XMLStreamException
public org.codehaus.stax2.XMLStreamWriter2 createStax2Writer(OutputStream out) throws XMLStreamException
Encoding used will be UTF-8.
XMLStreamException
public org.codehaus.stax2.XMLStreamWriter2 createStax2Writer(Writer w) throws XMLStreamException
Encoding used will be UTF-8.
XMLStreamException
public static SMOutputFactory getGlobalSMOutputFactory() throws FactoryConfigurationError
SMOutputFactory
instance. Instance is built using
similarly shared XMLOutputFactory
instance (which
is accessed using getGlobalXMLOutputFactory()
).
See notes on getGlobalXMLOutputFactory()
for limitations
on when (if ever) you should use this method.
Note that this single(ton) instance is global to the class loader
that loaded SMOutputFactory
(and usually hence
global to a single JVM instance).
FactoryConfigurationError
- If there are problems with
configuration of Stax output factory (most likely because
there is no implementation available)public static XMLOutputFactory getGlobalXMLOutputFactory() throws XMLStreamException
XMLOutputFactory
instance. Note that this instance
should only be used iff:
XMLStreamException
Copyright © 2013 FasterXML. All Rights Reserved.