com.sun.xml.stream.buffer.stax
Class StreamReaderBufferProcessor

java.lang.Object
  extended by com.sun.xml.stream.buffer.AbstractCreatorProcessor
      extended by com.sun.xml.stream.buffer.AbstractProcessor
          extended by com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor
All Implemented Interfaces:
XMLStreamConstants, XMLStreamReader, XMLStreamReaderEx

public class StreamReaderBufferProcessor
extends AbstractProcessor
implements 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
protected  AttributesHolder _attributeCache
          Holder of the attributes.
protected  char[] _characters
           
protected  CharSequence _charSequence
           
protected  int _depth
          The element depth that we are in.
protected  int _eventType
           
protected  int _namespaceAIIsEnd
           
protected  String[] _namespaceAIIsNamespaceName
           
protected  String[] _namespaceAIIsPrefix
          Namespace prefixes.
protected  com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.InternalNamespaceContext _nsCtx
           
protected  String _piData
           
protected  String _piTarget
           
protected  com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.ElementStackEntry[] _stack
           
protected  com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor.ElementStackEntry _stackTop
          The top-most active entry of the _stack.
protected  int _textLen
           
protected  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
StreamReaderBufferProcessor()
           
StreamReaderBufferProcessor(XMLStreamBuffer buffer)
           
 
Method Summary
 void close()
           
 int getAttributeCount()
           
 String getAttributeLocalName(int index)
           
 QName getAttributeName(int index)
           
 String getAttributeNamespace(int index)
           
 String getAttributePrefix(int index)
           
 String getAttributeType(int index)
           
 String getAttributeValue(int index)
           
 String getAttributeValue(String namespaceURI, String localName)
           
 String getCharacterEncodingScheme()
           
 String getElementText()
           
 String getElementText(boolean startElementRead)
           
 String getElementTextTrim()
          Works like XMLStreamReader.getElementText() but trims the leading and trailing whitespace.
 String getEncoding()
           
 int getEventType()
           
 String getLocalName()
           
 Location getLocation()
           
 QName getName()
           
 NamespaceContextEx getNamespaceContext()
          
 int getNamespaceCount()
           
 String getNamespacePrefix(int index)
           
 String getNamespaceURI()
           
 String getNamespaceURI(int index)
           
 String getNamespaceURI(String prefix)
           
 CharSequence getPCDATA()
          Works like XMLStreamReader.getText() but hides the actual data representation.
 String getPIData()
           
 String getPITarget()
           
 String getPrefix()
           
 Object getProperty(String name)
           
 String getText()
           
 char[] getTextCharacters()
           
 int getTextCharacters(int sourceStart, char[] target, int targetStart, int length)
           
 int getTextLength()
           
 int getTextStart()
           
 String getVersion()
           
 boolean hasName()
           
 boolean hasNext()
           
 boolean hasText()
           
 boolean isAttributeSpecified(int index)
           
 boolean isCharacters()
           
 boolean isEndElement()
           
 boolean isStandalone()
           
 boolean isStartElement()
           
 boolean isWhiteSpace()
           
 int next()
           
 int nextTag()
           
 int nextTag(boolean currentTagRead)
           
 XMLStreamBuffer nextTagAndMark()
          Does nextTag() and if the parser moved to a new start tag, returns a XMLStreamBufferMark that captures the infoset starting from the newly discovered element.
protected  void processElement(String prefix, String uri, String localName, boolean inscope)
           
 void require(int type, String namespaceURI, String localName)
           
 void setXMLStreamBuffer(XMLStreamBuffer buffer)
           
 boolean standaloneSet()
           
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Does nextTag() and if the parser moved to a new start tag, returns a XMLStreamBufferMark 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

public Object getProperty(String name)
Specified by:
getProperty in interface XMLStreamReader

next

public int next()
         throws XMLStreamException
Specified by:
next in interface XMLStreamReader
Throws:
XMLStreamException

require

public final void require(int type,
                          String namespaceURI,
                          String localName)
                   throws XMLStreamException
Specified by:
require in interface XMLStreamReader
Throws:
XMLStreamException

getElementTextTrim

public final String getElementTextTrim()
                                throws XMLStreamException
Description copied from interface: XMLStreamReaderEx
Works like XMLStreamReader.getElementText() but trims the leading and trailing whitespace.

The parser can often do this more efficiently than getElementText().trim().

Specified by:
getElementTextTrim in interface XMLStreamReaderEx
Throws:
XMLStreamException
See Also:
XMLStreamReader.getElementText()

getElementText

public final String getElementText()
                            throws XMLStreamException
Specified by:
getElementText in interface XMLStreamReader
Throws:
XMLStreamException

getElementText

public final String getElementText(boolean startElementRead)
                            throws XMLStreamException
Throws:
XMLStreamException

nextTag

public final int nextTag()
                  throws XMLStreamException
Specified by:
nextTag in interface XMLStreamReader
Throws:
XMLStreamException

nextTag

public final int nextTag(boolean currentTagRead)
                  throws XMLStreamException
Throws:
XMLStreamException

hasNext

public final boolean hasNext()
Specified by:
hasNext in interface XMLStreamReader

