java.lang.Object
com.sun.xml.fastinfoset.Decoder
com.sun.xml.fastinfoset.stax.StAXDocumentParser
- All Implemented Interfaces:
OctetBufferListener
,XMLStreamConstants
,XMLStreamReader
,FastInfosetParser
,FastInfosetStreamReader
public class StAXDocumentParser
extends Decoder
implements XMLStreamReader, FastInfosetStreamReader, OctetBufferListener
The Fast Infoset StAX parser.
Instantiate this parser to parse a fast infoset document in accordance with the StAX API.
More than one fast infoset document may be decoded from the
InputStream
.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.sun.xml.fastinfoset.Decoder
Decoder.EncodingAlgorithmInputStream
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
protected int
protected int
protected int
protected String
protected AttributesHolder
List of attributesprotected String
protected char[]
Characters associated with event.protected int
protected boolean
protected int
protected int
Namespaces associated with START_ELEMENT or END_ELEMENTprotected int
Current eventprotected int
protected boolean
protected StAXManager
protected int[]
protected int
protected String[]
protected String[]
protected int[]
protected int[]
protected StAXDocumentParser.NamespaceContextImpl
protected String
protected String
State for processing instructionprotected QualifiedName[]
Stack of qualified names and namespacesprotected QualifiedName
Qualified name associated with START_ELEMENT or END_ELEMENT.protected int
private byte[]
private int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
private static final Logger
Fields inherited from class com.sun.xml.fastinfoset.Decoder
_addToTable, _attributeNameTable, _attributeValueTable, _b, _bufferSize, _characterContentChunkTable, _charBuffer, _charBufferLength, _doubleTerminate, _duplicateAttributeVerifier, _elementNameTable, _identifier, _integer, _namespaceNameIndex, _needForceStreamClose, _notations, _octetBuffer, _octetBufferEnd, _octetBufferLength, _octetBufferOffset, _octetBufferStart, _parseFragments, _prefixIndex, _prefixTable, _registeredEncodingAlgorithms, _terminate, _unparsedEntities, _v, BUFFER_SIZE_SYSTEM_PROPERTY, NISTRING_EMPTY_STRING, NISTRING_ENCODING_ALGORITHM, NISTRING_INDEX, NISTRING_STRING, 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
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal String
final int
final String
final String
final char[]
Returns a cloned char[] representation of the internal char[] buffer.final int
final int
private void
base64DecodeWithCloning
(StringBuilder dstBuffer, byte[] data, int offset, int length) private void
base64DecodeWithoutCloning
(StringBuilder dstBuffer, byte[] data, int offset, int length) protected final void
void
close()
protected void
Deprecated, for removal: This API element is subject to removal in a future version.protected void
protected final void
final int
final String
getAttributeLocalName
(int index) final QName
getAttributeName
(int index) final String
getAttributeNamespace
(int index) final String
getAttributeNameString
(int index) final String
getAttributePrefix
(int index) final AttributesHolder
final String
getAttributeType
(int index) final String
getAttributeValue
(int index) final String
getAttributeValue
(String namespaceURI, String localName) final String
final String
Reads the content of a text-only element.final String
getElementText
(boolean startElementRead) final String
final int
(package private) static final String
getEventTypeString
(int eventType) final String
final Location
final QName
getName()
final NamespaceContext
final int
final String
getNamespaceDecl
(String prefix) final String
getNamespacePrefix
(int index) final String
final String
getNamespaceURI
(int index) final String
getNamespaceURI
(String prefix) final String
final String
final String
final String
getProperty
(String name) final String
getText()
final byte[]
Returns the byte[], which represents text algorithms.final int
getTextAlgorithmBytes
(int sourceStart, byte[] target, int targetStart, int length) final byte[]
final int
final int
final int
final String
final char[]
final int
getTextCharacters
(int sourceStart, char[] target, int targetStart, int length) final int
final int
final String
final String
final boolean
hasName()
final boolean
hasNext()
final boolean
hasText()
final boolean
final boolean
isAttributeSpecified
(int index) boolean
final boolean
final boolean
final boolean
final boolean
final boolean
Returns true if the cursor points to a character data event that consists of all whitespace Application calling this method needs to cache the value and avoid calling this method again for the same event.int
next()
final int
nextTag()
Skips any white space (isWhiteSpace() returns true), COMMENT, or PROCESSING_INSTRUCTION, until a START_ELEMENT or END_ELEMENT is reached.final int
nextTag
(boolean currentTagRead) if the current tag has already read, such as in the case EventReader's peek() has been called, the current cursor should not move before the loopvoid
Callback method that will be called before the (@link Decoder) octet buffer content is going to be changed.final int
peekNext()
Peek at the next event.private void
popStack()
protected final void
processAIIEncodingAlgorithm
(QualifiedName name, boolean addToTable) protected final void
protected final void
processCIIEncodingAlgorithm
(boolean addToTable) protected final void
protected final void
protected final void
processDIIOptionalProperties
(int b) protected final void
processEII
(QualifiedName name, boolean hasAttributes) protected final QualifiedName
processEIIIndexLarge
(int b) protected final QualifiedName
processEIIIndexMedium
(int b) protected final void
processEIIWithNamespaces
(boolean hasAttributes) protected final QualifiedName
processLiteralQualifiedName
(int state, QualifiedName q) protected final void
protected final void
private void
processUtf16CharacterString
(int b) private void
processUtf8CharacterString
(int b) final void
Test if the current event is of the given type and if the namespace and name match the current namespace and name of the current event.void
reset()
Reset the decoder for reuse decoding another XML infoset.protected void
protected final void
void
Set the InputStream to decode the fast infoset document.final void
setManager
(StAXManager manager) final boolean
Methods inherited from class com.sun.xml.fastinfoset.Decoder
_isFastInfosetDocument, closeIfRequired, createQualifiedNameString, createQualifiedNameString, decodeAdditionalData, decodeAlphabetOctetsAsCharBuffer, decodeCharacterEncodingScheme, decodeDII, decodeEIIIndexLarge, decodeEIIIndexMedium, decodeFourBitAlphabetOctetsAsCharBuffer, decodeHeader, decodeIdentifyingNonEmptyStringIndexOnFirstBitAsNamespaceName, decodeIdentifyingNonEmptyStringIndexOnFirstBitAsPrefix, decodeIdentifyingNonEmptyStringOnFirstBit, decodeIdentifyingNonEmptyStringOnFirstBitAsNamespaceName, decodeIdentifyingNonEmptyStringOnFirstBitAsPrefix, decodeInitialVocabulary, decodeIntegerIndexOnSecondBit, decodeLiteralQualifiedName, decodeNonEmptyOctetStringLengthOnSecondBit, decodeNonEmptyOctetStringOnSecondBitAsUtf8CharArray, decodeNonEmptyOctetStringOnSecondBitAsUtf8String, decodeNonIdentifyingStringOnFirstBit, decodeNotations, decodeOctetsOnFifthBitOfNonIdentifyingStringOnFirstBit, decodeOctetsOnSeventhBitOfNonIdentifyingStringOnThirdBit, decodeRAOctetsAsString, decodeRestrictedAlphabetAsCharBuffer, decodeRestrictedAlphabetAsString, decodeUnparsedEntities, decodeUtf16StringAsCharBuffer, decodeUtf16StringAsString, decodeUtf8NCNameIntoCharBuffer, decodeUtf8StringAsCharBuffer, decodeUtf8StringAsCharBuffer, decodeUtf8StringAsString, decodeUtf8StringIntoCharBuffer, decodeUtf8StringIntoCharBuffer, decodeVersion, getBufferSize, getExternalVocabularies, getForceStreamClose, getParseFragments, getRegisteredEncodingAlgorithms, getStringInterning, isFastInfosetDocument, peek, peek, peek2, read, setBufferSize, setExternalVocabularies, setForceStreamClose, setParseFragments, setRegisteredEncodingAlgorithms, setStringInterning, setVocabulary
-
Field Details
-
logger
-
INTERNAL_STATE_START_DOCUMENT
protected static final int INTERNAL_STATE_START_DOCUMENT- See Also:
-
INTERNAL_STATE_START_ELEMENT_TERMINATE
protected static final int INTERNAL_STATE_START_ELEMENT_TERMINATE- See Also:
-
INTERNAL_STATE_SINGLE_TERMINATE_ELEMENT_WITH_NAMESPACES
protected static final int INTERNAL_STATE_SINGLE_TERMINATE_ELEMENT_WITH_NAMESPACES- See Also:
-
INTERNAL_STATE_DOUBLE_TERMINATE_ELEMENT
protected static final int INTERNAL_STATE_DOUBLE_TERMINATE_ELEMENT- See Also:
-
INTERNAL_STATE_END_DOCUMENT
protected static final int INTERNAL_STATE_END_DOCUMENT- See Also:
-
INTERNAL_STATE_VOID
protected static final int INTERNAL_STATE_VOID- See Also:
-
_internalState
protected int _internalState -
_eventType
protected int _eventTypeCurrent event -
_qNameStack
Stack of qualified names and namespaces -
_namespaceAIIsStartStack
protected int[] _namespaceAIIsStartStack -
_namespaceAIIsEndStack
protected int[] _namespaceAIIsEndStack -
_stackCount
protected int _stackCount -
_namespaceAIIsPrefix
-
_namespaceAIIsNamespaceName
-
_namespaceAIIsPrefixIndex
protected int[] _namespaceAIIsPrefixIndex -
_namespaceAIIsIndex
protected int _namespaceAIIsIndex -
_currentNamespaceAIIsStart
protected int _currentNamespaceAIIsStartNamespaces associated with START_ELEMENT or END_ELEMENT -
_currentNamespaceAIIsEnd
protected int _currentNamespaceAIIsEnd -
_qualifiedName
Qualified name associated with START_ELEMENT or END_ELEMENT. -
_attributes
List of attributes -
_clearAttributes
protected boolean _clearAttributes -
_characters
protected char[] _charactersCharacters associated with event. -
_charactersOffset
protected int _charactersOffset -
_algorithmURI
-
_algorithmId
protected int _algorithmId -
_isAlgorithmDataCloned
protected boolean _isAlgorithmDataCloned -
_algorithmData
protected byte[] _algorithmData -
_algorithmDataOffset
protected int _algorithmDataOffset -
_algorithmDataLength
protected int _algorithmDataLength -
_piTarget
State for processing instruction -
_piData
-
_nsContext
-
_characterEncodingScheme
-
_manager
-
base64TaleBytes
private byte[] base64TaleBytes -
base64TaleLength
private int base64TaleLength
-
-
Constructor Details
-
StAXDocumentParser
public StAXDocumentParser() -
StAXDocumentParser
-
StAXDocumentParser
-
-
Method Details
-
setInputStream
Description copied from class:Decoder
Set the InputStream to decode the fast infoset document.- Overrides:
setInputStream
in classDecoder
- Parameters:
s
- the InputStream where the fast infoset document is decoded from.
-
reset
public void reset()Description copied from class:Decoder
Reset the decoder for reuse decoding another XML infoset. -
resetOnError
protected void resetOnError() -
getProperty
- Specified by:
getProperty
in interfaceXMLStreamReader
- Throws:
IllegalArgumentException
-
next
- Specified by:
next
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
processUtf8CharacterString
- Throws:
IOException
-
processUtf16CharacterString
- Throws:
IOException
-
popStack
private void popStack() -
require
public final void require(int type, String namespaceURI, String localName) throws XMLStreamException Test if the current event is of the given type and if the namespace and name match the current namespace and name of the current event. If the namespaceURI is null it is not checked for equality, if the localName is null it is not checked for equality.- Specified by:
require
in interfaceXMLStreamReader
- Parameters:
type
- the event typenamespaceURI
- the uri of the event, may be nulllocalName
- the localName of the event, may be null- Throws:
XMLStreamException
- if the required values are not matched.
-
getElementText
Reads the content of a text-only element. Precondition: the current event is START_ELEMENT. Postcondition: The current event is the corresponding END_ELEMENT.- Specified by:
getElementText
in interfaceXMLStreamReader
- Throws:
XMLStreamException
- if the current event is not a START_ELEMENT or if a non text element is encountered
-
getElementText
- Parameters:
startElementRead
- flag if start element has already been read- Throws:
XMLStreamException
-
nextTag
Skips any white space (isWhiteSpace() returns true), COMMENT, or PROCESSING_INSTRUCTION, until a START_ELEMENT or END_ELEMENT is reached. If other than white space characters, COMMENT, PROCESSING_INSTRUCTION, START_ELEMENT, END_ELEMENT are encountered, an exception is thrown. This method should be used when processing element-only content seperated by white space. This method should be used when processing element-only content because the parser is not able to recognize ignorable whitespace if then DTD is missing or not interpreted.- Specified by:
nextTag
in interfaceXMLStreamReader
- Returns:
- the event type of the element read
- Throws:
XMLStreamException
- if the current event is not white space
-
nextTag
if the current tag has already read, such as in the case EventReader's peek() has been called, the current cursor should not move before the loop- Throws:
XMLStreamException
-
hasNext
- Specified by:
hasNext
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
close
- Specified by:
close
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
isStartElement
public final boolean isStartElement()- Specified by:
isStartElement
in interfaceXMLStreamReader
-
isEndElement
public final boolean isEndElement()- Specified by:
isEndElement
in interfaceXMLStreamReader
-
isCharacters
public final boolean isCharacters()- Specified by:
isCharacters
in interfaceXMLStreamReader
-
isWhiteSpace
public final boolean isWhiteSpace()Returns true if the cursor points to a character data event that consists of all whitespace Application calling this method needs to cache the value and avoid calling this method again for the same event.- Specified by:
isWhiteSpace
in interfaceXMLStreamReader
- Returns:
- true if the cursor points to all whitespace, false otherwise
-
getAttributeValue
- Specified by:
getAttributeValue
in interfaceXMLStreamReader
-
getAttributeCount
public final int getAttributeCount()- Specified by:
getAttributeCount
in interfaceXMLStreamReader
-
getAttributeName
- Specified by:
getAttributeName
in interfaceXMLStreamReader
-
getAttributeNamespace
- Specified by:
getAttributeNamespace
in interfaceXMLStreamReader
-
getAttributeLocalName
- Specified by:
getAttributeLocalName
in interfaceXMLStreamReader
-
getAttributePrefix
- Specified by:
getAttributePrefix
in interfaceXMLStreamReader
-
getAttributeType
- Specified by:
getAttributeType
in interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValue
in interfaceXMLStreamReader
-
isAttributeSpecified
public final boolean isAttributeSpecified(int index) - Specified by:
isAttributeSpecified
in interfaceXMLStreamReader
-
getNamespaceCount
public final int getNamespaceCount()- Specified by:
getNamespaceCount
in interfaceXMLStreamReader
-
getNamespacePrefix
- Specified by:
getNamespacePrefix
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getNamespaceContext
- Specified by:
getNamespaceContext
in interfaceXMLStreamReader
-
getEventType
public final int getEventType()- Specified by:
getEventType
in interfaceXMLStreamReader
-
getText
- Specified by:
getText
in interfaceXMLStreamReader
-
getTextCharacters
public final char[] getTextCharacters()- Specified by:
getTextCharacters
in interfaceXMLStreamReader
-
getTextStart
public final int getTextStart()- Specified by:
getTextStart
in interfaceXMLStreamReader
-
getTextLength
public final int getTextLength()- Specified by:
getTextLength
in interfaceXMLStreamReader
-
getTextCharacters
public final int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException - Specified by:
getTextCharacters
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
checkTextState
protected final void checkTextState() -
getEncoding
- Specified by:
getEncoding
in interfaceXMLStreamReader
-
hasText
public final boolean hasText()- Specified by:
hasText
in interfaceXMLStreamReader
-
getLocation
- Specified by:
getLocation
in interfaceXMLStreamReader
-
getName
- Specified by:
getName
in interfaceXMLStreamReader
-
getLocalName
- Specified by:
getLocalName
in interfaceXMLStreamReader
-
hasName
public final boolean hasName()- Specified by:
hasName
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefix
in interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersion
in interfaceXMLStreamReader
-
isStandalone
public final boolean isStandalone()- Specified by:
isStandalone
in interfaceXMLStreamReader
-
standaloneSet
public final boolean standaloneSet()- Specified by:
standaloneSet
in interfaceXMLStreamReader
-
getCharacterEncodingScheme
- Specified by:
getCharacterEncodingScheme
in interfaceXMLStreamReader
-
getPITarget
- Specified by:
getPITarget
in interfaceXMLStreamReader
-
getPIData
- Specified by:
getPIData
in interfaceXMLStreamReader
-
getNameString
-
getAttributeNameString
-
getTextAlgorithmURI
-
getTextAlgorithmIndex
public final int getTextAlgorithmIndex() -
hasTextAlgorithmBytes
public final boolean hasTextAlgorithmBytes() -
getTextAlgorithmBytes
public final byte[] getTextAlgorithmBytes()Returns the byte[], which represents text algorithms.Was deprecated due to security reasons. Now the method return cloned byte[].
-
getTextAlgorithmBytesClone
public final byte[] getTextAlgorithmBytesClone() -
getTextAlgorithmStart
public final int getTextAlgorithmStart() -
getTextAlgorithmLength
public final int getTextAlgorithmLength() -
getTextAlgorithmBytes
public final int getTextAlgorithmBytes(int sourceStart, byte[] target, int targetStart, int length) throws XMLStreamException - Throws:
XMLStreamException
-
peekNext
Description copied from interface:FastInfosetStreamReader
Peek at the next event.- Specified by:
peekNext
in interfaceFastInfosetStreamReader
- Returns:
- the event, which will be the same as that returned from
XMLStreamReader.next()
. - Throws:
XMLStreamException
-
onBeforeOctetBufferOverwrite
public void onBeforeOctetBufferOverwrite()Description copied from interface:OctetBufferListener
Callback method that will be called before the (@link Decoder) octet buffer content is going to be changed. So it will be possible to preserve a read data by cloning, or perform other actions.- Specified by:
onBeforeOctetBufferOverwrite
in interfaceOctetBufferListener
-
accessNamespaceCount
public final int accessNamespaceCount()- Specified by:
accessNamespaceCount
in interfaceFastInfosetStreamReader
-
accessLocalName
- Specified by:
accessLocalName
in interfaceFastInfosetStreamReader
-
accessNamespaceURI
- Specified by:
accessNamespaceURI
in interfaceFastInfosetStreamReader
-
accessPrefix
- Specified by:
accessPrefix
in interfaceFastInfosetStreamReader
-
accessTextCharacters
public final char[] accessTextCharacters()Description copied from interface:FastInfosetStreamReader
Returns a cloned char[] representation of the internal char[] buffer. So be careful, when using this method due to possible performance and memory inefficiency.- Specified by:
accessTextCharacters
in interfaceFastInfosetStreamReader
- Returns:
- a cloned char[] representation of the internal char[] buffer.
-
accessTextStart
public final int accessTextStart()- Specified by:
accessTextStart
in interfaceFastInfosetStreamReader
-
accessTextLength
public final int accessTextLength()- Specified by:
accessTextLength
in interfaceFastInfosetStreamReader
-
processDII
- Throws:
FastInfosetException
IOException
-
processDIIOptionalProperties
- Throws:
FastInfosetException
IOException
-
resizeNamespaceAIIs
protected final void resizeNamespaceAIIs() -
processEIIWithNamespaces
protected final void processEIIWithNamespaces(boolean hasAttributes) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-
processEII
protected final void processEII(QualifiedName name, boolean hasAttributes) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-
processAIIs
- Throws:
FastInfosetException
IOException
-
processEIIIndexMedium
- Throws:
FastInfosetException
IOException
-
processEIIIndexLarge
- Throws:
FastInfosetException
IOException
-
processLiteralQualifiedName
protected final QualifiedName processLiteralQualifiedName(int state, QualifiedName q) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-
processCommentII
- Throws:
FastInfosetException
IOException
-
processProcessingII
- Throws:
FastInfosetException
IOException
-
processUnexpandedEntityReference
protected final void processUnexpandedEntityReference(int b) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-
processCIIEncodingAlgorithm
protected final void processCIIEncodingAlgorithm(boolean addToTable) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-
processAIIEncodingAlgorithm
protected final void processAIIEncodingAlgorithm(QualifiedName name, boolean addToTable) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-
convertEncodingAlgorithmDataToCharacters
protected final void convertEncodingAlgorithmDataToCharacters() throws FastInfosetException, IOException- Throws:
FastInfosetException
IOException
-
convertBase64AlorithmDataToCharacters
protected void convertBase64AlorithmDataToCharacters(StringBuilder buffer) throws EncodingAlgorithmException, IOException -
convertBase64AlorithmDataToCharacters
@Deprecated(since="2.1.1", forRemoval=true) protected void convertBase64AlorithmDataToCharacters(StringBuffer buffer) throws EncodingAlgorithmException, IOException Deprecated, for removal: This API element is subject to removal in a future version.UseconvertBase64AlorithmDataToCharacters(StringBuilder)
instead. -
base64DecodeWithCloning
private void base64DecodeWithCloning(StringBuilder dstBuffer, byte[] data, int offset, int length) throws EncodingAlgorithmException - Throws:
EncodingAlgorithmException
-
base64DecodeWithoutCloning
private void base64DecodeWithoutCloning(StringBuilder dstBuffer, byte[] data, int offset, int length) throws EncodingAlgorithmException - Throws:
EncodingAlgorithmException
-
isBase64Follows
- Throws:
IOException
-
getNamespaceDecl
-
getURI
-
getPrefixes
-
getAttributesHolder
-
setManager
-
getEventTypeString
-
convertBase64AlorithmDataToCharacters(StringBuilder)
instead.