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,XMLStreamReaderEx
public class StreamReaderBufferProcessor extends AbstractProcessor implements XMLStreamReaderEx
A processor of aXMLStreamBufferthat reads the XML infoset asXMLStreamReader.Because of
XMLStreamReaderdesign, this processor always produce a full document infoset, even if the buffer just contains a fragment.When
XMLStreamBuffercontains a multiple tree (AKA "forest"),XMLStreamReaderwill behave as if there are multiple root elements (so you'll seeXMLStreamConstants.START_ELEMENTevent where you'd normally expectXMLStreamConstants.END_DOCUMENT.)- Author:
- Paul.Sandoz@Sun.Com, K.Venugopal@sun.com
-
-
Field Summary
Fields Modifier and Type Field Description protected AttributesHolder_attributeCacheHolder of the attributes.protected char[]_charactersprotected CharSequence_charSequenceprotected int_depthThe element depth that we are in.protected int_eventTypeprotected int_namespaceAIIsEndprotected String[]_namespaceAIIsNamespaceNameprotected String[]_namespaceAIIsPrefixNamespace prefixes.protected com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.InternalNamespaceContext_nsCtxprotected String_piDataprotected String_piTargetprotected com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.ElementStackEntry[]_stackprotected com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.ElementStackEntry_stackTopThe top-most active entry of the_stack.protected int_textLenprotected int_textOffset-
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
Constructors Constructor Description StreamReaderBufferProcessor()StreamReaderBufferProcessor(XMLStreamBuffer buffer)
-
Method Summary
-
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 Detail
-
_stack
protected com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.ElementStackEntry[] _stack
-
_stackTop
protected com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.ElementStackEntry _stackTop
The top-most active entry of the_stack.
-
_depth
protected int _depth
The element depth that we are in. Used to determine when we are done with a tree.
-
_namespaceAIIsPrefix
protected String[] _namespaceAIIsPrefix
Namespace prefixes. Can be empty but not null.
-
_namespaceAIIsNamespaceName
protected String[] _namespaceAIIsNamespaceName
-
_namespaceAIIsEnd
protected int _namespaceAIIsEnd
-
_nsCtx
protected com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.InternalNamespaceContext _nsCtx
-
_eventType
protected int _eventType
-
_attributeCache
protected AttributesHolder _attributeCache
Holder of the attributes. Be careful that this follows the SAX convention of using "" instead of null.
-
_charSequence
protected CharSequence _charSequence
-
_characters
protected char[] _characters
-
_textOffset
protected int _textOffset
-
_textLen
protected int _textLen
-
_piTarget
protected String _piTarget
-
_piData
protected String _piData
-
-
Constructor Detail
-
StreamReaderBufferProcessor
public StreamReaderBufferProcessor()
-
StreamReaderBufferProcessor
public StreamReaderBufferProcessor(XMLStreamBuffer buffer) throws XMLStreamException
- Throws:
XMLStreamException
-
-
Method Detail
-
setXMLStreamBuffer
public void setXMLStreamBuffer(XMLStreamBuffer buffer) throws XMLStreamException
- Throws:
XMLStreamException
-
nextTagAndMark
public XMLStreamBuffer nextTagAndMark() throws XMLStreamException
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
public Object getProperty(String name)
- Specified by:
getPropertyin interfaceXMLStreamReader
-
next
public int next() throws XMLStreamException- 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
public final String getElementTextTrim() throws XMLStreamException
Description copied from interface:XMLStreamReaderExWorks likeXMLStreamReader.getElementText()but trims the leading and trailing whitespace.The parser can often do this more efficiently than
getElementText().trim().- Specified by:
getElementTextTrimin interfaceXMLStreamReaderEx- Throws:
XMLStreamException- See Also:
XMLStreamReader.getElementText()
-
getElementText
public final String getElementText() throws XMLStreamException
- Specified by:
getElementTextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getElementText
public final String getElementText(boolean startElementRead) throws XMLStreamException
- Throws:
XMLStreamException
-
nextTag
public final int nextTag() throws XMLStreamException- Specified by:
nextTagin interfaceXMLStreamReader- Throws:
XMLStreamException
-
nextTag
public final int nextTag(boolean currentTagRead) throws XMLStreamException- Throws:
XMLStreamException
-
hasNext
public final boolean hasNext()
- Specified by:
hasNextin interfaceXMLStreamReader
-
close
public void close() throws XMLStreamException- 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
public final String getAttributeValue(String namespaceURI, String localName)
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getAttributeCount
public final int getAttributeCount()
- Specified by:
getAttributeCountin interfaceXMLStreamReader
-
getAttributeName
public final QName getAttributeName(int index)
- Specified by:
getAttributeNamein interfaceXMLStreamReader
-
getAttributeNamespace
public final String getAttributeNamespace(int index)
- Specified by:
getAttributeNamespacein interfaceXMLStreamReader
-
getAttributeLocalName
public final String getAttributeLocalName(int index)
- Specified by:
getAttributeLocalNamein interfaceXMLStreamReader
-
getAttributePrefix
public final String getAttributePrefix(int index)
- Specified by:
getAttributePrefixin interfaceXMLStreamReader
-
getAttributeType
public final String getAttributeType(int index)
- Specified by:
getAttributeTypein interfaceXMLStreamReader
-
getAttributeValue
public final String getAttributeValue(int index)
- 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
public final String getNamespacePrefix(int index)
- Specified by:
getNamespacePrefixin interfaceXMLStreamReader
-
getNamespaceURI
public final String getNamespaceURI(int index)
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceURI
public final String getNamespaceURI(String prefix)
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceContext
public final NamespaceContextEx getNamespaceContext()
Description copied from interface:XMLStreamReaderEx- Specified by:
getNamespaceContextin interfaceXMLStreamReader- Specified by:
getNamespaceContextin interfaceXMLStreamReaderEx
-
getEventType
public final int getEventType()
- Specified by:
getEventTypein interfaceXMLStreamReader
-
getText
public final String 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
public final CharSequence getPCDATA()
Description copied from interface:XMLStreamReaderExWorks likeXMLStreamReader.getText()but hides the actual data representation.- Specified by:
getPCDATAin interfaceXMLStreamReaderEx- Returns:
- The
CharSequencethat represents the character infoset items at the current position.The
CharSequenceis normally aString, but can be any otherCharSequenceimplementation. For binary data, however, use ofBase64Datais recommended (so that the consumer interested in seeing it as binary data may take advantage of mor efficient data representation.)The object returned from this method belongs to the parser, and its content is guaranteed to be the same only until the
XMLStreamReader.next()method is invoked.
-
getEncoding
public final String getEncoding()
- Specified by:
getEncodingin interfaceXMLStreamReader
-
hasText
public final boolean hasText()
- Specified by:
hasTextin interfaceXMLStreamReader
-
getLocation
public final Location getLocation()
- Specified by:
getLocationin interfaceXMLStreamReader
-
hasName
public final boolean hasName()
- Specified by:
hasNamein interfaceXMLStreamReader
-
getName
public final QName getName()
- Specified by:
getNamein interfaceXMLStreamReader
-
getLocalName
public final String getLocalName()
- Specified by:
getLocalNamein interfaceXMLStreamReader
-
getNamespaceURI
public final String getNamespaceURI()
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getPrefix
public final String getPrefix()
- Specified by:
getPrefixin interfaceXMLStreamReader
-
getVersion
public final String getVersion()
- Specified by:
getVersionin interfaceXMLStreamReader
-
isStandalone
public final boolean isStandalone()
- Specified by:
isStandalonein interfaceXMLStreamReader
-
standaloneSet
public final boolean standaloneSet()
- Specified by:
standaloneSetin interfaceXMLStreamReader
-
getCharacterEncodingScheme
public final String getCharacterEncodingScheme()
- Specified by:
getCharacterEncodingSchemein interfaceXMLStreamReader
-
getPITarget
public final String getPITarget()
- Specified by:
getPITargetin interfaceXMLStreamReader
-
getPIData
public final String getPIData()
- Specified by:
getPIDatain interfaceXMLStreamReader
-
-