Top Description Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.runtime.output

public Class UTF8XmlOutput

extends XmlOutputAbstractImpl
Class Inheritance
Known Direct Subclasses
org.glassfish.jaxb.runtime.v2.runtime.output.C14nXmlOutput, org.glassfish.jaxb.runtime.v2.runtime.output.IndentingUTF8XmlOutput
Imports
org.glassfish.jaxb.core.marshaller.CharacterEscapeHandler, org.glassfish.jaxb.runtime.DatatypeConverterImpl, org.glassfish.jaxb.runtime.util.StringBuilderWriter, org.glassfish.jaxb.runtime.v2.runtime.MarshallerImpl, .Name, .XMLSerializer, org.xml.sax.SAXException, javax.xml.stream.XMLStreamException, java.io.IOException, .OutputStream

XmlOutput implementation specialized for UTF-8.
Authors
Kohsuke Kawaguchi, Paul Sandoz

Field Summary

Modifier and TypeField and Description
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private final byte[]
protected boolean
closeStartTagPending

Set to true to indicate that we need to write '>' to close a start tag.

private static final byte[]
private final byte[]
private final byte[]
private CharacterEscapeHandler
private String
private final Encoded[]
localNames

local names encoded in UTF-8.

protected final byte[]
octetBuffer

Buffer of octets for writing.

protected int
octetBufferIndex

Index in buffer to write to.

protected final OutputStream
private int
prefixCount

Of the prefixes, number of filled entries.

private Encoded[]
prefixes

prefixes encoded.

private final Encoded
textBuffer

Temporary buffer used to encode text.

private final byte[]
private final byte[]
private final byte[]
Inherited from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl:
nsContextnsUriIndex2prefixIndexserializer

Constructor Summary

AccessConstructor and Description
public
UTF8XmlOutput(OutputStream out, Encoded[]
local names encoded in UTF-8.
localNames
,
CharacterEscapeHandler escapeHandler)

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
public void
protected final void
closeStartTag()

Writes '>' to close the start tag, if necessary.

private void
doText(String value, boolean isAttribute)

public void
public void
public void
public void
protected final void
private int
public void
setHeader(String header)

public void
public void
text(String value, boolean needSP)

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Writes XML text with character escaping, if necessary.

public void
text(Pcdata value, boolean needSP)

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Writes XML text with character escaping, if necessary.

public final void
text(int value)

public void
text(byte[] data, int dataLen)

Writes the given byte[] as base64 encoded binary to the output.

pack-priv static byte[]
public final void
write(int i)

Writes one byte directly into the buffer.

protected final void
write(byte[] b)

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

private void
private void
writeName(int prefix, String localName)

protected final void
writeNsDecl(int prefixIndex)

Writes a single namespace declaration for the specified prefix.

protected void
writeNsDecls(int base)

private void
writePrefix(int prefix)

Field Detail

_CLOSE_TAGback to summary
private static final byte[] _CLOSE_TAG
_EMPTY_TAGback to summary
private static final byte[] _EMPTY_TAG
_EQUALSback to summary
private static final byte[] _EQUALS
_XML_DECLback to summary
private static final byte[] _XML_DECL
_XMLNS_COLONback to summary
private static final byte[] _XMLNS_COLON
_XMLNS_EQUALSback to summary
private static final byte[] _XMLNS_EQUALS
CLOSE_TAGback to summary
private final byte[] CLOSE_TAG
closeStartTagPendingback to summary
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.

EMPTY_BYTE_ARRAYback to summary
private static final byte[] EMPTY_BYTE_ARRAY
EMPTY_TAGback to summary
private final byte[] EMPTY_TAG
EQUALSback to summary
private final byte[] EQUALS
escapeHandlerback to summary
private CharacterEscapeHandler escapeHandler
localNamesback to summary
private final Encoded[] localNames

local names encoded in UTF-8. All entries are pre-filled.

octetBufferback to summary
protected final byte[] octetBuffer

Buffer of octets for writing.

octetBufferIndexback to summary
protected int octetBufferIndex

Index in buffer to write to.

