com.sun.xml.fastinfoset
Class Decoder

java.lang.Object
  extended by com.sun.xml.fastinfoset.Decoder
All Implemented Interfaces:
FastInfosetParser
Direct Known Subclasses:
DOMDocumentParser, SAXDocumentParser, StAXDocumentParser

public abstract class Decoder
extends Object
implements FastInfosetParser

Abstract decoder for developing concrete encoders. Concrete implementations extending Decoder will utilize methods on Decoder to decode XML infoset according to the Fast Infoset standard. It is the responsibility of the concrete implementation to ensure that methods are invoked in the correct order to correctly decode a valid fast infoset document.

This class extends org.sax.xml.DefaultHandler so that concrete SAX implementations can be used with javax.xml.parsers.SAXParser and the parse methods that take org.sax.xml.DefaultHandler as a parameter.

Buffering of octets that are read from an InputStream is supported in a similar manner to a BufferedInputStream. Combining buffering with decoding enables better performance.

More than one fast infoset document may be decoded from the InputStream.


Nested Class Summary
protected  class Decoder.EncodingAlgorithmInputStream
           
 
Field Summary
protected  boolean _addToTable
          True if an entry is required to be added to a table
protected  QualifiedNameArray _attributeNameTable
          The attribute name table of the vocabulary.
protected  StringArray _attributeValueTable
          The attribute value table of the vocabulary.
protected  int _b
          The current octet that is being read
protected  int _bufferSize
          The size of the internal buffer.
protected  ContiguousCharArrayArray _characterContentChunkTable
          The character content chunk table of the vocabulary.
protected  char[] _charBuffer
          The internal buffer of characters.
protected  int _charBufferLength
          The length of characters in the buffer of characters.
protected  boolean _doubleTerminate
          True if two information item are terminated in direct sequence.
protected  DuplicateAttributeVerifier _duplicateAttributeVerifier
          Helper class that checks for duplicate attribute information items.
protected  QualifiedNameArray _elementNameTable
          The element name table of the vocabulary.
protected  int _identifier
          The vocabulary table index of identifying string or the identifier of an encoding algorithm or restricted alphabet.
protected  int _integer
          The vocabulary table index to an indexed non identifying string.
protected  int _namespaceNameIndex
           
protected  boolean _needForceStreamClose
          True if needs to close underlying input stream.
protected  List _notations
          The list of Notation Information Items that are part of the Document Information Item.
protected  byte[] _octetBuffer
          The internal buffer used for decoding.
protected  int _octetBufferEnd
          The end of the buffer.
protected  int _octetBufferLength
          The length of some octets in the buffer that are to be read.
protected  int _octetBufferOffset
          The offset into the buffer to read the next byte.
protected  int _octetBufferStart
          A mark into the internal buffer used for decoding encoded algorithm or restricted alphabet data.
protected  boolean _parseFragments
          True if can parse fragments.
protected  int _prefixIndex
           
protected  PrefixArray _prefixTable
          The prefix table of the vocabulary.
protected  Map _registeredEncodingAlgorithms
          The map of URIs to registered encoding algorithms.
protected  boolean _terminate
          True if an information item is terminated.
protected  List _unparsedEntities
          The list of Unparsed Entity Information Items that are part of the Document Information Item.
protected  ParserVocabulary _v
          The vocabulary used for decoding.
static String BUFFER_SIZE_SYSTEM_PROPERTY
          Internal buffer size interning system property.
protected static int NISTRING_EMPTY_STRING
           
protected static int NISTRING_ENCODING_ALGORITHM
           
protected static int NISTRING_INDEX
           
protected static int NISTRING_STRING
           
static String STRING_INTERNING_SYSTEM_PROPERTY
          String interning system property.
 
Fields inherited from interface org.jvnet.fastinfoset.FastInfosetParser
BUFFER_SIZE_PROPERTY, EXTERNAL_VOCABULARIES_PROPERTY, FORCE_STREAM_CLOSE_PROPERTY, REGISTERED_ENCODING_ALGORITHMS_PROPERTY, STRING_INTERNING_PROPERTY
 
