- All Implemented Interfaces:
FastInfosetParser
- Direct Known Subclasses:
DOMDocumentParser
,SAXDocumentParser
,StAXDocumentParser
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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
True if an entry is required to be added to a tableprotected QualifiedNameArray
The attribute name table of the vocabulary.protected StringArray
The attribute value table of the vocabulary.protected int
The current octet that is being readprivate int
protected int
The size of the internal buffer.private static int
protected ContiguousCharArrayArray
The character content chunk table of the vocabulary.protected char[]
The internal buffer of characters.protected int
The length of characters in the buffer of characters.protected boolean
True if two information item are terminated in direct sequence.protected DuplicateAttributeVerifier
Helper class that checks for duplicate attribute information items.protected QualifiedNameArray
The element name table of the vocabulary.private Map
<String, ParserVocabulary> The map of URIs to referenced vocabularies.protected int
The vocabulary table index of identifying string or the identifier of an encoding algorithm or restricted alphabet.protected int
The vocabulary table index to an indexed non identifying string.protected int
protected boolean
True if needs to close underlying input stream.The list of Notation Information Items that are part of the Document Information Item.protected byte[]
The internal buffer used for decoding.protected int
The end of the buffer.protected int
The length of some octets in the buffer that are to be read.protected int
The offset into the buffer to read the next byte.protected int
A mark into the internal buffer used for decoding encoded algorithm or restricted alphabet data.protected boolean
True if can parse fragments.protected int
protected PrefixArray
The prefix table of the vocabulary.protected Map
<String, EncodingAlgorithm> The map of URIs to registered encoding algorithms.private InputStream
The input stream from which the fast infoset document is being read.private boolean
True if string interning is performed by the decoder.private static boolean
protected boolean
True if an information item is terminated.protected List
<UnparsedEntity> The list of Unparsed Entity Information Items that are part of the Document Information Item.private char
private char
protected ParserVocabulary
The vocabulary used for decoding.private boolean
True if the vocabulary is internally created by decoder.static final String
Internal buffer size interning system property.protected static final int
protected static final int
protected static final int
protected static final int
static final String
String interning system property.private static final char[]
private static final char[]
private static final char[]
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final boolean
private boolean
arrayEquals
(byte[] b1, int offset, byte[] b2, int length) protected final void
private boolean
compareCharsWithCharBufferFromEndToStart
(char[] c) protected String
createQualifiedNameString
(char[] first, String second) protected String
createQualifiedNameString
(String second) protected final void
protected final void
decodeAlphabetOctetsAsCharBuffer
(char[] restrictedAlphabet) protected final String
protected final void
protected final QualifiedName
protected final QualifiedName
private void
protected final void
decodeFourBitAlphabetOctetsAsCharBuffer
(char[] restrictedAlphabet) protected final void
protected final String
decodeIdentifyingNonEmptyStringIndexOnFirstBitAsNamespaceName
(boolean prefixPresent) protected final String
decodeIdentifyingNonEmptyStringIndexOnFirstBitAsPrefix
(boolean namespaceNamePresent) protected final String
protected final String
decodeIdentifyingNonEmptyStringOnFirstBitAsNamespaceName
(boolean prefixPresent) protected final String
decodeIdentifyingNonEmptyStringOnFirstBitAsPrefix
(boolean namespaceNamePresent) protected final void
protected final int
protected final QualifiedName
decodeLiteralQualifiedName
(int state, QualifiedName q) protected final void
protected final void
protected final String
protected final int
protected final void
private int
protected final void
protected final void
protected final String
decodeRAOctetsAsString
(char[] restrictedAlphabet) protected final void
protected final String
private void
decodeTableItems
(CharArrayArray array) private void
private void
decodeTableItems
(PrefixArray array) private void
decodeTableItems
(QualifiedNameArray array, boolean isAttribute) private void
decodeTableItems
(StringArray array) private void
decodeTwoToFourByteUtf8Character
(char[] ch, int b1, int end) private void
decodeTwoToFourByteUtf8Character
(int b1, int end) protected final void
protected final void
protected final String
private void
private int
decodeUtf8FourByteChar
(int end, int b1) private void
protected final void
private void
decodeUtf8NCNameStartTwoToFourByteCharacters
(int b1, int end) private void
decodeUtf8NCNameTwoToFourByteCharacters
(int b1, int end) protected final void
protected final void
decodeUtf8StringAsCharBuffer
(char[] ch, int offset) protected final String
private void
protected final void
protected final void
decodeUtf8StringIntoCharBuffer
(char[] ch, int offset) private void
private char
decodeUtf8ThreeByteChar
(int end, int b1) protected final String
private void
int
Get the buffer size.Get the map of referenced external vocabularies.boolean
Return the force stream close property.boolean
Return the parse fragments property.Gets the set of registered encoding algorithms.boolean
Return the string interning property.static boolean
protected final int
peek()
protected final int
peek
(OctetBufferListener octetBufferListener) protected final int
peek2
(OctetBufferListener octetBufferListener) protected final int
read()
private int
readBits
(int bits) private void
void
reset()
Reset the decoder for reuse decoding another XML infoset.private void
void
setBufferSize
(int bufferSize) Set the buffer size.void
setExternalVocabularies
(Map<String, ParserVocabulary> referencedVocabualries) Set the map of referenced external vocabularies.void
setForceStreamClose
(boolean needForceStreamClose) Set the force stream close property.void
Set the InputStream to decode the fast infoset document.void
setParseFragments
(boolean parseFragments) Set the parse fragments property.void
setRegisteredEncodingAlgorithms
(Map<String, EncodingAlgorithm> algorithms) Sets the set of registered encoding algorithms.void
setStringInterning
(boolean stringInterning) Set the string interning property.void
Set the ParserVocabulary to be used for decoding.
-
Field Details
-
XML_NAMESPACE_NAME_CHARS
private static final char[] XML_NAMESPACE_NAME_CHARS -
XMLNS_NAMESPACE_PREFIX_CHARS
private static final char[] XMLNS_NAMESPACE_PREFIX_CHARS -
XMLNS_NAMESPACE_NAME_CHARS
private static final char[] XMLNS_NAMESPACE_NAME_CHARS -
STRING_INTERNING_SYSTEM_PROPERTY
String interning system property.- See Also:
-
BUFFER_SIZE_SYSTEM_PROPERTY
Internal buffer size interning system property.- See Also:
-
_stringInterningSystemDefault
private static boolean _stringInterningSystemDefault -
_bufferSizeSystemDefault
private static int _bufferSizeSystemDefault -
_stringInterning
private boolean _stringInterningTrue if string interning is performed by the decoder. -
_s
The input stream from which the fast infoset document is being read. -
_externalVocabularies
The map of URIs to referenced vocabularies. -
_parseFragments
protected boolean _parseFragmentsTrue if can parse fragments. -
_needForceStreamClose
protected boolean _needForceStreamCloseTrue if needs to close underlying input stream. -
_vIsInternal
private boolean _vIsInternalTrue if the vocabulary is internally created by decoder. -
_notations
The list of Notation Information Items that are part of the Document Information Item. -
_unparsedEntities
The list of Unparsed Entity Information Items that are part of the Document Information Item. -
_registeredEncodingAlgorithms
The map of URIs to registered encoding algorithms. -
_v
The vocabulary used for decoding. -
_prefixTable
The prefix table of the vocabulary. -
_elementNameTable
The element name table of the vocabulary. -
_attributeNameTable
The attribute name table of the vocabulary. -
_characterContentChunkTable
The character content chunk table of the vocabulary. -
_attributeValueTable
The attribute value table of the vocabulary. -
_b
protected int _bThe current octet that is being read -
_terminate
protected boolean _terminateTrue if an information item is terminated. -
_doubleTerminate
protected boolean _doubleTerminateTrue if two information item are terminated in direct sequence. -
_addToTable
protected boolean _addToTableTrue if an entry is required to be added to a table -
_integer
protected int _integerThe vocabulary table index to an indexed non identifying string. -
_identifier
protected int _identifierThe vocabulary table index of identifying string or the identifier of an encoding algorithm or restricted alphabet. -
_bufferSize
protected int _bufferSizeThe size of the internal buffer. -
_octetBuffer
protected byte[] _octetBufferThe internal buffer used for decoding. -
_octetBufferStart
protected int _octetBufferStartA mark into the internal buffer used for decoding encoded algorithm or restricted alphabet data. -
_octetBufferOffset
protected int _octetBufferOffsetThe offset into the buffer to read the next byte. -
_octetBufferEnd
protected int _octetBufferEndThe end of the buffer. -
_octetBufferLength
protected int _octetBufferLengthThe length of some octets in the buffer that are to be read. -
_charBuffer
protected char[] _charBufferThe internal buffer of characters. -
_charBufferLength
protected int _charBufferLengthThe length of characters in the buffer of characters. -
_duplicateAttributeVerifier
Helper class that checks for duplicate attribute information items. -
NISTRING_STRING
protected static final int NISTRING_STRING- See Also:
-
NISTRING_INDEX
protected static final int NISTRING_INDEX- See Also:
-
NISTRING_ENCODING_ALGORITHM
protected static final int NISTRING_ENCODING_ALGORITHM- See Also:
-
NISTRING_EMPTY_STRING
protected static final int NISTRING_EMPTY_STRING- See Also:
-
_prefixIndex
protected int _prefixIndex -
_namespaceNameIndex
protected int _namespaceNameIndex -
_bitsLeftInOctet
private int _bitsLeftInOctet -
_utf8_highSurrogate
private char _utf8_highSurrogate -
_utf8_lowSurrogate
private char _utf8_lowSurrogate
-
-
Constructor Details
-
Decoder
protected Decoder()Default constructor for the Decoder.
-
-
Method Details
-
setStringInterning
public void setStringInterning(boolean stringInterning) Description copied from interface:FastInfosetParser
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 methodString.intern()
.- Specified by:
setStringInterning
in interfaceFastInfosetParser
- Parameters:
stringInterning
- The string interning property.
-
getStringInterning
public boolean getStringInterning()Description copied from interface:FastInfosetParser
Return the string interning property.- Specified by:
getStringInterning
in interfaceFastInfosetParser
- Returns:
- The string interning property.
-
setBufferSize
public void setBufferSize(int bufferSize) Description copied from interface:FastInfosetParser
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 interfaceFastInfosetParser
- Parameters:
bufferSize
- The requested buffer size.
-
getBufferSize
public int getBufferSize()Description copied from interface:FastInfosetParser
Get the buffer size.- Specified by:
getBufferSize
in interfaceFastInfosetParser
- Returns:
- The buffer size.
-
setRegisteredEncodingAlgorithms
Description copied from interface:FastInfosetParser
Sets the set of registered encoding algorithms.- Specified by:
setRegisteredEncodingAlgorithms
in interfaceFastInfosetParser
- Parameters:
algorithms
- The set of registered algorithms.
-
getRegisteredEncodingAlgorithms
Description copied from interface:FastInfosetParser
Gets the set of registered encoding algorithms.- Specified by:
getRegisteredEncodingAlgorithms
in interfaceFastInfosetParser
- Returns:
- The set of registered algorithms.
-
setExternalVocabularies
Description copied from interface:FastInfosetParser
Set the map of referenced external vocabularies.The map (but not the keys and values) be cloned.
- Specified by:
setExternalVocabularies
in interfaceFastInfosetParser
- Parameters:
referencedVocabualries
- the map of URI to vocabulary.
-
getExternalVocabularies
Description copied from interface:FastInfosetParser
Get the map of referenced external vocabularies.- Specified by:
getExternalVocabularies
in interfaceFastInfosetParser
- Returns:
- the map of URI to vocabulary.
-
setParseFragments
public void setParseFragments(boolean parseFragments) Description copied from interface:FastInfosetParser
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 interfaceFastInfosetParser
- Parameters:
parseFragments
- The parse fragments property.
-
getParseFragments
public boolean getParseFragments()Description copied from interface:FastInfosetParser
Return the parse fragments property.- Specified by:
getParseFragments
in interfaceFastInfosetParser
- Returns:
- The parse fragments property.
-
setForceStreamClose
public void setForceStreamClose(boolean needForceStreamClose) Description copied from interface:FastInfosetParser
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 interfaceFastInfosetParser
- Parameters:
needForceStreamClose
- The force stream close property.
-
getForceStreamClose
public boolean getForceStreamClose()Description copied from interface:FastInfosetParser
Return the force stream close property.- Specified by:
getForceStreamClose
in interfaceFastInfosetParser
- Returns:
- The force stream close property.
-
reset
public void reset()Reset the decoder for reuse decoding another XML infoset. -
setVocabulary
Set the ParserVocabulary to be used for decoding.- Parameters:
v
- the vocabulary to be used for decoding.
-
setInputStream
Set the InputStream to decode the fast infoset document.- Parameters:
s
- the InputStream where the fast infoset document is decoded from.
-
decodeDII
- Throws:
FastInfosetException
IOException
-
decodeAdditionalData
- Throws:
FastInfosetException
IOException
-
decodeInitialVocabulary
- Throws:
FastInfosetException
IOException
-
decodeExternalVocabularyURI
- Throws:
FastInfosetException
IOException
-
decodeTableItems
- Throws:
FastInfosetException
IOException
-
decodeTableItems
- Throws:
FastInfosetException
IOException
-
decodeTableItems
private void decodeTableItems(ContiguousCharArrayArray array) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-
decodeTableItems
- Throws:
FastInfosetException
IOException
-
decodeTableItems
private void decodeTableItems(QualifiedNameArray array, boolean isAttribute) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-
decodeNumberOfItemsOfSequence
- Throws:
IOException
-
decodeNotations
- Throws:
FastInfosetException
IOException
-
decodeUnparsedEntities
- Throws:
FastInfosetException
IOException
-
decodeCharacterEncodingScheme
- Throws:
FastInfosetException
IOException
-
decodeVersion
- Throws:
FastInfosetException
IOException
-
decodeEIIIndexMedium
- Throws:
FastInfosetException
IOException
-
decodeEIIIndexLarge
- Throws:
FastInfosetException
IOException
-
decodeLiteralQualifiedName
protected final QualifiedName decodeLiteralQualifiedName(int state, QualifiedName q) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-
decodeNonIdentifyingStringOnFirstBit
- 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
-
compareCharsWithCharBufferFromEndToStart
private boolean compareCharsWithCharBufferFromEndToStart(char[] c) -
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
- Throws:
FastInfosetException
IOException
-
decodeHeader
- Throws:
FastInfosetException
IOException
-
decodeRestrictedAlphabetAsCharBuffer
protected final void decodeRestrictedAlphabetAsCharBuffer() throws FastInfosetException, IOException- Throws:
FastInfosetException
IOException
-
decodeRestrictedAlphabetAsString
- 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
-
resetBits
private void resetBits() -
readBits
- Throws:
IOException
-
decodeUtf8StringAsCharBuffer
- Throws:
IOException
-
decodeUtf8StringAsCharBuffer
- Throws:
IOException
-
decodeUtf8StringAsString
- Throws:
IOException
-
decodeUtf16StringAsCharBuffer
- Throws:
IOException
-
decodeUtf16StringAsString
- Throws:
IOException
-
ensureOctetBufferSize
- Throws:
IOException
-
repeatedRead
- Throws:
IOException
-
decodeUtf8StringIntoCharBuffer
- Throws:
IOException
-
decodeUtf8StringIntoCharBuffer
- Throws:
IOException
-
decodeTwoToFourByteUtf8Character
- Throws:
IOException
-
decodeTwoToFourByteUtf8Character
- Throws:
IOException
-
decodeUtf8NCNameIntoCharBuffer
- Throws:
IOException
-
decodeUtf8NCNameStartTwoToFourByteCharacters
- Throws:
IOException
-
decodeUtf8NCNameTwoToFourByteCharacters
- Throws:
IOException
-
decodeUtf8ThreeByteChar
- Throws:
IOException
-
decodeUtf8FourByteChar
- Throws:
IOException
-
decodeUtf8StringLengthTooSmall
- Throws:
IOException
-
decodeUtf8StringIllegalState
- Throws:
IOException
-
decodeUtf8NCNameIllegalState
- Throws:
IOException
-
decodeUtf16StringIntoCharBuffer
- Throws:
IOException
-
createQualifiedNameString
-
createQualifiedNameString
-
read
- Throws:
IOException
-
closeIfRequired
- Throws:
IOException
-
peek
- Throws:
IOException
-
peek
- Throws:
IOException
-
peek2
- Throws:
IOException
-
_isFastInfosetDocument
- Throws:
IOException
-
arrayEquals
private boolean arrayEquals(byte[] b1, int offset, byte[] b2, int length) -
isFastInfosetDocument
- Throws:
IOException
-