outback to summary
protected final OutputStream out
prefixCountback to summary
private int prefixCount

Of the prefixes, number of filled entries. This is almost the same as NamespaceContextImpl#count(), except that it allows us to handle contextual in-scope namespace bindings correctly.

prefixesback to summary
private Encoded[] prefixes

prefixes encoded.

textBufferback to summary
private final Encoded textBuffer

Temporary buffer used to encode text.

XML_DECLback to summary
private final byte[] XML_DECL
XMLNS_COLONback to summary
private final byte[] XMLNS_COLON
XMLNS_EQUALSback to summary
private final byte[] XMLNS_EQUALS

Constructor Detail

UTF8XmlOutputback to summary
public UTF8XmlOutput(OutputStream out, Encoded[] localNames, CharacterEscapeHandler escapeHandler)
Parameters
localNames:Encoded[]

local names encoded in UTF-8.

Method Detail

attributeback to summary
public void attribute(Name name, String value) throws IOException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.attribute.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.attribute.

Annotations
@Override
attributeback to summary
public void attribute(int prefix, String localName, String value) throws IOException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.attribute.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.attribute.

Annotations
@Override
beginStartTagback to summary
public void beginStartTag(int prefix, String localName) throws IOException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.beginStartTag.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.beginStartTag.

Annotations
@Override
beginStartTagback to summary
public void beginStartTag(Name name) throws IOException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.beginStartTag.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.beginStartTag.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.beginStartTag.

Writes a start tag.

At this point nsContext holds namespace declarations needed for this new element.

This method is used for writing tags that are indexed.

Annotations
@Override
closeStartTagback to summary
protected final void closeStartTag() throws IOException

Writes '>' to close the start tag, if necessary.

doTextback to summary
private void doText(String value, boolean isAttribute) throws IOException
endDocumentback to summary
public void endDocument(boolean fragment) throws IOException, SAXException, XMLStreamException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.endDocument.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.endDocument.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.endDocument.

Called at the very end.

Annotations
@Override
endStartTagback to summary
public void endStartTag() throws IOException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.endStartTag.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.endStartTag.

Annotations
@Override
endTagback to summary
public void endTag(Name name) throws IOException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.endTag.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.endTag.

Annotations
@Override
endTagback to summary
public void endTag(int prefix, String localName) throws IOException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.endTag.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.endTag.

Annotations
@Override
flushBufferback to summary
protected final void flushBuffer() throws IOException
pushNsDeclsback to summary
private int pushNsDecls()
setHeaderback to summary
public void setHeader(String header)
startDocumentback to summary
public void startDocument(XMLSerializer serializer, boolean fragment, int[] nsUriIndex2prefixIndex, NamespaceContextImpl nsContext) throws IOException, SAXException, XMLStreamException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.startDocument.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.startDocument.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.startDocument.

Called at the very beginning.

Annotations
@Override
textback to summary
public void text(String value, boolean needSP) throws IOException

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Writes XML text with character escaping, if necessary.

Annotations
@Override
textback to summary
public void text(Pcdata value, boolean needSP) throws IOException

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Writes XML text with character escaping, if necessary.

Annotations
@Override
textback to summary
public final void text(int value) throws IOException
textback to summary
public void text(byte[] data, int dataLen) throws IOException

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.

Annotations
@SuppressWarnings:deprecation
toBytesback to summary
pack-priv static byte[] toBytes(String s)
writeback to summary
public final void write(int i) throws IOException

Writes one byte directly into the buffer.

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

writeback to summary
protected final void write(byte[] b) throws IOException
writeback to summary
protected final void write(byte[] b, int start, int length) throws IOException
writeNameback to summary
private void writeName(Name name) throws IOException
writeNameback to summary
private void writeName(int prefix, String localName) throws IOException
writeNsDeclback to summary
protected final void writeNsDecl(int prefixIndex) throws IOException

Writes a single namespace declaration for the specified prefix.

writeNsDeclsback to summary
protected void writeNsDecls(int base) throws IOException
writePrefixback to summary
private void writePrefix(int prefix) throws IOException