Constructor Summary
protected Decoder()
          Default constructor for the Decoder.
 
Method Summary
protected  boolean _isFastInfosetDocument()
           
protected  void closeIfRequired()
           
protected  String createQualifiedNameString(char[] first, String second)
           
protected  String createQualifiedNameString(String second)
           
protected  void decodeAdditionalData()
           
protected  void decodeAlphabetOctetsAsCharBuffer(char[] restrictedAlphabet)
           
protected  String decodeCharacterEncodingScheme()
           
protected  void decodeDII()
           
protected  QualifiedName decodeEIIIndexLarge()
           
protected  QualifiedName decodeEIIIndexMedium()
           
protected  void decodeFourBitAlphabetOctetsAsCharBuffer(char[] restrictedAlphabet)
           
protected  void decodeHeader()
           
protected  String decodeIdentifyingNonEmptyStringIndexOnFirstBitAsNamespaceName(boolean prefixPresent)
           
protected  String decodeIdentifyingNonEmptyStringIndexOnFirstBitAsPrefix(boolean namespaceNamePresent)
           
protected  String decodeIdentifyingNonEmptyStringOnFirstBit(StringArray table)
           
protected  String decodeIdentifyingNonEmptyStringOnFirstBitAsNamespaceName(boolean prefixPresent)
           
protected  String decodeIdentifyingNonEmptyStringOnFirstBitAsPrefix(boolean namespaceNamePresent)
           
protected  void decodeInitialVocabulary()
           
protected  int decodeIntegerIndexOnSecondBit()
           
protected  QualifiedName decodeLiteralQualifiedName(int state, QualifiedName q)
           
protected  void decodeNonEmptyOctetStringLengthOnSecondBit()
           
protected  void decodeNonEmptyOctetStringOnSecondBitAsUtf8CharArray()
           
protected  String decodeNonEmptyOctetStringOnSecondBitAsUtf8String()
           
protected  int decodeNonIdentifyingStringOnFirstBit()
           
protected  void decodeNotations()
           
protected  void decodeOctetsOnFifthBitOfNonIdentifyingStringOnFirstBit(int b)
           
protected  void decodeOctetsOnSeventhBitOfNonIdentifyingStringOnThirdBit(int b)
           
protected  String decodeRAOctetsAsString(char[] restrictedAlphabet)
           
protected  void decodeRestrictedAlphabetAsCharBuffer()
           
protected  String decodeRestrictedAlphabetAsString()
           
protected  void decodeUnparsedEntities()
           
protected  void decodeUtf16StringAsCharBuffer()
           
protected  String decodeUtf16StringAsString()
           
protected  void decodeUtf8NCNameIntoCharBuffer()
           
protected  void decodeUtf8StringAsCharBuffer()
           
protected  void decodeUtf8StringAsCharBuffer(char[] ch, int offset)
           
protected  String decodeUtf8StringAsString()
           
protected  void decodeUtf8StringIntoCharBuffer()
           
protected  void decodeUtf8StringIntoCharBuffer(char[] ch, int offset)
           
protected  String decodeVersion()
           
 int getBufferSize()
          Get the buffer size.
 Map getExternalVocabularies()
          Get the map of referenced external vocabularies.
 boolean getForceStreamClose()
          Return the force stream close property.
 boolean getParseFragments()
          Return the parse fragments property.
 Map getRegisteredEncodingAlgorithms()
          Gets the set of registered encoding algorithms.
 boolean getStringInterning()
          Return the string interning property.
static boolean isFastInfosetDocument(InputStream s)
           
protected  int peek()
           
protected  int peek(OctetBufferListener octetBufferListener)
           
protected  int peek2(OctetBufferListener octetBufferListener)
           
