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

public final Class FastInfosetStreamWriterOutput

extends XMLStreamWriterOutput
Class Inheritance
Imports
org.glassfish.jaxb.core.marshaller.NoEscapeHandler, org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl, .Name, .XMLSerializer, org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.Base64Data, com.sun.xml.fastinfoset.EncodingConstants, com.sun.xml.fastinfoset.stax.StAXDocumentSerializer, jakarta.xml.bind.JAXBContext, org.jvnet.fastinfoset.VocabularyApplicationData, org.xml.sax.SAXException, javax.xml.stream.XMLStreamException, java.io.IOException, java.util.Arrays, .Collection, .Map, .WeakHashMap

XmlOutput for StAXDocumentSerializer.

This class is responsible for managing the indexing of elements, attributes and local names that are known to JAXB by way of the JAXBContext (generated from JAXB beans or schema). The pre-encoded UTF-8 representations of known local names are also utilized.

The lookup of elements, attributes and local names with respect to a context is very efficient. It relies on an incrementing base line so that look up is performed in O(1) time and only uses static memory. When the base line reaches a point where integer overflow will occur the arrays and base line are reset (such an event is rare and will have little impact on performance).

A weak map of JAXB contexts to optimized tables for attributes, elements and local names is utilized and stored on the LowLevel StAX serializer. Thus, optimized serializing can work other multiple serializing of JAXB beans using the same LowLevel StAX serializer instance. This approach works best when JAXB contexts are only created once per schema or JAXB beans (which is the recommended practice as the creation JAXB contexts are expensive, they are thread safe and can be reused).

Author
[email protected]

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
FastInfosetStreamWriterOutput.AppData

Holder of JAXB contexts -> tables.

pack-priv static class
FastInfosetStreamWriterOutput.TablesPerJAXBContext

Holder for the optimzed element, attribute and local name tables.

Field Summary

Modifier and TypeField and Description
private final StAXDocumentSerializer
private final Encoded[]
private final FastInfosetStreamWriterOutput.TablesPerJAXBContext
Inherited from org.glassfish.jaxb.runtime.v2.runtime.output.XMLStreamWriterOutput:
buf

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
text(Pcdata value, boolean needsSeparatingWhitespace)

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XMLStreamWriterOutput.text.

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

Writes XML text with character escaping, if necessary.

public void
text(String value, boolean needsSeparatingWhitespace)

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XMLStreamWriterOutput.text.

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

Writes XML text with character escaping, if necessary.

private void
writeLiteral(int type, Name name, String prefix, String namespaceURI)

Inherited from org.glassfish.jaxb.runtime.v2.runtime.output.XMLStreamWriterOutput:
create

Field Detail

fioutback to summary
private final StAXDocumentSerializer fiout
localNamesback to summary
private final Encoded[] localNames
tablesback to summary
private final FastInfosetStreamWriterOutput.TablesPerJAXBContext tables

Constructor Detail

FastInfosetStreamWriterOutputback to summary
public FastInfosetStreamWriterOutput(StAXDocumentSerializer out, JAXBContextImpl context)

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

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

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

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
beginStartTagback to summary
public void beginStartTag(int prefix, String localName) throws IOException

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

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

Annotations
@Override
beginStartTagWithNamespacesback to summary
public void beginStartTagWithNamespaces(Name name) throws IOException
endDocumentback to summary
public void endDocument(boolean fragment) throws IOException, SAXException, XMLStreamException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XMLStreamWriterOutput.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

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XMLStreamWriterOutput.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

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

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

Annotations
@Override
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.XMLStreamWriterOutput.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(Pcdata value, boolean needsSeparatingWhitespace) throws IOException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XMLStreamWriterOutput.text.

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(String value, boolean needsSeparatingWhitespace) throws IOException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XMLStreamWriterOutput.text.

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
writeLiteralback to summary
private void writeLiteral(int type, Name name, String prefix, String namespaceURI) throws IOException
org.glassfish.jaxb.runtime.v2.runtime.output back to summary

pack-priv final Class FastInfosetStreamWriterOutput.AppData

