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
FieldsModifier and TypeFieldDescriptionprotected booleanSet to true to indicate that we need to write'>'to close a start tag.protected final byte[]Buffer of octets for writing.protected intIndex in buffer to write to.protected final OutputStreamFields inherited from class com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl
nsContext, nsUriIndex2prefixIndex, serializer -
Constructor Summary
ConstructorsConstructorDescriptionUTF8XmlOutput(OutputStream out, Encoded[] localNames, CharacterEscapeHandler escapeHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidbeginStartTag(int prefix, String localName) voidbeginStartTag(Name name) Writes a start tag.protected final voidWrites'>'to close the start tag, if necessary.voidendDocument(boolean fragment) Called at the very end.voidvoidvoidprotected final voidvoidvoidstartDocument(XMLSerializer serializer, boolean fragment, int[] nsUriIndex2prefixIndex, NamespaceContextImpl nsContext) Called at the very beginning.voidtext(byte[] data, int dataLen) Writes the given byte[] as base64 encoded binary to the output.final voidtext(int value) voidWrites XML text with character escaping, if necessary.voidWrites XML text with character escaping, if necessary.protected final voidwrite(byte[] b) protected final voidwrite(byte[] b, int start, int length) final voidwrite(int i) Writes one byte directly into the buffer.protected final voidwriteNsDecl(int prefixIndex) Writes a single namespace declaration for the specified prefix.protected voidwriteNsDecls(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:XmlOutputAbstractImplCalled at the very beginning.- Specified by:
startDocumentin interfaceXmlOutput- Overrides:
startDocumentin classXmlOutputAbstractImpl- Parameters:
serializer- theXMLSerializerthat coordinates this whole marshalling episode.fragment- true if we are marshalling a fragment.- Throws:
IOExceptionSAXExceptionXMLStreamException
-
endDocument
Description copied from class:XmlOutputAbstractImplCalled at the very end.- Specified by:
endDocumentin interfaceXmlOutput- Overrides:
endDocumentin classXmlOutputAbstractImpl- Parameters:
fragment- false if we are writing the whole document.- Throws:
IOExceptionSAXExceptionXMLStreamException
-
closeStartTag
Writes'>'to close the start tag, if necessary.- Throws:
IOException
-
beginStartTag
- Specified by:
beginStartTagin interfaceXmlOutput- Specified by:
beginStartTagin classXmlOutputAbstractImpl- Throws:
IOException
-
beginStartTag
Description copied from class:XmlOutputAbstractImplWrites a start tag.At this point
XmlOutputAbstractImpl.nsContextholds namespace declarations needed for this new element.This method is used for writing tags that are indexed.
- Specified by:
beginStartTagin interfaceXmlOutput- Overrides:
beginStartTagin classXmlOutputAbstractImpl- Throws:
IOException
-
writeNsDecls
- Throws:
IOException
-
writeNsDecl
Writes a single namespace declaration for the specified prefix.- Throws:
IOException
-
attribute
- Specified by:
attributein interfaceXmlOutput- Overrides:
attributein classXmlOutputAbstractImpl- Throws:
IOException
-
attribute
- Specified by:
attributein interfaceXmlOutput- Specified by:
attributein classXmlOutputAbstractImpl- Parameters:
prefix- -1 if this attribute does not have a prefix (this handling differs from that of elements.)- Throws:
IOException
-
endStartTag
- Specified by:
endStartTagin interfaceXmlOutput- Specified by:
endStartTagin classXmlOutputAbstractImpl- Throws:
IOException
-
endTag
- Specified by:
endTagin interfaceXmlOutput- Overrides:
endTagin classXmlOutputAbstractImpl- Throws:
IOException
-
endTag
- Specified by:
endTagin interfaceXmlOutput- Specified by:
endTagin classXmlOutputAbstractImpl- Throws:
IOException
-
text
Description copied from interface:XmlOutputWrites 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:XmlOutputWrites 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
textmethod, but it doesn't perform character escaping.- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
flushBuffer
- Throws:
IOException
-