Package com.sun.xml.stream.buffer.stax
Class StreamReaderBufferProcessor
java.lang.Object
com.sun.xml.stream.buffer.AbstractCreatorProcessor
com.sun.xml.stream.buffer.AbstractProcessor
com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor
- All Implemented Interfaces:
XMLStreamConstants
,XMLStreamReader
,org.jvnet.staxex.XMLStreamReaderEx
public class StreamReaderBufferProcessor
extends AbstractProcessor
implements org.jvnet.staxex.XMLStreamReaderEx
A processor of a
XMLStreamBuffer
that reads the XML infoset as
XMLStreamReader
.
Because of XMLStreamReader
design, this processor always produce
a full document infoset, even if the buffer just contains a fragment.
When XMLStreamBuffer
contains a multiple tree (AKA "forest"),
XMLStreamReader
will behave as if there are multiple root elements
(so you'll see XMLStreamConstants.START_ELEMENT
event where you'd normally expect
XMLStreamConstants.END_DOCUMENT
.)
- Author:
- [email protected], [email protected]
-
Field Summary
Modifier and TypeFieldDescriptionprotected AttributesHolder
Holder of the attributes.protected char[]
protected CharSequence
protected int
The element depth that we are in.protected int
protected int
protected String[]
protected String[]
Namespace prefixes.protected String
protected String
protected int
protected int
Fields inherited from class com.sun.xml.stream.buffer.AbstractProcessor
_buffer, _fragmentMode, _qNameBuffer, _stringInterningFeature, _treeCount, STATE_ATTRIBUTE_LN, STATE_ATTRIBUTE_LN_OBJECT, STATE_ATTRIBUTE_P_U_LN, STATE_ATTRIBUTE_P_U_LN_OBJECT, STATE_ATTRIBUTE_U_LN, STATE_ATTRIBUTE_U_LN_OBJECT, STATE_ATTRIBUTE_U_LN_QN, STATE_ATTRIBUTE_U_LN_QN_OBJECT, STATE_COMMENT_AS_CHAR_ARRAY_COPY, STATE_COMMENT_AS_CHAR_ARRAY_MEDIUM, STATE_COMMENT_AS_CHAR_ARRAY_SMALL, STATE_COMMENT_AS_STRING, STATE_DOCUMENT, STATE_DOCUMENT_FRAGMENT, STATE_ELEMENT_LN, STATE_ELEMENT_P_U_LN, STATE_ELEMENT_U_LN, STATE_ELEMENT_U_LN_QN, STATE_END, STATE_ILLEGAL, STATE_NAMESPACE_ATTRIBUTE, STATE_NAMESPACE_ATTRIBUTE_P, STATE_NAMESPACE_ATTRIBUTE_P_U, STATE_NAMESPACE_ATTRIBUTE_U, STATE_PROCESSING_INSTRUCTION, STATE_TEXT_AS_CHAR_ARRAY_COPY, STATE_TEXT_AS_CHAR_ARRAY_MEDIUM, STATE_TEXT_AS_CHAR_ARRAY_SMALL, STATE_TEXT_AS_OBJECT, STATE_TEXT_AS_STRING
Fields inherited from class com.sun.xml.stream.buffer.AbstractCreatorProcessor
_contentCharactersBuffer, _contentCharactersBufferPtr, _contentObjects, _contentObjectsPtr, _currentContentCharactersBufferFragment, _currentContentObjectFragment, _currentStructureFragment, _currentStructureStringFragment, _structure, _structurePtr, _structureStrings, _structureStringsPtr, CHAR_ARRAY_LENGTH_MEDIUM, CHAR_ARRAY_LENGTH_MEDIUM_SIZE, CHAR_ARRAY_LENGTH_SMALL, CHAR_ARRAY_LENGTH_SMALL_SIZE, CONTENT_TYPE_CHAR_ARRAY, CONTENT_TYPE_CHAR_ARRAY_COPY, CONTENT_TYPE_OBJECT, CONTENT_TYPE_STRING, FLAG_DOCUMENT_FRAGMENT, FLAG_PREFIX, FLAG_QUALIFIED_NAME, FLAG_URI, T_ATTRIBUTE, T_ATTRIBUTE_LN, T_ATTRIBUTE_LN_OBJECT, T_ATTRIBUTE_P_U_LN, T_ATTRIBUTE_P_U_LN_OBJECT, T_ATTRIBUTE_U_LN, T_ATTRIBUTE_U_LN_OBJECT, T_ATTRIBUTE_U_LN_QN, T_ATTRIBUTE_U_LN_QN_OBJECT, T_COMMENT, T_COMMENT_AS_CHAR_ARRAY, T_COMMENT_AS_CHAR_ARRAY_COPY, T_COMMENT_AS_CHAR_ARRAY_MEDIUM, T_COMMENT_AS_CHAR_ARRAY_SMALL, T_COMMENT_AS_STRING, T_DOCUMENT, T_DOCUMENT_FRAGMENT, T_ELEMENT, T_ELEMENT_LN, T_ELEMENT_P_U_LN, T_ELEMENT_U_LN, T_ELEMENT_U_LN_QN, T_END, T_END_OF_BUFFER, T_NAMESPACE_ATTRIBUTE, T_NAMESPACE_ATTRIBUTE_P, T_NAMESPACE_ATTRIBUTE_P_U, T_NAMESPACE_ATTRIBUTE_U, T_PROCESSING_INSTRUCTION, T_TEXT, T_TEXT_AS_CHAR_ARRAY, T_TEXT_AS_CHAR_ARRAY_COPY, T_TEXT_AS_CHAR_ARRAY_MEDIUM, T_TEXT_AS_CHAR_ARRAY_SMALL, T_TEXT_AS_OBJECT, T_TEXT_AS_STRING, T_UNEXPANDED_ENTITY_REFERENCE, TYPE_MASK, VALUE_TYPE_OBJECT, VALUE_TYPE_STRING
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
ConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
final int
final String
getAttributeLocalName
(int index) final QName
getAttributeName
(int index) final String
getAttributeNamespace
(int index) final String
getAttributePrefix
(int index) final String
getAttributeType
(int index) final String
getAttributeValue
(int index) final String
getAttributeValue
(String namespaceURI, String localName) final String
final String
final String
getElementText
(boolean startElementRead) final String
final String
final int
final String
final Location
final QName
getName()
final org.jvnet.staxex.NamespaceContextEx
final int
final String
getNamespacePrefix
(int index) final String
final String
getNamespaceURI
(int index) final String
getNamespaceURI
(String prefix) final CharSequence
final String
final String
final String
getProperty
(String name) final String
getText()
final char[]
final int
getTextCharacters
(int sourceStart, char[] target, int targetStart, int length) final int
final int
final String
final boolean
hasName()
final boolean
hasNext()
final boolean
hasText()
final boolean
isAttributeSpecified
(int index) final boolean
final boolean
final boolean
final boolean
final boolean
int
next()
final int
nextTag()
final int
nextTag
(boolean currentTagRead) DoesnextTag()
and if the parser moved to a new start tag, returns aXMLStreamBufferMark
that captures the infoset starting from the newly discovered element.protected void
processElement
(String prefix, String uri, String localName, boolean inscope) final void
void
setXMLStreamBuffer
(XMLStreamBuffer buffer) final boolean
Methods inherited from class com.sun.xml.stream.buffer.AbstractProcessor
getAIIState, getEIIState, getNIIState, getPrefixFromQName, getQName, peekStructure, readContentCharactersBuffer, readContentCharactersCopy, readContentObject, readContentString, readEiiState, readStructure, readStructure16, readStructureString, setBuffer, setBuffer
-
Field Details
-
_depth
protected int _depthThe element depth that we are in. Used to determine when we are done with a tree. -
_namespaceAIIsPrefix
Namespace prefixes. Can be empty but not null. -
_namespaceAIIsNamespaceName
-
_namespaceAIIsEnd
protected int _namespaceAIIsEnd -
_eventType
protected int _eventType -
_attributeCache
Holder of the attributes. Be careful that this follows the SAX convention of using "" instead of null. -
_charSequence
-
_characters
protected char[] _characters -
_textOffset
protected int _textOffset -
_textLen
protected int _textLen -
_piTarget
-
_piData
-
-
Constructor Details
-
StreamReaderBufferProcessor
public StreamReaderBufferProcessor() -
StreamReaderBufferProcessor
- Throws:
XMLStreamException
-
-
Method Details
-
setXMLStreamBuffer
- Throws:
XMLStreamException
-
nextTagAndMark
DoesnextTag()
and if the parser moved to a new start tag, returns aXMLStreamBufferMark
that captures the infoset starting from the newly discovered element.(Ideally we should have a method that works against the current position, but the way the data structure is read makes this somewhat difficult.) This creates a new
XMLStreamBufferMark
that shares the underlying data storage, thus it's fairly efficient.- Throws:
XMLStreamException
-
getProperty
- Specified by:
getProperty
in interfaceXMLStreamReader
-
next
- Specified by:
next
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
require
public final void require(int type, String namespaceURI, String localName) throws XMLStreamException - Specified by:
require
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
getElementTextTrim
- Specified by:
getElementTextTrim
in interfaceorg.jvnet.staxex.XMLStreamReaderEx
- Throws:
XMLStreamException
-
getElementText
- Specified by:
getElementText
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
getElementText
- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTag
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
nextTag
- Throws:
XMLStreamException
-
hasNext
public final boolean hasNext()- Specified by:
hasNext
in interfaceXMLStreamReader
-
close
- Specified by:
close
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
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()- Specified by:
isWhiteSpace
in interfaceXMLStreamReader
-
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
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getNamespaceContext
public final org.jvnet.staxex.NamespaceContextEx getNamespaceContext()- Specified by:
getNamespaceContext
in interfaceXMLStreamReader
- Specified by:
getNamespaceContext
in interfaceorg.jvnet.staxex.XMLStreamReaderEx
-
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
-
getPCDATA
- Specified by:
getPCDATA
in interfaceorg.jvnet.staxex.XMLStreamReaderEx
-
getEncoding
- Specified by:
getEncoding
in interfaceXMLStreamReader
-
hasText
public final boolean hasText()- Specified by:
hasText
in interfaceXMLStreamReader
-
getLocation
- Specified by:
getLocation
in interfaceXMLStreamReader
-
hasName
public final boolean hasName()- Specified by:
hasName
in interfaceXMLStreamReader
-
getName
- Specified by:
getName
in interfaceXMLStreamReader
-
getLocalName
- Specified by:
getLocalName
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
-
processElement
-