com.sun.xml.fastinfoset.stax
Class StAXDocumentSerializer

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.sun.xml.fastinfoset.Encoder
          extended by com.sun.xml.fastinfoset.stax.StAXDocumentSerializer
All Implemented Interfaces:
javax.xml.stream.XMLStreamWriter, FastInfosetSerializer, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class StAXDocumentSerializer
extends Encoder
implements javax.xml.stream.XMLStreamWriter

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
protected  String[] _attributesArray
          List of attributes qnames and values defined in the current element.
protected  int _attributesArrayIndex
           
protected  String _currentLocalName
          Local name of current element.
protected  String _currentPrefix
          Prefix of current element.
protected  String _currentUri
          Namespace of current element.
protected  String _encoding
           
protected  boolean _inStartElement
          This flag indicates when there is a pending start element event.
protected  boolean _isEmptyElement
          This flag indicates if the current element is empty.
protected  StAXManager _manager
           
protected  String[] _namespacesArray
          List of namespaces defined in the current element.
protected  int _namespacesArrayIndex
           
protected  NamespaceContextImplementation _nsContext
          Mapping between uris and prefixes.
protected  boolean[] _nsSupportContextStack
           
protected  int _stackCount
           
 
Fields inherited from class com.sun.xml.fastinfoset.Encoder
_b, _characterEncodingSchemeSystemDefault, _charBuffer, _markIndex, _octetBuffer, _octetBufferIndex, _s, _terminate, _v, _vData, attributeValueMapTotalCharactersConstraint, attributeValueSizeConstraint, CHARACTER_ENCODING_SCHEME_SYSTEM_PROPERTY, characterContentChunkMapTotalCharactersConstraint, characterContentChunkSizeContraint, DATE_TIME_CHARACTERS_TABLE, NUMERIC_CHARACTERS_TABLE
 
Fields inherited from interface org.jvnet.fastinfoset.FastInfosetSerializer
ATTRIBUTE_VALUE_MAP_MEMORY_CONSTRAINT, ATTRIBUTE_VALUE_SIZE_CONSTRAINT, BUFFER_SIZE_PROPERTY, CHARACTER_CONTENT_CHUNK_MAP_MEMORY_CONSTRAINT, CHARACTER_CONTENT_CHUNK_SIZE_CONSTRAINT, EXTERNAL_VOCABULARIES_PROPERTY, IGNORE_COMMENTS_FEATURE, IGNORE_DTD_FEATURE, IGNORE_PROCESSING_INSTRUCTIONS_FEATURE, IGNORE_WHITE_SPACE_TEXT_CONTENT_FEATURE, REGISTERED_ENCODING_ALGORITHMS_PROPERTY, UTF_16BE, UTF_8
 
Constructor Summary
StAXDocumentSerializer()
           
StAXDocumentSerializer(OutputStream outputStream)
           
StAXDocumentSerializer(OutputStream outputStream, StAXManager manager)
           
 
Method Summary
 void close()
           
protected  void encodeTerminationAndCurrentElement(boolean terminateAfter)
           
 void flush()
           
 NamespaceContext getNamespaceContext()
           
 String getPrefix(String uri)
           
 Object getProperty(String name)
           
 void reset()
          Reset the encoder for reuse encoding another XML infoset.
 void setDefaultNamespace(String uri)
           
 void setEncoding(String encoding)
           
 void setManager(StAXManager manager)
           
 void setNamespaceContext(NamespaceContext context)
          Sets the current namespace context for prefix and uri bindings.
 void setPrefix(String prefix, String uri)
           
 void writeAttribute(String localName, String value)
           
 void writeAttribute(String namespaceURI, String localName, String value)
           
 void writeAttribute(String prefix, String namespaceURI, String localName, String value)
           
 void writeCData(String data)
           
 void writeCharacters(char[] text, int start, int len)
           
 void writeCharacters(String text)
           
 void writeComment(String data)
           
 void writeDefaultNamespace(String namespaceURI)
           
 void writeDTD(String dtd)
           
 void writeEmptyElement(String localName)
           
 void writeEmptyElement(String namespaceURI, String localName)
           
 void writeEmptyElement(String prefix, String localName, String namespaceURI)
           
 void writeEndDocument()
           
 void writeEndElement()
           
 void writeEntityRef(String name)
           
 void writeNamespace(String prefix, String namespaceURI)
           
 void writeOctets(byte[] b, int start, int len)
           
 void writeProcessingInstruction(String target)
           
 void writeProcessingInstruction(String target, String data)
           
 void writeStartDocument()
           
 void writeStartDocument(String version)
           
 void writeStartDocument(String encoding, String version)
           
 void writeStartElement(String localName)
           
 void writeStartElement(String namespaceURI, String localName)
           
 void writeStartElement(String prefix, String localName, String namespaceURI)
           
 