extends Object
implements VocabularyApplicationData
Class Inheritance
  • java.lang.Object
  • org.glassfish.jaxb.runtime.v2.runtime.output.FastInfosetStreamWriterOutput.AppData
All Implemented Interfaces
org.jvnet.fastinfoset.VocabularyApplicationData

Holder of JAXB contexts -> tables.

An instance will be registered with the StAXDocumentSerializer.

Field Summary

Modifier and TypeField and Description
pack-priv final Collection<FastInfosetStreamWriterOutput.TablesPerJAXBContext>
pack-priv final Map<JAXBContext, FastInfosetStreamWriterOutput.TablesPerJAXBContext>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

collectionOfContextsback to summary
pack-priv final Collection<FastInfosetStreamWriterOutput.TablesPerJAXBContext> collectionOfContexts
contextsback to summary
pack-priv final Map<JAXBContext, FastInfosetStreamWriterOutput.TablesPerJAXBContext> contexts

Constructor Detail

AppDataback to summary
pack-priv AppData()

Method Detail

clearback to summary
public void clear()

Implements org.jvnet.fastinfoset.VocabularyApplicationData.clear.

Clear all the tables.

Annotations
@Override
org.glassfish.jaxb.runtime.v2.runtime.output back to summary

pack-priv final Class FastInfosetStreamWriterOutput.TablesPerJAXBContext

extends Object
Class Inheritance
  • java.lang.Object
  • org.glassfish.jaxb.runtime.v2.runtime.output.FastInfosetStreamWriterOutput.TablesPerJAXBContext

Holder for the optimzed element, attribute and local name tables.

Field Summary

Modifier and TypeField and Description
pack-priv final int[]
pack-priv final int[]
pack-priv final int[]
pack-priv int
indexOffset

The offset of the index

pack-priv final int[]
pack-priv int
maxIndex

The the maximum known value of an index

pack-priv boolean
requiresClear

True if the tables require clearing

Constructor Summary

AccessConstructor and Description
pack-priv
TablesPerJAXBContext(JAXBContextImpl
the JAXB context.
context
,
int
the initial index offset to calculate the maximum possible index
initialIndexOffset
)

Create a new set of tables for a JAXB context.

Method Summary

Modifier and TypeMethod and Description
private void
clear(int[] array)

private void
public void
clearOrResetTables(int
the initial index offset to calculate the maximum possible index
intialIndexOffset
)

Clear or reset the tables.

public void
incrementMaxIndexValue()

Increment the maximum know index value

The indexes are preserved.

public void
requireClearTables()

Require that tables are cleared.

private void
reset(int[] array)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeIndexesback to summary
pack-priv final int[] attributeIndexes
elementIndexesback to summary
pack-priv final int[] elementIndexes
elementIndexPrefixesback to summary
pack-priv final int[] elementIndexPrefixes
indexOffsetback to summary
pack-priv int indexOffset

The offset of the index

localNameIndexesback to summary
pack-priv final int[] localNameIndexes
maxIndexback to summary
pack-priv int maxIndex

The the maximum known value of an index

requiresClearback to summary
pack-priv boolean requiresClear

True if the tables require clearing

Constructor Detail

TablesPerJAXBContextback to summary
pack-priv TablesPerJAXBContext(JAXBContextImpl context, int initialIndexOffset)

Create a new set of tables for a JAXB context.

Parameters
context:JAXBContextImpl

the JAXB context.

initialIndexOffset:int

the initial index offset to calculate the maximum possible index

Method Detail

clearback to summary
private void clear(int[] array)
clearAllback to summary
private void clearAll()
clearOrResetTablesback to summary
public void clearOrResetTables(int intialIndexOffset)

Clear or reset the tables.

Parameters
intialIndexOffset:int

the initial index offset to calculate the maximum possible index

incrementMaxIndexValueback to summary
public void incrementMaxIndexValue()

Increment the maximum know index value

The indexes are preserved.

requireClearTablesback to summary
public void requireClearTables()

Require that tables are cleared.

resetback to summary
private void reset(int[] array)
resetAllback to summary
private void resetAll()