protected  int read()
           
 void reset()
          Reset the decoder for reuse decoding another XML infoset.
 void setBufferSize(int bufferSize)
          Set the buffer size.
 void setExternalVocabularies(Map referencedVocabualries)
          Set the map of referenced external vocabularies.
 void setForceStreamClose(boolean needForceStreamClose)
          Set the force stream close property.
 void setInputStream(InputStream s)
          Set the InputStream to decode the fast infoset document.
 void setParseFragments(boolean parseFragments)
          Set the parse fragments property.
 void setRegisteredEncodingAlgorithms(Map algorithms)
          Sets the set of registered encoding algorithms.
 void setStringInterning(boolean stringInterning)
          Set the string interning property.
 void setVocabulary(ParserVocabulary v)
          Set the ParserVocabulary to be used for decoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING_INTERNING_SYSTEM_PROPERTY

public static final String STRING_INTERNING_SYSTEM_PROPERTY
String interning system property.

See Also:
Constant Field Values

BUFFER_SIZE_SYSTEM_PROPERTY

public static final String BUFFER_SIZE_SYSTEM_PROPERTY
Internal buffer size interning system property.

See Also:
Constant Field Values

_parseFragments

protected boolean _parseFragments
True if can parse fragments.


_needForceStreamClose

protected boolean _needForceStreamClose
True if needs to close underlying input stream.


_notations

protected List _notations
The list of Notation Information Items that are part of the Document Information Item.


_unparsedEntities

protected List _unparsedEntities
The list of Unparsed Entity Information Items that are part of the Document Information Item.


_registeredEncodingAlgorithms

protected Map _registeredEncodingAlgorithms
The map of URIs to registered encoding algorithms.


_v

protected ParserVocabulary _v
The vocabulary used for decoding.


_prefixTable

protected PrefixArray _prefixTable
The prefix table of the vocabulary.


_elementNameTable

protected QualifiedNameArray _elementNameTable
The element name table of the vocabulary.


_attributeNameTable

protected QualifiedNameArray _attributeNameTable
The attribute name table of the vocabulary.


_characterContentChunkTable

protected ContiguousCharArrayArray _characterContentChunkTable
The character content chunk table of the vocabulary.


_attributeValueTable

protected StringArray _attributeValueTable
The attribute value table of the vocabulary.


_b

protected int _b
The current octet that is being read


_terminate

protected boolean _terminate
True if an information item is terminated.


_doubleTerminate

protected boolean _doubleTerminate
True if two information item are terminated in direct sequence.


_addToTable

protected boolean _addToTable
True if an entry is required to be added to a table


_integer

protected int _integer
The vocabulary table index to an indexed non identifying string.


_identifier

protected int _identifier
The vocabulary table index of identifying string or the identifier of an encoding algorithm or restricted alphabet.


_bufferSize

protected int _bufferSize
The size of the internal buffer.


_octetBuffer

protected byte[] _octetBuffer
The internal buffer used for decoding.


_octetBufferStart

protected int _octetBufferStart
A mark into the internal buffer used for decoding encoded algorithm or restricted alphabet data.


_octetBufferOffset

protected int _octetBufferOffset
The offset into the buffer to read the next byte.


_octetBufferEnd

protected int _octetBufferEnd
The end of the buffer.


_octetBufferLength

protected int _octetBufferLength
The length of some octets in the buffer that are to be read.


_charBuffer

protected char[] _charBuffer
The internal buffer of characters.


_charBufferLength

protected int _charBufferLength
The length of characters in the buffer of characters.


_duplicateAttributeVerifier

protected DuplicateAttributeVerifier _duplicateAttributeVerifier
Helper class that checks for duplicate attribute information items.


NISTRING_STRING

protected static final int NISTRING_STRING
See Also:
Constant Field Values

NISTRING_INDEX

protected static final int NISTRING_INDEX
See Also:
Constant Field Values

NISTRING_ENCODING_ALGORITHM

protected static final int NISTRING_ENCODING_ALGORITHM
See Also:
Constant Field Values

NISTRING_EMPTY_STRING

protected static final int NISTRING_EMPTY_STRING
See Also:
Constant Field Values

_prefixIndex

protected int _prefixIndex

_namespaceNameIndex