Methods inherited from class com.sun.xml.fastinfoset.Encoder
encodeAIIBuiltInAlgorithmData, encodeAIIObjectAlgorithmData, encodeAIIOctetAlgorithmData, encodeAlphabetCharacters, encodeAttributeQualifiedNameOnSecondBit, encodeCharacters, encodeCharactersNoClone, encodeCIIBuiltInAlgorithmData, encodeCIIBuiltInAlgorithmDataAsCDATA, encodeCIIObjectAlgorithmData, encodeCIIOctetAlgorithmData, encodeComment, encodeCommentNoClone, 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, encodeProcessingInstruction, encodeTermination, encodeUtf16String, encodeUtf16String, encodeUTF8String, encodeUTF8String, getAttributeValueMapMemoryLimit, getAttributeValueSizeLimit, getCharacterContentChunkMapMemoryLimit, getCharacterContentChunkSizeLimit, getCharacterEncodingScheme, getIgnoreComments, getIgnoreDTD, getIgnoreProcesingInstructions, getIgnoreWhiteSpaceTextContent, getPrefixFromQualifiedName, getRegisteredEncodingAlgorithms, getVocabularyApplicationData, hasMark, isAttributeValueLengthMathesLimit, isCharacterContentChunkLengthMathesLimit, isWhiteSpace, isWhiteSpace, mark, resetMark, setAttributeValueMapMemoryLimit, setAttributeValueSizeLimit, setCharacterContentChunkMapMemoryLimit, setCharacterContentChunkSizeLimit, setCharacterEncodingScheme, setExternalVocabulary, setIgnoreComments, setIgnoreDTD, setIgnoreProcesingInstructions, setIgnoreWhiteSpaceTextContent, setOutputStream, setRegisteredEncodingAlgorithms, setVocabulary, setVocabularyApplicationData, write, write, write
 
Methods 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_manager

protected StAXManager _manager

_encoding

protected String _encoding

_currentLocalName

protected String _currentLocalName
Local name of current element.


_currentUri

protected String _currentUri
Namespace of current element.


_currentPrefix

protected String _currentPrefix
Prefix of current element.


_inStartElement

protected boolean _inStartElement
This flag indicates when there is a pending start element event.


_isEmptyElement

protected boolean _isEmptyElement
This flag indicates if the current element is empty.


_attributesArray

protected String[] _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

protected NamespaceContextImplementation _nsContext
Mapping between uris and prefixes.


_namespacesArray

protected String[] _namespacesArray
List of namespaces defined in the current element.


_namespacesArrayIndex

protected int _namespacesArrayIndex
Constructor Detail

StAXDocumentSerializer

public StAXDocumentSerializer()

StAXDocumentSerializer

public StAXDocumentSerializer(OutputStream outputStream)

StAXDocumentSerializer

public StAXDocumentSerializer(OutputStream outputStream,
                              StAXManager manager)
Method Detail

reset

public void reset()
Description copied from class: Encoder
Reset the encoder for reuse encoding another XML infoset.

Specified by:
reset in interface FastInfosetSerializer
Overrides:
reset in class Encoder

writeStartDocument

public void writeStartDocument()
                        throws javax.xml.stream.XMLStreamException
Specified by:
writeStartDocument in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeStartDocument

public void writeStartDocument(String version)
                        throws javax.xml.stream.XMLStreamException
Specified by:
writeStartDocument in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeStartDocument

public void writeStartDocument(String encoding,
                               String version)
                        throws javax.xml.stream.XMLStreamException
Specified by:
writeStartDocument in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeEndDocument

public void writeEndDocument()
                      throws javax.xml.stream.XMLStreamException
Specified by:
writeEndDocument in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

close

public void close()
           throws javax.xml.stream.XMLStreamException
Specified by:
close in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

flush

public void flush()
           throws javax.xml.stream.XMLStreamException
