com.sun.xml.bind.v2.runtime.output

Class UTF8XmlOutput

public class UTF8XmlOutput extends XmlOutputAbstractImpl

XmlOutput implementation specialized for UTF-8.
Field Summary
protected booleancloseStartTagPending
Set to true to indicate that we need to write '>' to close a start tag.
protected byte[]octetBuffer
Buffer of octets for writing.
protected intoctetBufferIndex
Index in buffer to write to.
protected OutputStreamout
Constructor Summary
UTF8XmlOutput(OutputStream out, Encoded[] localNames, CharacterEscapeHandler escapeHandler)
Method Summary
voidattribute(Name name, String value)
voidattribute(int prefix, String localName, String value)
voidbeginStartTag(int prefix, String localName)
voidbeginStartTag(Name name)
protected voidcloseStartTag()
Writes '>' to close the start tag, if necessary.
voidendDocument(boolean fragment)
voidendStartTag()
voidendTag(Name name)
voidendTag(int prefix, String localName)
protected voidflushBuffer()
voidsetHeader(String header)
voidstartDocument(XMLSerializer serializer, boolean fragment, int[] nsUriIndex2prefixIndex, NamespaceContextImpl nsContext)
voidtext(String value, boolean needSP)
voidtext(Pcdata value, boolean needSP)
voidtext(int value)
voidtext(byte[] data, int dataLen)
Writes the given byte[] as base64 encoded binary to the output.
static byte[]toBytes(String s)
voidwrite(int i)
Writes one byte directly into the buffer.
protected voidwrite(byte[] b)
protected voidwrite(byte[] b, int start, int length)
protected voidwriteNsDecl(int prefixIndex)
Writes a single namespace declaration for the specified prefix.
protected voidwriteNsDecls(int base)

Field Detail

closeStartTagPending

protected boolean closeStartTagPending
Set 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.

octetBuffer

protected final byte[] octetBuffer
Buffer of octets for writing.

octetBufferIndex

protected int octetBufferIndex
Index in buffer to write to.

out

protected final OutputStream out

Constructor Detail

UTF8XmlOutput

public UTF8XmlOutput(OutputStream out, Encoded[] localNames, CharacterEscapeHandler escapeHandler)

Parameters: localNames local names encoded in UTF-8.

Method Detail

attribute

void attribute(Name name, String value)

attribute

public void attribute(int prefix, String localName, String value)

beginStartTag

public void beginStartTag(int prefix, String localName)

beginStartTag

void beginStartTag(Name name)

closeStartTag

protected final void closeStartTag()
Writes '>' to close the start tag, if necessary.

endDocument

void endDocument(boolean fragment)

endStartTag

public void endStartTag()

endTag

void endTag(Name name)

endTag

public void endTag(int prefix, String localName)

flushBuffer

protected final void flushBuffer()

setHeader

public void setHeader(String header)

startDocument

void startDocument(XMLSerializer serializer, boolean fragment, int[] nsUriIndex2prefixIndex, NamespaceContextImpl nsContext)

text

public void text(String value, boolean needSP)

text

public void text(Pcdata value, boolean needSP)

text

public final void text(int value)

text

public void text(byte[] data, int dataLen)
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.

toBytes

static byte[] toBytes(String s)

write

public final void write(int i)
Writes one byte directly into the buffer.

This method can be used somewhat like the {@code text} method, but it doesn't perform character escaping.

write

protected final void write(byte[] b)

write

protected final void write(byte[] b, int start, int length)

writeNsDecl

protected final void writeNsDecl(int prefixIndex)
Writes a single namespace declaration for the specified prefix.

writeNsDecls

protected void writeNsDecls(int base)