public class StAXWriter extends XMLWriterNamespaceBase implements IExtensibleWriter
Modifier and Type | Field and Description |
---|---|
private javax.xml.stream.XMLStreamWriter |
m_writer
Target for parse event stream.
|
m_prefixes, m_uris
Constructor and Description |
---|
StAXWriter(StAXWriter base,
java.lang.String[] uris)
Copy constructor.
|
StAXWriter(java.lang.String[] uris)
Constructor.
|
StAXWriter(java.lang.String[] uris,
javax.xml.stream.XMLStreamWriter wrtr)
Constructor with writer supplied.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(int index,
java.lang.String name,
java.lang.String value)
Add attribute to current open start tag.
|
void |
close()
Close document output.
|
void |
closeEmptyTag()
Close the current open start tag as an empty element.
|
void |
closeStartTag()
Close the current open start tag.
|
IXMLWriter |
createChildWriter(java.lang.String[] uris)
Create a child writer instance to be used for a separate binding.
|
protected void |
defineNamespace(int index,
java.lang.String prefix)
Report to subclass that namespace has been defined.
|
void |
endTag(int index,
java.lang.String name)
Generate end tag.
|
void |
flush()
Flush document output.
|
void |
indent()
Request output indent.
|
void |
init()
Initialize writer.
|
void |
setIndentSpaces(int count,
java.lang.String newline,
char indent)
Set nesting indentation.
|
void |
setWriter(javax.xml.stream.XMLStreamWriter wrtr)
Set StAX writer.
|
void |
startTagClosed(int index,
java.lang.String name)
Generate closed start tag.
|
void |
startTagNamespaces(int index,
java.lang.String name,
int[] nums,
java.lang.String[] prefs)
Generate start tag for element with namespaces.
|
void |
startTagOpen(int index,
java.lang.String name)
Generate open start tag.
|
protected void |
undefineNamespace(int index)
Report to subclass that namespace has been undefined.
|
void |
writeCData(java.lang.String text)
Write CDATA text to document.
|
void |
writeComment(java.lang.String text)
Write comment to document.
|
void |
writeDocType(java.lang.String name,
java.lang.String sys,
java.lang.String pub,
java.lang.String subset)
Write DOCTYPE declaration to document.
|
void |
writeEntityRef(java.lang.String name)
Write entity reference to document.
|
void |
writePI(java.lang.String target,
java.lang.String data)
Write processing instruction to document.
|
void |
writeTextContent(java.lang.String text)
Write ordinary character data text content to document.
|
void |
writeXMLDecl(java.lang.String version,
java.lang.String encoding,
java.lang.String standalone)
Write XML declaration to document.
|
decrementNesting, getExtensionNamespaces, getNamespaceCount, getNamespacePrefix, getNamespaces, getNamespaceUri, getNestingDepth, getPrefixIndex, growArray, incrementNesting, internalNamespacePrefix, internalNamespaceUri, internalSetUris, openNamespaces, popExtensionNamespaces, popTranslationTable, pushExtensionNamespaces, pushTranslationTable, reset, shrinkArray, translateNamespace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getExtensionNamespaces, getNamespaceCount, getNamespacePrefix, getNamespaces, getNamespaceUri, getNestingDepth, getPrefixIndex, openNamespaces, popExtensionNamespaces, popTranslationTable, pushExtensionNamespaces, pushTranslationTable, reset
private javax.xml.stream.XMLStreamWriter m_writer
public StAXWriter(java.lang.String[] uris)
uris
- ordered array of URIs for namespaces used in document (must
be constant; the value in position 0 must always be the empty string "",
and the value in position 1 must always be the XML namespace
"http://www.w3.org/XML/1998/namespace")public StAXWriter(java.lang.String[] uris, javax.xml.stream.XMLStreamWriter wrtr)
uris
- ordered array of URIs for namespaces used in document (must
be constant; the value in position 0 must always be the empty string "",
and the value in position 1 must always be the XML namespace
"http://www.w3.org/XML/1998/namespace")wrtr
- StAX writer for parse event outputpublic StAXWriter(StAXWriter base, java.lang.String[] uris)
base
- existing instanceuris
- ordered array of URIs for namespaces used in documentpublic void init()
init
in interface IXMLWriter
public void setWriter(javax.xml.stream.XMLStreamWriter wrtr)
wrtr
- StAX writer for parse event outputprotected void defineNamespace(int index, java.lang.String prefix) throws java.io.IOException
XMLWriterNamespaceBase
defineNamespace
in class XMLWriterNamespaceBase
index
- post-translation namespace URI index numberprefix
- prefix used for namespacejava.io.IOException
- if error writing to documentprotected void undefineNamespace(int index)
XMLWriterNamespaceBase
undefineNamespace
in class XMLWriterNamespaceBase
index
- post-translation namespace URI index numberpublic void setIndentSpaces(int count, java.lang.String newline, char indent)
IXMLWriter
setIndentSpaces
in interface IXMLWriter
count
- number of character to indent per level, or disable
indentation if negative (zero means new line only)newline
- sequence of characters used for a line ending
(null
means use the single character '\n')indent
- whitespace character used for indentationpublic void writeXMLDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone) throws java.io.IOException
IXMLWriter
writeXMLDecl
in interface IXMLWriter
version
- XML version textencoding
- text for encoding attribute (unspecified if
null
)standalone
- text for standalone attribute (unspecified if
null
)java.io.IOException
- on error writing to documentpublic void startTagOpen(int index, java.lang.String name) throws java.io.IOException
IXMLWriter
IXMLWriter.closeStartTag()
call.startTagOpen
in interface IXMLWriter
index
- namespace URI index numbername
- unqualified element namejava.io.IOException
- on error writing to documentpublic void startTagNamespaces(int index, java.lang.String name, int[] nums, java.lang.String[] prefs) throws java.io.IOException
IXMLWriter
startTagNamespaces
in interface IXMLWriter
index
- namespace URI index numbername
- element namenums
- array of namespace indexes defined by this element (must
be constant, reference is kept until end of element)prefs
- array of namespace prefixes mapped by this element (no
null
values, use "" for default namespace declaration)java.io.IOException
- on error writing to documentpublic void addAttribute(int index, java.lang.String name, java.lang.String value) throws java.io.IOException
IXMLWriter
IXMLWriter.startTagOpen(int, java.lang.String)
and before the corresponding call to IXMLWriter.closeStartTag()
.addAttribute
in interface IXMLWriter
index
- namespace URI index numbername
- unqualified attribute namevalue
- text value for attributejava.io.IOException
- on error writing to documentpublic void closeStartTag() throws java.io.IOException
IXMLWriter
IXMLWriter.startTagOpen(int, java.lang.String)
.closeStartTag
in interface IXMLWriter
java.io.IOException
- on error writing to documentpublic void closeEmptyTag() throws java.io.IOException
IXMLWriter
IXMLWriter.startTagOpen(int, java.lang.String)
.closeEmptyTag
in interface IXMLWriter
java.io.IOException
- on error writing to documentpublic void startTagClosed(int index, java.lang.String name) throws java.io.IOException
IXMLWriter
startTagClosed
in interface IXMLWriter
index
- namespace URI index numbername
- unqualified element namejava.io.IOException
- on error writing to documentpublic void endTag(int index, java.lang.String name) throws java.io.IOException
IXMLWriter
endTag
in interface IXMLWriter
index
- namespace URI index numbername
- unqualified element namejava.io.IOException
- on error writing to documentpublic void writeTextContent(java.lang.String text) throws java.io.IOException
IXMLWriter
writeTextContent
in interface IXMLWriter
text
- content value text (must not be null
)java.io.IOException
- on error writing to documentpublic void writeCData(java.lang.String text) throws java.io.IOException
IXMLWriter
writeCData
in interface IXMLWriter
text
- content value text (must not be null
)java.io.IOException
- on error writing to documentpublic void writeComment(java.lang.String text) throws java.io.IOException
IXMLWriter
writeComment
in interface IXMLWriter
text
- comment text (must not be null
)java.io.IOException
- on error writing to documentpublic void writeEntityRef(java.lang.String name) throws java.io.IOException
IXMLWriter
writeEntityRef
in interface IXMLWriter
name
- entity name (must not be null
)java.io.IOException
- on error writing to documentpublic void writeDocType(java.lang.String name, java.lang.String sys, java.lang.String pub, java.lang.String subset) throws java.io.IOException
IXMLWriter
writeDocType
in interface IXMLWriter
name
- root element namesys
- system ID (null
if none, must be
non-null
for public ID to be used)pub
- public ID (null
if none)subset
- internal subset (null
if none)java.io.IOException
- on error writing to documentpublic void writePI(java.lang.String target, java.lang.String data) throws java.io.IOException
IXMLWriter
writePI
in interface IXMLWriter
target
- processing instruction target name (must not be
null
)data
- processing instruction data (must not be null
)java.io.IOException
- on error writing to documentpublic void indent() throws java.io.IOException
IXMLWriter
indent
in interface IXMLWriter
java.io.IOException
- on error writing to documentpublic void flush() throws java.io.IOException
IXMLWriter
flush
in interface IXMLWriter
java.io.IOException
- on error writing to documentpublic void close() throws java.io.IOException
IXMLWriter
close
in interface IXMLWriter
java.io.IOException
- on error writing to documentpublic IXMLWriter createChildWriter(java.lang.String[] uris)
createChildWriter
in interface IExtensibleWriter
uris
- ordered array of URIs for namespaces used in document
(see StAXWriter(String[])
)