Specified by:
flush in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeStartElement

public void writeStartElement(String localName)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeStartElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeStartElement

public void writeStartElement(String namespaceURI,
                              String localName)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeStartElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeStartElement

public void writeStartElement(String prefix,
                              String localName,
                              String namespaceURI)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeStartElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeEmptyElement

public void writeEmptyElement(String localName)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeEmptyElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeEmptyElement

public void writeEmptyElement(String namespaceURI,
                              String localName)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeEmptyElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeEmptyElement

public void writeEmptyElement(String prefix,
                              String localName,
                              String namespaceURI)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeEmptyElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeEndElement

public void writeEndElement()
                     throws javax.xml.stream.XMLStreamException
Specified by:
writeEndElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeAttribute

public void writeAttribute(String localName,
                           String value)
                    throws javax.xml.stream.XMLStreamException
Specified by:
writeAttribute in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeAttribute

public void writeAttribute(String namespaceURI,
                           String localName,
                           String value)
                    throws javax.xml.stream.XMLStreamException
Specified by:
writeAttribute in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeAttribute

public void writeAttribute(String prefix,
                           String namespaceURI,
                           String localName,
                           String value)
                    throws javax.xml.stream.XMLStreamException
Specified by:
writeAttribute in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeNamespace

public void writeNamespace(String prefix,
                           String namespaceURI)
                    throws javax.xml.stream.XMLStreamException
Specified by:
writeNamespace in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeDefaultNamespace

public void writeDefaultNamespace(String namespaceURI)
                           throws javax.xml.stream.XMLStreamException
Specified by:
writeDefaultNamespace in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeComment

public void writeComment(String data)
                  throws javax.xml.stream.XMLStreamException
Specified by:
writeComment in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeProcessingInstruction

public void writeProcessingInstruction(String target)
                                throws javax.xml.stream.XMLStreamException
Specified by:
writeProcessingInstruction in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeProcessingInstruction

public void writeProcessingInstruction(String target,
                                       String data)
                                throws javax.xml.stream.XMLStreamException
Specified by:
writeProcessingInstruction in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeCData

public void writeCData(String data)
                throws javax.xml.stream.XMLStreamException
Specified by:
writeCData in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeDTD

public void writeDTD(String dtd)
              throws javax.xml.stream.XMLStreamException
Specified by:
writeDTD in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeEntityRef

public void writeEntityRef(String name)
                    throws javax.xml.stream.XMLStreamException
Specified by:
writeEntityRef in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeCharacters

public void writeCharacters(String text)
                     throws javax.xml.stream.XMLStreamException
Specified by:
writeCharacters in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeCharacters

public void writeCharacters(char[] text,
                            int start,
                            int len)
                     throws javax.xml.stream.XMLStreamException
Specified by:
writeCharacters in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

getPrefix

public String getPrefix(String uri)
                 throws javax.xml.stream.XMLStreamException
Specified by:
getPrefix in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

setPrefix

public void setPrefix(String prefix,
                      String uri)
               throws javax.xml.stream.XMLStreamException
Specified by:
setPrefix in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

setDefaultNamespace

public void setDefaultNamespace(String uri)
                         throws javax.xml.stream.XMLStreamException
Specified by:
setDefaultNamespace in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

setNamespaceContext

public void setNamespaceContext(NamespaceContext context)
                         throws javax.xml.stream.XMLStreamException
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:
setNamespaceContext in interface javax.xml.stream.XMLStreamWriter
Parameters:
context - the namespace context to use for this writer, may not be null
Throws:
javax.xml.stream.XMLStreamException

getNamespaceContext

public NamespaceContext getNamespaceContext()
Specified by:
getNamespaceContext in interface javax.xml.stream.XMLStreamWriter

getProperty

public Object getProperty(String name)
                   throws IllegalArgumentException
Specified by:
getProperty in interface javax.xml.stream.XMLStreamWriter
Throws:
IllegalArgumentException

setManager

public void setManager(StAXManager manager)

setEncoding

public void setEncoding(String encoding)

writeOctets

public void writeOctets(byte[] b,
                        int start,
                        int len)
                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

encodeTerminationAndCurrentElement

protected void encodeTerminationAndCurrentElement(boolean terminateAfter)
                                           throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException


Copyright © 2011 Oracle Corpration. All Rights Reserved.