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:
- Paul.Sandoz@Sun.Com, K.Venugopal@sun.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AttributesHolderHolder of the attributes.protected char[]protected CharSequenceprotected intThe element depth that we are in.protected intprotected intprotected String[]protected String[]Namespace prefixes.protected Stringprotected Stringprotected intprotected intFields 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_STRINGFields 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_STRINGFields 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
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()final intfinal StringgetAttributeLocalName(int index) final QNamegetAttributeName(int index) final StringgetAttributeNamespace(int index) final StringgetAttributePrefix(int index) final StringgetAttributeType(int index) final StringgetAttributeValue(int index) final StringgetAttributeValue(String namespaceURI, String localName) final Stringfinal Stringfinal StringgetElementText(boolean startElementRead) final Stringfinal Stringfinal intfinal Stringfinal Locationfinal QNamegetName()final org.jvnet.staxex.NamespaceContextExfinal intfinal StringgetNamespacePrefix(int index) final Stringfinal StringgetNamespaceURI(int index) final StringgetNamespaceURI(String prefix) final CharSequencefinal Stringfinal Stringfinal StringgetProperty(String name) final StringgetText()final char[]final intgetTextCharacters(int sourceStart, char[] target, int targetStart, int length) final intfinal intfinal Stringfinal booleanhasName()final booleanhasNext()final booleanhasText()final booleanisAttributeSpecified(int index) final booleanfinal booleanfinal booleanfinal booleanfinal booleanintnext()final intnextTag()final intnextTag(boolean currentTagRead) DoesnextTag()and if the parser moved to a new start tag, returns aXMLStreamBufferMarkthat captures the infoset starting from the newly discovered element.protected voidprocessElement(String prefix, String uri, String localName, boolean inscope) final voidvoidsetXMLStreamBuffer(XMLStreamBuffer buffer) final booleanMethods 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 aXMLStreamBufferMarkthat 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
XMLStreamBufferMarkthat shares the underlying data storage, thus it's fairly efficient.- Throws:
XMLStreamException
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamReader
-
next
- Specified by:
nextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
require
public final void require(int type, String namespaceURI, String localName) throws XMLStreamException - Specified by:
requirein interfaceXMLStreamReader- Throws:
XMLStreamException
-
getElementTextTrim
- Specified by:
getElementTextTrimin interfaceorg.jvnet.staxex.XMLStreamReaderEx- Throws:
XMLStreamException
-
getElementText
- Specified by:
getElementTextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getElementText
- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTagin interfaceXMLStreamReader- Throws:
XMLStreamException
-
nextTag
- Throws:
XMLStreamException
-
hasNext
public final boolean hasNext()- Specified by:
hasNextin interfaceXMLStreamReader
-
close
- Specified by:
closein interfaceXMLStreamReader- Throws:
XMLStreamException
-
isStartElement
public final boolean isStartElement()- Specified by:
isStartElementin interfaceXMLStreamReader
-
isEndElement
public final boolean isEndElement()- Specified by:
isEndElementin interfaceXMLStreamReader
-
isCharacters
public final boolean isCharacters()- Specified by:
isCharactersin interfaceXMLStreamReader
-
isWhiteSpace
public final boolean isWhiteSpace()- Specified by:
isWhiteSpacein interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getAttributeCount
public final int getAttributeCount()- Specified by:
getAttributeCountin interfaceXMLStreamReader
-
getAttributeName
- Specified by:
getAttributeNamein interfaceXMLStreamReader
-
getAttributeNamespace
- Specified by:
getAttributeNamespacein interfaceXMLStreamReader
-
getAttributeLocalName
- Specified by:
getAttributeLocalNamein interfaceXMLStreamReader
-
getAttributePrefix
- Specified by:
getAttributePrefixin interfaceXMLStreamReader
-
getAttributeType
- Specified by:
getAttributeTypein interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
isAttributeSpecified
public final boolean isAttributeSpecified(int index) - Specified by:
isAttributeSpecifiedin interfaceXMLStreamReader
-
getNamespaceCount
public final int getNamespaceCount()- Specified by:
getNamespaceCountin interfaceXMLStreamReader
-
getNamespacePrefix
- Specified by:
getNamespacePrefixin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceContext
public final org.jvnet.staxex.NamespaceContextEx getNamespaceContext()- Specified by:
getNamespaceContextin interfaceXMLStreamReader- Specified by:
getNamespaceContextin interfaceorg.jvnet.staxex.XMLStreamReaderEx
-
getEventType
public final int getEventType()- Specified by:
getEventTypein interfaceXMLStreamReader
-
getText
- Specified by:
getTextin interfaceXMLStreamReader
-
getTextCharacters
public final char[] getTextCharacters()- Specified by:
getTextCharactersin interfaceXMLStreamReader
-
getTextStart
public final int getTextStart()- Specified by:
getTextStartin interfaceXMLStreamReader
-
getTextLength
public final int getTextLength()- Specified by:
getTextLengthin interfaceXMLStreamReader
-
getTextCharacters
public final int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException - Specified by:
getTextCharactersin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getPCDATA
- Specified by:
getPCDATAin interfaceorg.jvnet.staxex.XMLStreamReaderEx
-
getEncoding
- Specified by:
getEncodingin interfaceXMLStreamReader
-
hasText
public final boolean hasText()- Specified by:
hasTextin interfaceXMLStreamReader
-
getLocation
- Specified by:
getLocationin interfaceXMLStreamReader
-
hasName
public final boolean hasName()- Specified by:
hasNamein interfaceXMLStreamReader
-
getName
- Specified by:
getNamein interfaceXMLStreamReader
-
getLocalName
- Specified by:
getLocalNamein interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersionin interfaceXMLStreamReader
-
isStandalone
public final boolean isStandalone()- Specified by:
isStandalonein interfaceXMLStreamReader
-
standaloneSet
public final boolean standaloneSet()- Specified by:
standaloneSetin interfaceXMLStreamReader
-
getCharacterEncodingScheme
- Specified by:
getCharacterEncodingSchemein interfaceXMLStreamReader
-
getPITarget
- Specified by:
getPITargetin interfaceXMLStreamReader
-
getPIData
- Specified by:
getPIDatain interfaceXMLStreamReader
-
processElement
-