Package com.sun.xml.fastinfoset.stax
Class StAXDocumentSerializer
java.lang.Object
org.xml.sax.helpers.DefaultHandler
com.sun.xml.fastinfoset.Encoder
com.sun.xml.fastinfoset.stax.StAXDocumentSerializer
- All Implemented Interfaces:
XMLStreamWriter,FastInfosetSerializer,LowLevelFastInfosetStreamWriter,ContentHandler,DTDHandler,EntityResolver,ErrorHandler
- Direct Known Subclasses:
FastInfosetWriter
public class StAXDocumentSerializer
extends Encoder
implements XMLStreamWriter, LowLevelFastInfosetStreamWriter
The Fast Infoset StAX serializer.
Instantiate this serializer to serialize a fast infoset document in accordance with the StAX API.
More than one fast infoset document may be encoded to the
OutputStream.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]List of attributes qnames and values defined in the current element.protected intprotected StringLocal name of current element.protected StringPrefix of current element.protected StringNamespace of current element.protected Stringprotected booleanThis flag indicates when there is a pending start element event.protected booleanThis flag indicates if the current element is empty.protected StAXManagerprotected String[]List of namespaces defined in the current element.protected intprotected NamespaceContextImplementationMapping between uris and prefixes.protected boolean[]protected intFields inherited from class com.sun.xml.fastinfoset.Encoder
_b, _characterEncodingSchemeSystemDefault, _charBuffer, _markIndex, _octetBuffer, _octetBufferIndex, _s, _terminate, _v, _vData, attributeValueMapTotalCharactersConstraint, CHARACTER_ENCODING_SCHEME_SYSTEM_PROPERTY, characterContentChunkMapTotalCharactersConstraint, maxAttributeValueSize, maxCharacterContentChunkSize, minAttributeValueSize, minCharacterContentChunkSizeFields inherited from interface org.jvnet.fastinfoset.FastInfosetSerializer
ATTRIBUTE_VALUE_MAP_MEMORY_CONSTRAINT, BUFFER_SIZE_PROPERTY, CHARACTER_CONTENT_CHUNK_MAP_MEMORY_CONSTRAINT, EXTERNAL_VOCABULARIES_PROPERTY, IGNORE_COMMENTS_FEATURE, IGNORE_DTD_FEATURE, IGNORE_PROCESSING_INSTRUCTIONS_FEATURE, IGNORE_WHITE_SPACE_TEXT_CONTENT_FEATURE, MAX_ATTRIBUTE_VALUE_SIZE, MAX_CHARACTER_CONTENT_CHUNK_SIZE, MIN_ATTRIBUTE_VALUE_SIZE, MIN_CHARACTER_CONTENT_CHUNK_SIZE, REGISTERED_ENCODING_ALGORITHMS_PROPERTY, UTF_16BE, UTF_8 -
Constructor Summary
ConstructorsConstructorDescriptionStAXDocumentSerializer(OutputStream outputStream) StAXDocumentSerializer(OutputStream outputStream, StAXManager manager) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected voidencodeTerminationAndCurrentElement(boolean terminateAfter) voidflush()final intGet the current index that was applied to an [local name] of an Element or Attribute Information Item.final intGet the next index to apply to an Attribute Information Item.final intGet the next index to apply to an Element Information Item.final intGet the next index to apply to an [local name] of an Element or Attribute Information Item.getProperty(String name) final voidInitiate low level writing of an element fragment.voidreset()Reset the encoder for reuse encoding another XML infoset.voidvoidsetEncoding(String encoding) voidsetManager(StAXManager manager) voidsetNamespaceContext(NamespaceContext context) Sets the current namespace context for prefix and uri bindings.voidvoidwriteAttribute(String localName, String value) voidwriteAttribute(String namespaceURI, String localName, String value) voidwriteAttribute(String prefix, String namespaceURI, String localName, String value) voidwriteCData(String text) voidwriteCharacters(char[] text, int start, int len) voidwriteCharacters(String text) voidwriteComment(String data) voidwriteDefaultNamespace(String namespaceURI) voidvoidwriteEmptyElement(String localName) voidwriteEmptyElement(String namespaceURI, String localName) voidwriteEmptyElement(String prefix, String localName, String namespaceURI) voidvoidvoidwriteEntityRef(String name) final booleanwriteLowLevelAttribute(String prefix, String namespaceURI, String localName) Write an attribute.final voidwriteLowLevelAttributeIndexed(int index) final voidfinal voidfinal voidfinal voidfinal voidwriteLowLevelNamespace(String prefix, String namespaceName) final voidwriteLowLevelOctets(byte[] octets, int length) final voidfinal booleanwriteLowLevelStartElement(int type, String prefix, String localName, String namespaceURI) Write the start of an element.final voidwriteLowLevelStartElementIndexed(int type, int index) final voidwriteLowLevelStartNameLiteral(int type, String prefix, byte[] utf8LocalName, String namespaceURI) final voidwriteLowLevelStartNameLiteral(int type, String prefix, int localNameIndex, String namespaceURI) final voidfinal voidfinal voidwriteLowLevelText(char[] text, int length) final voidwriteLowLevelText(String text) voidwriteNamespace(String prefix, String namespaceURI) voidwriteOctets(byte[] b, int start, int len) voidwriteProcessingInstruction(String target) voidwriteProcessingInstruction(String target, String data) voidvoidwriteStartDocument(String version) voidwriteStartDocument(String encoding, String version) voidwriteStartElement(String localName) voidwriteStartElement(String namespaceURI, String localName) voidwriteStartElement(String prefix, String localName, String namespaceURI) Methods inherited from class com.sun.xml.fastinfoset.Encoder
canAddAttributeToTable, canAddCharacterContentToTable, encodeAIIBuiltInAlgorithmData, encodeAIIObjectAlgorithmData, encodeAIIOctetAlgorithmData, encodeAlphabetCharacters, encodeAttributeQualifiedNameOnSecondBit, encodeCharacters, encodeCharactersNoClone, encodeCIIBuiltInAlgorithmData, encodeCIIBuiltInAlgorithmDataAsCDATA, encodeCIIObjectAlgorithmData, encodeCIIOctetAlgorithmData, encodeComment, encodeCommentNoClone, encodeDateTimeFourBitCharacters, encodeDateTimeNonIdentifyingStringOnFirstBit, encodeDocumentTermination, encodeDocumentTypeDeclaration, encodeElementQualifiedNameOnThirdBit, encodeElementTermination, encodeFourBitCharacters, encodeHeader, encodeIdentifyingNonEmptyStringOnFirstBit, encodeInitialVocabulary, encodeLiteralAttributeQualifiedNameOnSecondBit, encodeLiteralElementQualifiedNameOnThirdBit, encodeNamespaceAttribute, encodeNonEmptyCharacterStringOnFifthBit, encodeNonEmptyCharacterStringOnFifthBit, encodeNonEmptyCharacterStringOnSeventhBit, encodeNonEmptyFourBitCharacterString, encodeNonEmptyFourBitCharacterStringOnSeventhBit, encodeNonEmptyNBitCharacterStringOnSeventhBit, encodeNonEmptyOctetStringOnSecondBit, encodeNonEmptyUTF8StringAsOctetString, encodeNonEmptyUTF8StringAsOctetString, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnFirstBit, encodeNonIdentifyingStringOnThirdBit, encodeNonIdentifyingStringOnThirdBit, encodeNonIdentifyingStringOnThirdBit, encodeNonZeroInteger, encodeNonZeroIntegerOnFourthBit, encodeNonZeroIntegerOnSecondBitFirstBitOne, encodeNonZeroIntegerOnSecondBitFirstBitZero, encodeNonZeroIntegerOnThirdBit, encodeNonZeroOctetStringLength, encodeNonZeroOctetStringLengthOnFifthBit, encodeNonZeroOctetStringLengthOnSecondBit, encodeNonZeroOctetStringLengthOnSenventhBit, encodeNumericFourBitCharacters, encodeNumericNonIdentifyingStringOnFirstBit, encodeProcessingInstruction, encodeTermination, encodeUtf16String, encodeUtf16String, encodeUTF8String, encodeUTF8String, getAttributeValueMapMemoryLimit, getCharacterContentChunkMapMemoryLimit, getCharacterEncodingScheme, getIgnoreComments, getIgnoreDTD, getIgnoreProcesingInstructions, getIgnoreWhiteSpaceTextContent, getMaxAttributeValueSize, getMaxCharacterContentChunkSize, getMinAttributeValueSize, getMinCharacterContentChunkSize, getPrefixFromQualifiedName, getRegisteredEncodingAlgorithms, getVocabularyApplicationData, hasMark, isAttributeValueLengthMatchesLimit, isCharacterContentChunkLengthMatchesLimit, isWhiteSpace, isWhiteSpace, mark, resetMark, setAttributeValueMapMemoryLimit, setCharacterContentChunkMapMemoryLimit, setCharacterEncodingScheme, setExternalVocabulary, setIgnoreComments, setIgnoreDTD, setIgnoreProcesingInstructions, setIgnoreWhiteSpaceTextContent, setMaxAttributeValueSize, setMaxCharacterContentChunkSize, setMinAttributeValueSize, setMinCharacterContentChunkSize, setOutputStream, setRegisteredEncodingAlgorithms, setVocabulary, setVocabularyApplicationData, write, write, writeMethods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
-
Field Details
-
_manager
-
_encoding
-
_currentLocalName
Local name of current element. -
_currentUri
Namespace of current element. -
_currentPrefix
Prefix of current element. -
_inStartElement
protected boolean _inStartElementThis flag indicates when there is a pending start element event. -
_isEmptyElement
protected boolean _isEmptyElementThis flag indicates if the current element is empty. -
_attributesArray
List of attributes qnames and values defined in the current element. -
_attributesArrayIndex
protected int _attributesArrayIndex -
_nsSupportContextStack
protected boolean[] _nsSupportContextStack -
_stackCount
protected int _stackCount -
_nsContext
Mapping between uris and prefixes. -
_namespacesArray
List of namespaces defined in the current element. -
_namespacesArrayIndex
protected int _namespacesArrayIndex
-
-
Constructor Details
-
StAXDocumentSerializer
public StAXDocumentSerializer() -
StAXDocumentSerializer
-
StAXDocumentSerializer
-
-
Method Details
-
reset
public void reset()Description copied from class:EncoderReset the encoder for reuse encoding another XML infoset.- Specified by:
resetin interfaceFastInfosetSerializer- Overrides:
resetin classEncoder
-
writeStartDocument
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndDocument
- Specified by:
writeEndDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
close
- Specified by:
closein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
flush
- Specified by:
flushin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException - Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException - Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndElement
- Specified by:
writeEndElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException - Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException - Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeNamespace
- Specified by:
writeNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDefaultNamespace
- Specified by:
writeDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeComment
- Specified by:
writeCommentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCData
- Specified by:
writeCDatain interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDTD
- Specified by:
writeDTDin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEntityRef
- Specified by:
writeEntityRefin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setPrefix
- Specified by:
setPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setDefaultNamespace
- Specified by:
setDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setNamespaceContext
Sets the current namespace context for prefix and uri bindings. This context becomes the root namespace context for writing and will replace the current root namespace context. Subsequent calls to setPrefix and setDefaultNamespace will bind namespaces using the context passed to the method as the root context for resolving namespaces. This method may only be called once at the start of the document. It does not cause the namespaces to be declared. If a namespace URI to prefix mapping is found in the namespace context it is treated as declared and the prefix may be used by the StreamWriter.- Specified by:
setNamespaceContextin interfaceXMLStreamWriter- Parameters:
context- the namespace context to use for this writer, may not be null- Throws:
XMLStreamException
-
getNamespaceContext
- Specified by:
getNamespaceContextin interfaceXMLStreamWriter
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamWriter- Throws:
IllegalArgumentException
-
setManager
-
setEncoding
-
writeOctets
- Throws:
XMLStreamException
-
encodeTerminationAndCurrentElement
- Throws:
XMLStreamException
-
initiateLowLevelWriting
Description copied from interface:LowLevelFastInfosetStreamWriterInitiate low level writing of an element fragment.This method must be invoked before other low level method.
- Specified by:
initiateLowLevelWritingin interfaceLowLevelFastInfosetStreamWriter- Throws:
XMLStreamException
-
getNextElementIndex
public final int getNextElementIndex()Description copied from interface:LowLevelFastInfosetStreamWriterGet the next index to apply to an Element Information Item.This will increment the next obtained index such that:
i = w.getNextElementIndex(); j = w.getNextElementIndex(); i == j + 1;
- Specified by:
getNextElementIndexin interfaceLowLevelFastInfosetStreamWriter- Returns:
- the index.
-
getNextAttributeIndex
public final int getNextAttributeIndex()Description copied from interface:LowLevelFastInfosetStreamWriterGet the next index to apply to an Attribute Information Item. This will increment the next obtained index such that:i = w.getNextAttributeIndex(); j = w.getNextAttributeIndex(); i == j + 1;
- Specified by:
getNextAttributeIndexin interfaceLowLevelFastInfosetStreamWriter- Returns:
- the index.
-
getLocalNameIndex
public final int getLocalNameIndex()Description copied from interface:LowLevelFastInfosetStreamWriterGet the current index that was applied to an [local name] of an Element or Attribute Information Item.- Specified by:
getLocalNameIndexin interfaceLowLevelFastInfosetStreamWriter- Returns:
- the index.
-
getNextLocalNameIndex
public final int getNextLocalNameIndex()Description copied from interface:LowLevelFastInfosetStreamWriterGet the next index to apply to an [local name] of an Element or Attribute Information Item. This will increment the next obtained index such that:i = w.getNextLocalNameIndex(); j = w.getNextLocalNameIndex(); i == j + 1;
- Specified by:
getNextLocalNameIndexin interfaceLowLevelFastInfosetStreamWriter- Returns:
- the index.
-
writeLowLevelTerminationAndMark
- Specified by:
writeLowLevelTerminationAndMarkin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelStartElementIndexed
- Specified by:
writeLowLevelStartElementIndexedin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelStartElement
public final boolean writeLowLevelStartElement(int type, String prefix, String localName, String namespaceURI) throws IOException Description copied from interface:LowLevelFastInfosetStreamWriterWrite the start of an element.- Specified by:
writeLowLevelStartElementin interfaceLowLevelFastInfosetStreamWriter- Returns:
- true if element is indexed, otherwise false.
- Throws:
IOException
-
writeLowLevelStartNamespaces
- Specified by:
writeLowLevelStartNamespacesin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelNamespace
- Specified by:
writeLowLevelNamespacein interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelEndNamespaces
- Specified by:
writeLowLevelEndNamespacesin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelStartAttributes
- Specified by:
writeLowLevelStartAttributesin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelAttributeIndexed
- Specified by:
writeLowLevelAttributeIndexedin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelAttribute
public final boolean writeLowLevelAttribute(String prefix, String namespaceURI, String localName) throws IOException Description copied from interface:LowLevelFastInfosetStreamWriterWrite an attribute.- Specified by:
writeLowLevelAttributein interfaceLowLevelFastInfosetStreamWriter- Returns:
- true if attribute is indexed, otherwise false.
- Throws:
IOException
-
writeLowLevelAttributeValue
- Specified by:
writeLowLevelAttributeValuein interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelStartNameLiteral
public final void writeLowLevelStartNameLiteral(int type, String prefix, byte[] utf8LocalName, String namespaceURI) throws IOException - Specified by:
writeLowLevelStartNameLiteralin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelStartNameLiteral
public final void writeLowLevelStartNameLiteral(int type, String prefix, int localNameIndex, String namespaceURI) throws IOException - Specified by:
writeLowLevelStartNameLiteralin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelEndStartElement
- Specified by:
writeLowLevelEndStartElementin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelEndElement
- Specified by:
writeLowLevelEndElementin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelText
- Specified by:
writeLowLevelTextin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelText
- Specified by:
writeLowLevelTextin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-
writeLowLevelOctets
- Specified by:
writeLowLevelOctetsin interfaceLowLevelFastInfosetStreamWriter- Throws:
IOException
-