protected int _namespaceNameIndex
Constructor Detail

Decoder

protected Decoder()
Default constructor for the Decoder.

Method Detail

setStringInterning

public void setStringInterning(boolean stringInterning)
Set the string interning property.

If the string interning property is set to true then String objects instantiated for [namespace name], [prefix] and [local name] infoset properties will be interned using the method String.intern().

Specified by:
setStringInterning in interface FastInfosetParser
Parameters:
stringInterning - The string interning property.

getStringInterning

public boolean getStringInterning()
Return the string interning property.

Specified by:
getStringInterning in interface FastInfosetParser
Returns:
The string interning property.

setBufferSize

public void setBufferSize(int bufferSize)
Set the buffer size.

The size of the buffer for parsing is set using this method. Requests for sizes smaller then the current size will be ignored. Otherwise the buffer will be resized when the next parse is performed.

Specified by:
setBufferSize in interface FastInfosetParser
Parameters:
bufferSize - The requested buffer size.

getBufferSize

public int getBufferSize()
Get the buffer size.

Specified by:
getBufferSize in interface FastInfosetParser
Returns:
The buffer size.

setRegisteredEncodingAlgorithms

public void setRegisteredEncodingAlgorithms(Map algorithms)
Sets the set of registered encoding algorithms.

Specified by:
setRegisteredEncodingAlgorithms in interface FastInfosetParser
Parameters:
algorithms - The set of registered algorithms.

getRegisteredEncodingAlgorithms

public Map getRegisteredEncodingAlgorithms()
Gets the set of registered encoding algorithms.

Specified by:
getRegisteredEncodingAlgorithms in interface FastInfosetParser
Returns:
The set of registered algorithms.

setExternalVocabularies

public void setExternalVocabularies(Map referencedVocabualries)
Set the map of referenced external vocabularies.

The map (but not the keys and values) be cloned.

Specified by:
setExternalVocabularies in interface FastInfosetParser
Parameters:
referencedVocabualries - the map of URI to vocabulary.

getExternalVocabularies

public Map getExternalVocabularies()
Get the map of referenced external vocabularies.

Specified by:
getExternalVocabularies in interface FastInfosetParser
Returns:
the map of URI to vocabulary.

setParseFragments

public void setParseFragments(boolean parseFragments)
Set the parse fragments property.

If the parse fragments property is set to true then fragments of an XML infoset may be parsed.

Specified by:
setParseFragments in interface FastInfosetParser
Parameters:
parseFragments - The parse fragments property.

getParseFragments

public boolean getParseFragments()
Return the parse fragments property.

Specified by:
getParseFragments in interface FastInfosetParser
Returns:
The parse fragments property.

setForceStreamClose

public void setForceStreamClose(boolean needForceStreamClose)
Set the force stream close property.

If the force stream property is set to true then Parser's underlying InputStream will be closed.

Specified by:
setForceStreamClose in interface FastInfosetParser
Parameters:
needForceStreamClose - The force stream close property.

getForceStreamClose

public boolean getForceStreamClose()
Return the force stream close property.

Specified by:
getForceStreamClose in interface FastInfosetParser
Returns:
The force stream close property.

reset

public void reset()
Reset the decoder for reuse decoding another XML infoset.


setVocabulary

public void setVocabulary(ParserVocabulary v)
Set the ParserVocabulary to be used for decoding.

Parameters:
v - the vocabulary to be used for decoding.

setInputStream

public void setInputStream(InputStream s)
Set the InputStream to decode the fast infoset document.

Parameters:
s - the InputStream where the fast infoset document is decoded from.

decodeDII

protected final void decodeDII()
                        throws FastInfosetException,
                               IOException
Throws:
FastInfosetException
IOException

decodeAdditionalData

protected final void decodeAdditionalData()
                                   throws FastInfosetException,
                                          IOException
Throws:
FastInfosetException
IOException

decodeInitialVocabulary

protected final void decodeInitialVocabulary()
                                      throws FastInfosetException,
                                             IOException