close

public void close()
           throws XMLStreamException
Specified by:
close in interface XMLStreamReader
Throws:
XMLStreamException

isStartElement

public final boolean isStartElement()
Specified by:
isStartElement in interface XMLStreamReader

isEndElement

public final boolean isEndElement()
Specified by:
isEndElement in interface XMLStreamReader

isCharacters

public final boolean isCharacters()
Specified by:
isCharacters in interface XMLStreamReader

isWhiteSpace

public final boolean isWhiteSpace()
Specified by:
isWhiteSpace in interface XMLStreamReader

getAttributeValue

public final String getAttributeValue(String namespaceURI,
                                      String localName)
Specified by:
getAttributeValue in interface XMLStreamReader

getAttributeCount

public final int getAttributeCount()
Specified by:
getAttributeCount in interface XMLStreamReader

getAttributeName

public final QName getAttributeName(int index)
Specified by:
getAttributeName in interface XMLStreamReader

getAttributeNamespace

public final String getAttributeNamespace(int index)
Specified by:
getAttributeNamespace in interface XMLStreamReader

getAttributeLocalName

public final String getAttributeLocalName(int index)
Specified by:
getAttributeLocalName in interface XMLStreamReader

getAttributePrefix

public final String getAttributePrefix(int index)
Specified by:
getAttributePrefix in interface XMLStreamReader

getAttributeType

public final String getAttributeType(int index)
Specified by:
getAttributeType in interface XMLStreamReader

getAttributeValue

public final String getAttributeValue(int index)
Specified by:
getAttributeValue in interface XMLStreamReader

isAttributeSpecified

public final boolean isAttributeSpecified(int index)
Specified by:
isAttributeSpecified in interface XMLStreamReader

getNamespaceCount

public final int getNamespaceCount()
Specified by:
getNamespaceCount in interface XMLStreamReader

getNamespacePrefix

public final String getNamespacePrefix(int index)
Specified by:
getNamespacePrefix in interface XMLStreamReader

getNamespaceURI

public final String getNamespaceURI(int index)
Specified by:
getNamespaceURI in interface XMLStreamReader

getNamespaceURI

public final String getNamespaceURI(String prefix)
Specified by:
getNamespaceURI in interface XMLStreamReader

getNamespaceContext

public final NamespaceContextEx getNamespaceContext()
Description copied from interface: XMLStreamReaderEx

Specified by:
getNamespaceContext in interface XMLStreamReader
Specified by:
getNamespaceContext in interface XMLStreamReaderEx

getEventType

public final int getEventType()
Specified by:
getEventType in interface XMLStreamReader

getText

public final String getText()
Specified by:
getText in interface XMLStreamReader

getTextCharacters

public final char[] getTextCharacters()
Specified by:
getTextCharacters in interface XMLStreamReader

getTextStart

public final int getTextStart()
Specified by:
getTextStart in interface XMLStreamReader

getTextLength

public final int getTextLength()
Specified by:
getTextLength in interface XMLStreamReader

getTextCharacters

public final int getTextCharacters(int sourceStart,
                                   char[] target,
                                   int targetStart,
                                   int length)
                            throws XMLStreamException
Specified by:
getTextCharacters in interface XMLStreamReader
Throws:
XMLStreamException

getPCDATA

public final CharSequence getPCDATA()
Description copied from interface: XMLStreamReaderEx
Works like XMLStreamReader.getText() but hides the actual data representation.

Specified by:
getPCDATA in interface XMLStreamReaderEx
Returns:
The CharSequence that represents the character infoset items at the current position.

The CharSequence is normally a String, but can be any other CharSequence implementation. For binary data, however, use of Base64Data is 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:
getEncoding in interface XMLStreamReader

hasText

public final boolean hasText()
Specified by:
hasText in interface XMLStreamReader

getLocation

public final Location getLocation()
Specified by:
getLocation in interface XMLStreamReader

hasName

public final boolean hasName()
Specified by:
hasName in interface XMLStreamReader

getName

public final QName getName()
Specified by:
getName in interface XMLStreamReader

getLocalName

public final String getLocalName()
Specified by:
getLocalName in interface XMLStreamReader

getNamespaceURI

public final String getNamespaceURI()
Specified by:
getNamespaceURI in interface XMLStreamReader

getPrefix

public final String getPrefix()
Specified by:
getPrefix in interface XMLStreamReader

getVersion

public final String getVersion()
Specified by:
getVersion in interface XMLStreamReader

isStandalone

public final boolean isStandalone()
Specified by:
isStandalone in interface XMLStreamReader

standaloneSet

public final boolean standaloneSet()
Specified by:
standaloneSet in interface XMLStreamReader

getCharacterEncodingScheme

public final String getCharacterEncodingScheme()
Specified by:
getCharacterEncodingScheme in interface XMLStreamReader

getPITarget

public final String getPITarget()
Specified by:
getPITarget in interface XMLStreamReader

getPIData

public final String getPIData()
Specified by:
getPIData in interface XMLStreamReader

processElement

protected void processElement(String prefix,
                              String uri,
                              String localName,
                              boolean inscope)


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.