Class UTF8XmlOutput
java.lang.Object
com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl
com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput
- All Implemented Interfaces:
XmlOutput
- Direct Known Subclasses:
C14nXmlOutput
,IndentingUTF8XmlOutput
XmlOutput
implementation specialized for UTF-8.- Author:
- Kohsuke Kawaguchi, Paul Sandoz
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Set to true to indicate that we need to write'>'
to close a start tag.protected final byte[]
Buffer of octets for writing.protected int
Index in buffer to write to.protected final OutputStream
Fields inherited from class com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl
nsContext, nsUriIndex2prefixIndex, serializer
-
Constructor Summary
ConstructorDescriptionUTF8XmlOutput
(OutputStream out, Encoded[] localNames, CharacterEscapeHandler escapeHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
beginStartTag
(int prefix, String localName) void
beginStartTag
(Name name) Writes a start tag.protected final void
Writes'>'
to close the start tag, if necessary.void
endDocument
(boolean fragment) Called at the very end.void
void
void
protected final void
void
void
startDocument
(XMLSerializer serializer, boolean fragment, int[] nsUriIndex2prefixIndex, NamespaceContextImpl nsContext) Called at the very beginning.void
text
(byte[] data, int dataLen) Writes the given byte[] as base64 encoded binary to the output.final void
text
(int value) void
Writes XML text with character escaping, if necessary.void
Writes XML text with character escaping, if necessary.protected final void
write
(byte[] b) protected final void
write
(byte[] b, int start, int length) final void
write
(int i) Writes one byte directly into the buffer.protected final void
writeNsDecl
(int prefixIndex) Writes a single namespace declaration for the specified prefix.protected void
writeNsDecls
(int base)
-
Field Details
-
out
-
octetBuffer
protected final byte[] octetBufferBuffer of octets for writing. -
octetBufferIndex
protected int octetBufferIndexIndex in buffer to write to. -
closeStartTagPending
protected boolean closeStartTagPendingSet to true to indicate that we need to write'>'
to close a start tag. Deferring the write of this char allows us to write"/>"
for empty elements.
-
-
Constructor Details
-
UTF8XmlOutput
- Parameters:
localNames
- local names encoded in UTF-8.
-
-
Method Details
-
setHeader
-
startDocument
public void startDocument(XMLSerializer serializer, boolean fragment, int[] nsUriIndex2prefixIndex, NamespaceContextImpl nsContext) throws IOException, SAXException, XMLStreamException Description copied from class:XmlOutputAbstractImpl
Called at the very beginning.- Specified by:
startDocument
in interfaceXmlOutput
- Overrides:
startDocument
in classXmlOutputAbstractImpl
- Parameters:
serializer
- theXMLSerializer
that coordinates this whole marshalling episode.fragment
- true if we are marshalling a fragment.- Throws:
IOException
SAXException
XMLStreamException
-
endDocument
Description copied from class:XmlOutputAbstractImpl
Called at the very end.- Specified by:
endDocument
in interfaceXmlOutput
- Overrides:
endDocument
in classXmlOutputAbstractImpl
- Parameters:
fragment
- false if we are writing the whole document.- Throws:
IOException
SAXException
XMLStreamException
-
closeStartTag
Writes'>'
to close the start tag, if necessary.- Throws:
IOException
-
beginStartTag
- Specified by:
beginStartTag
in interfaceXmlOutput
- Specified by:
beginStartTag
in classXmlOutputAbstractImpl
- Throws:
IOException
-
beginStartTag
Description copied from class:XmlOutputAbstractImpl
Writes a start tag.At this point
XmlOutputAbstractImpl.nsContext
holds namespace declarations needed for this new element.This method is used for writing tags that are indexed.
- Specified by:
beginStartTag
in interfaceXmlOutput
- Overrides:
beginStartTag
in classXmlOutputAbstractImpl
- Throws:
IOException
-
writeNsDecls
- Throws:
IOException
-
writeNsDecl
Writes a single namespace declaration for the specified prefix.- Throws:
IOException
-
attribute
- Specified by:
attribute
in interfaceXmlOutput
- Overrides:
attribute
in classXmlOutputAbstractImpl
- Throws:
IOException
-
attribute
- Specified by:
attribute
in interfaceXmlOutput
- Specified by:
attribute
in classXmlOutputAbstractImpl
- Parameters:
prefix
- -1 if this attribute does not have a prefix (this handling differs from that of elements.)- Throws:
IOException
-
endStartTag
- Specified by:
endStartTag
in interfaceXmlOutput
- Specified by:
endStartTag
in classXmlOutputAbstractImpl
- Throws:
IOException
-
endTag
- Specified by:
endTag
in interfaceXmlOutput
- Overrides:
endTag
in classXmlOutputAbstractImpl
- Throws:
IOException
-
endTag
- Specified by:
endTag
in interfaceXmlOutput
- Specified by:
endTag
in classXmlOutputAbstractImpl
- Throws:
IOException
-
text
Description copied from interface:XmlOutput
Writes XML text with character escaping, if necessary.- Parameters:
value
- this string can contain characters that might need escaping (such as'&' or '>'
)- Throws:
IOException
-
text
Description copied from interface:XmlOutput
Writes XML text with character escaping, if necessary.- Parameters:
value
- this string can contain characters that might need escaping (such as'&' or '>'
)- Throws:
IOException
-
text
- Throws:
IOException
-
text
Writes the given byte[] as base64 encoded binary to the output.Being defined on this class allows this method to access the buffer directly, which translates to a better performance.
- Throws:
IOException
-
write
Writes one byte directly into the buffer.This method can be used somewhat like the
text
method, but it doesn't perform character escaping.- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
flushBuffer
- Throws:
IOException
-