Throws:
FastInfosetException
IOException

decodeNotations

protected final void decodeNotations()
                              throws FastInfosetException,
                                     IOException
Throws:
FastInfosetException
IOException

decodeUnparsedEntities

protected final void decodeUnparsedEntities()
                                     throws FastInfosetException,
                                            IOException
Throws:
FastInfosetException
IOException

decodeCharacterEncodingScheme

protected final String decodeCharacterEncodingScheme()
                                              throws FastInfosetException,
                                                     IOException
Throws:
FastInfosetException
IOException

decodeVersion

protected final String decodeVersion()
                              throws FastInfosetException,
                                     IOException
Throws:
FastInfosetException
IOException

decodeEIIIndexMedium

protected final QualifiedName decodeEIIIndexMedium()
                                            throws FastInfosetException,
                                                   IOException
Throws:
FastInfosetException
IOException

decodeEIIIndexLarge

protected final QualifiedName decodeEIIIndexLarge()
                                           throws FastInfosetException,
                                                  IOException
Throws:
FastInfosetException
IOException

decodeLiteralQualifiedName

protected final QualifiedName decodeLiteralQualifiedName(int state,
                                                         QualifiedName q)
                                                  throws FastInfosetException,
                                                         IOException
Throws:
FastInfosetException
IOException

decodeNonIdentifyingStringOnFirstBit

protected final int decodeNonIdentifyingStringOnFirstBit()
                                                  throws FastInfosetException,
                                                         IOException
Throws:
FastInfosetException
IOException

decodeOctetsOnFifthBitOfNonIdentifyingStringOnFirstBit

protected final void decodeOctetsOnFifthBitOfNonIdentifyingStringOnFirstBit(int b)
                                                                     throws FastInfosetException,
                                                                            IOException
Throws:
FastInfosetException
IOException

decodeOctetsOnSeventhBitOfNonIdentifyingStringOnThirdBit

protected final void decodeOctetsOnSeventhBitOfNonIdentifyingStringOnThirdBit(int b)
                                                                       throws FastInfosetException,
                                                                              IOException
Throws:
FastInfosetException
IOException

decodeIdentifyingNonEmptyStringOnFirstBit

protected final String decodeIdentifyingNonEmptyStringOnFirstBit(StringArray table)
                                                          throws FastInfosetException,
                                                                 IOException
Throws:
FastInfosetException
IOException

decodeIdentifyingNonEmptyStringOnFirstBitAsPrefix

protected final String decodeIdentifyingNonEmptyStringOnFirstBitAsPrefix(boolean namespaceNamePresent)
                                                                  throws FastInfosetException,
                                                                         IOException
Throws:
FastInfosetException
IOException

decodeIdentifyingNonEmptyStringIndexOnFirstBitAsPrefix

protected final String decodeIdentifyingNonEmptyStringIndexOnFirstBitAsPrefix(boolean namespaceNamePresent)
                                                                       throws FastInfosetException,
                                                                              IOException
Throws:
FastInfosetException
IOException

decodeIdentifyingNonEmptyStringOnFirstBitAsNamespaceName

protected final String decodeIdentifyingNonEmptyStringOnFirstBitAsNamespaceName(boolean prefixPresent)
                                                                         throws FastInfosetException,
                                                                                IOException
Throws:
FastInfosetException
IOException

decodeIdentifyingNonEmptyStringIndexOnFirstBitAsNamespaceName

protected final String decodeIdentifyingNonEmptyStringIndexOnFirstBitAsNamespaceName(boolean prefixPresent)
                                                                              throws FastInfosetException,
                                                                                     IOException
Throws:
FastInfosetException
IOException

decodeNonEmptyOctetStringOnSecondBitAsUtf8String

protected final String decodeNonEmptyOctetStringOnSecondBitAsUtf8String()
                                                                 throws FastInfosetException,
                                                                        IOException
Throws:
FastInfosetException
IOException

decodeNonEmptyOctetStringOnSecondBitAsUtf8CharArray

protected final void decodeNonEmptyOctetStringOnSecondBitAsUtf8CharArray()
                                                                  throws FastInfosetException,
                                                                         IOException
Throws:
FastInfosetException
IOException

decodeNonEmptyOctetStringLengthOnSecondBit

protected final void decodeNonEmptyOctetStringLengthOnSecondBit()
                                                         throws FastInfosetException,
                                                                IOException
Throws:
FastInfosetException
IOException

decodeIntegerIndexOnSecondBit

protected final int decodeIntegerIndexOnSecondBit()
                                           throws FastInfosetException,
                                                  IOException
Throws:
FastInfosetException
IOException

decodeHeader

protected final void decodeHeader()
                           throws FastInfosetException,
                                  IOException
Throws:
FastInfosetException
IOException

decodeRestrictedAlphabetAsCharBuffer

protected final void decodeRestrictedAlphabetAsCharBuffer()
                                                   throws FastInfosetException,
                                                          IOException
Throws:
FastInfosetException
IOException

decodeRestrictedAlphabetAsString

protected final String decodeRestrictedAlphabetAsString()
                                                 throws FastInfosetException,
                                                        IOException
Throws:
FastInfosetException
IOException

decodeRAOctetsAsString

protected final String decodeRAOctetsAsString(char[] restrictedAlphabet)
                                       throws FastInfosetException,
                                              IOException
Throws:
FastInfosetException
IOException

decodeFourBitAlphabetOctetsAsCharBuffer

protected final void decodeFourBitAlphabetOctetsAsCharBuffer(char[] restrictedAlphabet)
                                                      throws FastInfosetException,
                                                             IOException
Throws:
FastInfosetException
IOException

decodeAlphabetOctetsAsCharBuffer

protected final void decodeAlphabetOctetsAsCharBuffer(char[] restrictedAlphabet)
                                               throws FastInfosetException,
                                                      IOException
Throws:
FastInfosetException
IOException

decodeUtf8StringAsCharBuffer

protected final void decodeUtf8StringAsCharBuffer()
                                           throws IOException
Throws:
IOException

decodeUtf8StringAsCharBuffer

protected final void decodeUtf8StringAsCharBuffer(char[] ch,
                                                  int offset)
                                           throws IOException
Throws:
IOException

decodeUtf8StringAsString

protected final String decodeUtf8StringAsString()
                                         throws IOException
Throws:
IOException

decodeUtf16StringAsCharBuffer

protected final void decodeUtf16StringAsCharBuffer()
                                            throws IOException
Throws:
IOException

decodeUtf16StringAsString

protected final String decodeUtf16StringAsString()
                                          throws IOException
Throws:
IOException

decodeUtf8StringIntoCharBuffer

protected final void decodeUtf8StringIntoCharBuffer()
                                             throws IOException
Throws:
IOException

decodeUtf8StringIntoCharBuffer

protected final void decodeUtf8StringIntoCharBuffer(char[] ch,
                                                    int offset)
                                             throws IOException
Throws:
IOException

decodeUtf8NCNameIntoCharBuffer

protected final void decodeUtf8NCNameIntoCharBuffer()
                                             throws IOException
Throws:
IOException

createQualifiedNameString

protected String createQualifiedNameString(String second)

createQualifiedNameString

protected String createQualifiedNameString(char[] first,
                                           String second)

read

protected final int read()
                  throws IOException
Throws:
IOException

closeIfRequired

protected final void closeIfRequired()
                              throws IOException
Throws:
IOException

peek

protected final int peek()
                  throws IOException
Throws:
IOException

peek

protected final int peek(OctetBufferListener octetBufferListener)
                  throws IOException
Throws:
IOException

peek2

protected final int peek2(OctetBufferListener octetBufferListener)
                   throws IOException
Throws:
IOException

_isFastInfosetDocument

protected final boolean _isFastInfosetDocument()
                                        throws IOException
Throws:
IOException

isFastInfosetDocument

public static boolean isFastInfosetDocument(InputStream s)
                                     throws IOException
Throws:
IOException


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.