com.ctc.wstx.sr
Class WstxStreamReader

java.lang.Object
  extended bycom.ctc.wstx.io.WstxInputData
      extended bycom.ctc.wstx.sr.StreamScanner
          extended bycom.ctc.wstx.sr.WstxStreamReader
All Implemented Interfaces:
DTDInfo, InputConfigFlags, InputProblemReporter, LocationInfo, ParsingErrorMsgs, StreamReaderImpl, javax.xml.stream.XMLStreamConstants, javax.xml.stream.XMLStreamReader, XMLStreamReader2
Direct Known Subclasses:
FullStreamReader

public class WstxStreamReader
extends StreamScanner
implements StreamReaderImpl, DTDInfo, LocationInfo

Implementation of XMLStreamReader2 that implements non-DTD aware parts of XML handling (plus some minimal support for parsing DOCTYPE declaration and skipping internal DTD subset if necessary). It can be used as is, and it is also the superclass of the DTD-aware implementation(s).

This class is also the lowest common denominator for all actual XMLStreamReader2 implementations Woodstox will ever create.

Some notes about non-conformancy with XML specs:

About interfaces implemented: XMLStreamReader2 is part of StAX2, and implemented as the "main" interface. Implementing DTDInfo is just an implementation detail; it could be implemented as a separate Object if necessary.


Field Summary
protected static java.lang.String DEFAULT_NS_PREFIX
          StAX API expects null to indicate "no prefix", not an empty String...
protected  AttributeCollector mAttrCollector
          Object that stores information about currently accessible attributes.
protected  boolean mCfgCoalesceText
           
protected  boolean mCfgLazyParsing
           
protected  boolean mCfgNormalizeAttrs
           
protected  boolean mCfgNormalizeLFs
           
protected  boolean mCfgReplaceEntities
           
protected  boolean mCfgReportTextAsChars
           
protected  int mConfigFlags
          Various flags about tokenization state (TF_xxx)
protected  EntityDecl mCurrEntity
          Entity reference stream currently points to; only used when in non-automatically expanding mode.
protected  int mCurrToken
          Current state of the stream, ie token value returned by getEventType().
 int mDocStandalone
          Status about "stand-aloneness" of document; set to 'yes'/'no'/'unknown' based on whether there was xml declaration, and if so, whether it had standalone attribute.
protected  java.lang.String mDtdPublicId
          Public id of the DTD, if one exists and has been parsed.
protected  java.lang.String mDtdSystemId
          System id of the DTD, if one exists and has been parsed.
protected  InputElementStack mElementStack
          Currently open element tree
protected  java.util.Map mGeneralEntities
          Entities parsed from internal/external DTD subsets.
protected  ReaderCreator mOwner
          Object to notify about shared stuff, such as symbol tables, as well as to query for additional config settings if necessary.
protected  int mShortestTextSegment
          Minimum number of characters parser can return as partial text segment, IF it's not required to coalesce adjacent text segments.
protected  boolean mStDoctypeFound
           
protected  boolean mStEmptyElem
           
protected  int mStTextThreshold
          Threshold value that defines tokenization state that needs to be achieved to "finish" current logical text segment (which may consist of adjacent CDATA and text segments; or be a complete physical segment; or just even a fragment of such a segment)
protected  int mTokenState
          State of the current token; one of M_ - constants from above.
protected  int mVldContent
          Mode information needed at this level; mostly to check what kind of textual content (if any) is allowed in current element context.
protected static java.lang.String sPrefixXml
           
protected static java.lang.String sPrefixXmlns
           
 
Fields inherited from class com.ctc.wstx.sr.StreamScanner
CHAR_CR_LF_OR_NULL, CHAR_FIRST_PURE_TEXT, CHAR_LOWEST_LEGAL_LOCALNAME_CHAR, INT_CR_LF_OR_NULL, mCfgNsEnabled, mConfig, mInput, mNameBuffer, mReporter, mRootInput, mTextBuffer, mTokenInputCol, mTokenInputRow, mTokenInputTotal
 
Fields inherited from class com.ctc.wstx.io.WstxInputData
CHAR_NULL, CHAR_SPACE, INT_NULL, INT_SPACE, MAX_UNICODE_CHAR, mCurrInputProcessed, mCurrInputRow, mCurrInputRowStart, mInputBuffer, mInputLen, mInputPtr
 
Fields inherited from interface org.codehaus.stax2.XMLStreamReader2
FEATURE_DTD_OVERRIDE
 
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
 
Fields inherited from interface com.ctc.wstx.cfg.InputConfigFlags
CFG_CACHE_DTDS, CFG_COALESCE_TEXT, CFG_INTERN_NS_URIS, CFG_LAZY_PARSING, CFG_NAMESPACE_AWARE, CFG_NORMALIZE_ATTR_VALUES, CFG_NORMALIZE_LFS, CFG_PRESERVE_LOCATION, CFG_REPLACE_ENTITY_REFS, CFG_REPORT_ALL_TEXT_AS_CHARACTERS, CFG_REPORT_PROLOG_WS, CFG_SUPPORT_DTD, CFG_SUPPORT_DTDPP, CFG_SUPPORT_EXTERNAL_ENTITIES, CFG_VALIDATE_AGAINST_DTD, CFG_VALIDATE_TEXT_CHARS, CONTENT_ALLOW_DTD_ANY, CONTENT_ALLOW_MIXED, CONTENT_ALLOW_NON_MIXED, CONTENT_ALLOW_NONE, CONTENT_ALLOW_UNDEFINED
 
Fields inherited from interface com.ctc.wstx.cfg.ParsingErrorMsgs
SUFFIX_EOF_EXP_NAME, SUFFIX_IN_ATTR_VALUE, SUFFIX_IN_CDATA, SUFFIX_IN_CLOSE_ELEMENT, SUFFIX_IN_COMMENT, SUFFIX_IN_DEF_ATTR_VALUE, SUFFIX_IN_DOC, SUFFIX_IN_DTD, SUFFIX_IN_DTD_EXTERNAL, SUFFIX_IN_DTD_INTERNAL, SUFFIX_IN_ELEMENT, SUFFIX_IN_ENTITY_REF, SUFFIX_IN_EPILOG, SUFFIX_IN_NAME, SUFFIX_IN_PROC_INSTR, SUFFIX_IN_PROLOG, SUFFIX_IN_TEXT, SUFFIX_IN_XML_DECL
 
Constructor Summary
protected WstxStreamReader(BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputElementStack elemStack)
           
 
Method Summary
protected  void checkCData()
           
protected  boolean checkEquals(java.lang.String errorMsg)
          Method that checks that input following is of form '[S]* '=' [S]*' (as per XML specs, production #25).
protected  java.lang.String checkKeyword(char c, java.lang.String expected)
           
 void close()
           Note: as per StAX 1.0 specs, this method does NOT close the underlying input reader.
static WstxStreamReader createBasicStreamReader(BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputBootstrapper bs)
          Factory method for constructing readers.
protected static InputElementStack createElementStack(ReaderConfig cfg)
           
protected  void ensureFinishToken()
           
protected  void finishDTD(boolean copyContents)
          This method gets called to handle remainder of DOCTYPE declaration, essentially the optional internal subset.
protected  void finishToken()
          Method called to read in contents of the token completely, if not yet read.
 AttributeCollector getAttributeCollector()
          Method needed by classes (like stream writer implementations) that want to have efficient direct access to attribute collector Object, for optimal attribute name and value access.
 int getAttributeCount()
           
 AttributeInfo getAttributeInfo()
          Method that can be called to get additional information about attributes related to the current start element, as well as related DTD-based information if available.
 java.lang.String getAttributeLocalName(int index)
           
 javax.xml.namespace.QName getAttributeName(int index)
           
 java.lang.String getAttributeNamespace(int index)
           
 java.lang.String getAttributePrefix(int index)
           
 java.lang.String getAttributeType(int index)
           
 java.lang.String getAttributeValue(int index)
           
 java.lang.String getAttributeValue(java.lang.String nsURI, java.lang.String localName)
           
 java.lang.String getCharacterEncodingScheme()
           
 EntityDecl getCurrentEntityDecl()
           
 int getDepth()
          Method that returns the number of open elements in the stack; 0 when the reader is in prolog/epilog, 1 inside root element and so on.
 DTDInfo getDTDInfo()
          Since this class implements DTDInfo, method can just return this.
 java.lang.String getDTDInternalSubset()
           
 java.lang.String getDTDPublicId()
           
 java.lang.String getDTDRootName()
           
 java.lang.String getDTDSystemId()
           
 java.lang.String getElementText()
          From StAX specs: Reads the content of a text-only element, an exception is thrown if this is not a text-only element.
 java.lang.String getEncoding()
           
 long getEndingByteOffset()
          Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.
 long getEndingCharOffset()
          Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.
 XMLStreamLocation2 getEndLocation()
          An optional method that either returns the location object that points the ending position of the current event, or null if implementation does not keep track of it (some may return only start location; and some no location at all).
 int getEventType()
          Returns type of the last event returned; or START_DOCUMENT before any events has been explicitly returned.
 java.lang.Object getFeature(java.lang.String name)
          Method that can be used to get per-reader values; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.
 InputElementStack getInputElementStack()
          Method needed by classes (like stream writer implementations) that want to have efficient direct access to element stack implementation
 java.lang.String getLocalName()
           
 javax.xml.stream.Location getLocation()
          Returns location of last properly parsed token; as per StAX specs, apparently needs to be the end of current event, which is the same as the start of the following event (or EOF if that's next).
 LocationInfo getLocationInfo()
          Location information is always accessible, for this reader.
 javax.xml.namespace.QName getName()
           
 javax.xml.namespace.NamespaceContext getNamespaceContext()
           
 int getNamespaceCount()
           
 java.lang.String getNamespacePrefix(int index)
           
 java.lang.String getNamespaceURI()
           
 java.lang.String getNamespaceURI(int index)
           
 java.lang.String getNamespaceURI(java.lang.String prefix)
           
 java.lang.String getPIData()
           
 java.lang.String getPITarget()
           
 java.lang.String getPrefix()
           
 java.lang.Object getProcessedDTD()
           Note: DTD-handling sub-classes need to override this method.
 java.lang.Object getProperty(java.lang.String name)
           
 long getStartingByteOffset()
          Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.
 long getStartingCharOffset()
          Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.
 SymbolTable getSymbolTable()
           
 java.lang.String getText()
           
 int getText(java.io.Writer w, boolean preserveContents)
          Method similar to getText(), except that it just uses provided Writer to write all textual content.
 char[] getTextCharacters()
           
 int getTextCharacters(int sourceStart, char[] target, int targetStart, int len)
           
 int getTextLength()
           
 int getTextStart()
           
 java.lang.String getVersion()
           
protected  boolean hasConfigFlags(int flags)
           
 boolean hasName()
           
 boolean hasNext()
           
 boolean hasText()
           
protected  void initProlog(InputBootstrapper bs)
           
 boolean isAttributeSpecified(int index)
           
 boolean isCharacters()
           
 boolean isEmptyElement()
          Method that can be used to check whether current START_ELEMENT event was created for an empty element (xml short-hand notation where one tag implies start and end, ending with "/>"), or not.
 boolean isEndElement()
           
 boolean isNamespaceAware()
           
 boolean isStandalone()
           
 boolean isStartElement()
           
 boolean isWhiteSpace()
           05-Apr-2004, TSa: Could try to determine status when text is actually read.
 int next()
           
 int nextTag()
           
protected  void parseNonNormalizedAttrValue(char openingQuote, TextBuilder tb)
          Method that will parse an attribute value enclosed in quotes, using an TextBuilder instance.
protected  void parseNormalizedAttrValue(char openingQuote, TextBuilder tb)
          Method that will parse an attribute value enclosed in quotes, using an TextBuilder instance.
protected  void reportInvalidContent(int evtType)
          Stub method implemented by validating parsers, to report content that's not valid for current element context.
 void require(int type, java.lang.String nsUri, java.lang.String localName)
           
protected  void safeEnsureFinishToken()
           
protected  void safeFinishToken()
           
 void setFeature(java.lang.String name, java.lang.Object value)
          Method that can be used to set per-reader features such as configuration settings; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.
 void skipElement()
          Method that will skip all the contents of the element that the stream currently points to.
 boolean standaloneSet()
           
 java.lang.Object withStartElement(ElemCallback cb, javax.xml.stream.Location loc)
          Method called by DefaultEventAllocator to get double-indirection necessary for constructing start element events.
protected  void wrappedFinishToken()
           
 
Methods inherited from class com.ctc.wstx.sr.StreamScanner
ensureInput, expandBy50Pct, expandEntity, expandEntity, fullyResolveEntity, getCurrentInput, getCurrentLocation, getLastCharLocation, getNameBuffer, getNext, getNextAfterWS, getNextAfterWS, getNextChar, getNextCharAfterWS, getNextCharAfterWS, getNextCharFromCurrent, getNextInCurrAfterWS, getNextInCurrAfterWS, getSource, getStartLocation, getSystemId, initInputSource, inputInBuffer, loadMore, loadMore, loadMoreFromCurrent, loadMoreFromCurrent, markLF, markLF, parseEntityName, parseFNameForError, parseFullName, parseFullName, parseFullName2, parseLocalName, parseLocalName2, parsePublicId, parseSystemId, parseUntil, peekNext, pushback, reportProblem, reportProblem, reportProblem, reportProblem, reportProblem, resolveCharOnlyEntity, resolveNonCharEntity, resolveSimpleEntity, skipCRLF, skipFullName, skipWS, throwFromIOE, throwFromStrE, throwLazyError, throwNullChar, throwParseError, throwParseError, throwParseError, throwParseError, throwUnexpectedChar, throwUnexpectedEOB, throwUnexpectedEOF, tokenTypeDesc
 
Methods inherited from class com.ctc.wstx.io.WstxInputData
copyBufferStateFrom, getCharDesc, is11NameChar, is11NameStartChar, isSpaceChar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.codehaus.stax2.LocationInfo
getCurrentLocation, getStartLocation
 

Field Detail

DEFAULT_NS_PREFIX

protected static final java.lang.String DEFAULT_NS_PREFIX
StAX API expects null to indicate "no prefix", not an empty String...


sPrefixXml

protected static final java.lang.String sPrefixXml

sPrefixXmlns

protected static final java.lang.String sPrefixXmlns

mOwner

protected final ReaderCreator mOwner
Object to notify about shared stuff, such as symbol tables, as well as to query for additional config settings if necessary.


mDocStandalone

public int mDocStandalone
Status about "stand-aloneness" of document; set to 'yes'/'no'/'unknown' based on whether there was xml declaration, and if so, whether it had standalone attribute.


mDtdPublicId

protected java.lang.String mDtdPublicId
Public id of the DTD, if one exists and has been parsed.


mDtdSystemId

protected java.lang.String mDtdSystemId
System id of the DTD, if one exists and has been parsed.


mElementStack

protected final InputElementStack mElementStack
Currently open element tree


mAttrCollector

protected final AttributeCollector mAttrCollector
Object that stores information about currently accessible attributes.


mStDoctypeFound

protected boolean mStDoctypeFound

mTokenState

protected int mTokenState
State of the current token; one of M_ - constants from above.

Initially set to fully tokenized, since it's the virtual START_DOCUMENT event that we fully know by now (parsed by bootstrapper)


mStTextThreshold

protected final int mStTextThreshold
Threshold value that defines tokenization state that needs to be achieved to "finish" current logical text segment (which may consist of adjacent CDATA and text segments; or be a complete physical segment; or just even a fragment of such a segment)


mStEmptyElem

protected boolean mStEmptyElem

mCurrToken

protected int mCurrToken
Current state of the stream, ie token value returned by getEventType(). Needs to be initialized to START_DOCUMENT, since that's the state it starts in.


mGeneralEntities

protected java.util.Map mGeneralEntities
Entities parsed from internal/external DTD subsets. Although it will remain null for this class, extended classes make use of it, plus, to be able to share some of entity resolution code, instance is left here even though it semantically belongs to the sub-class.


mCurrEntity

protected EntityDecl mCurrEntity
Entity reference stream currently points to; only used when in non-automatically expanding mode.


mVldContent

protected int mVldContent
Mode information needed at this level; mostly to check what kind of textual content (if any) is allowed in current element context. Constants come from InputConfigFlags, (like InputConfigFlags.CONTENT_ALLOW_MIXED). Only used inside tree; ignored for prolog/epilog (which have straight-forward static rules).


mConfigFlags

protected final int mConfigFlags
Various flags about tokenization state (TF_xxx)


mCfgReplaceEntities

protected final boolean mCfgReplaceEntities

mCfgNormalizeLFs

protected final boolean mCfgNormalizeLFs

mCfgNormalizeAttrs

protected final boolean mCfgNormalizeAttrs

mCfgCoalesceText

protected final boolean mCfgCoalesceText

mCfgReportTextAsChars

protected final boolean mCfgReportTextAsChars

mCfgLazyParsing

protected final boolean mCfgLazyParsing

mShortestTextSegment

protected final int mShortestTextSegment
Minimum number of characters parser can return as partial text segment, IF it's not required to coalesce adjacent text segments.

Constructor Detail

WstxStreamReader

protected WstxStreamReader(BranchingReaderSource input,
                           ReaderCreator owner,
                           ReaderConfig cfg,
                           InputElementStack elemStack)
                    throws java.io.IOException,
                           javax.xml.stream.XMLStreamException
Parameters:
elemStack - Input element stack to use; if null, will create instance locally.
Method Detail

createBasicStreamReader

public static WstxStreamReader createBasicStreamReader(BranchingReaderSource input,
                                                       ReaderCreator owner,
                                                       ReaderConfig cfg,
                                                       InputBootstrapper bs)
                                                throws java.io.IOException,
                                                       javax.xml.stream.XMLStreamException
Factory method for constructing readers.

Parameters:
owner - "Owner" of this reader, factory that created the reader; needed for returning updated symbol table information after parsing.
input - Input source used to read the XML document.
cfg - Object that contains reader configuration info.
Throws:
java.io.IOException
javax.xml.stream.XMLStreamException

createElementStack

protected static InputElementStack createElementStack(ReaderConfig cfg)

getCharacterEncodingScheme

public java.lang.String getCharacterEncodingScheme()
Specified by:
getCharacterEncodingScheme in interface javax.xml.stream.XMLStreamReader

getEncoding

public java.lang.String getEncoding()
Specified by:
getEncoding in interface javax.xml.stream.XMLStreamReader

getVersion

public java.lang.String getVersion()
Specified by:
getVersion in interface javax.xml.stream.XMLStreamReader

isStandalone

public boolean isStandalone()
Specified by:
isStandalone in interface javax.xml.stream.XMLStreamReader

standaloneSet

public boolean standaloneSet()
Specified by:
standaloneSet in interface javax.xml.stream.XMLStreamReader

getProperty

public java.lang.Object getProperty(java.lang.String name)
Specified by:
getProperty in interface javax.xml.stream.XMLStreamReader

getAttributeCount

public int getAttributeCount()
Specified by:
getAttributeCount in interface javax.xml.stream.XMLStreamReader

getAttributeLocalName

public java.lang.String getAttributeLocalName(int index)
Specified by:
getAttributeLocalName in interface javax.xml.stream.XMLStreamReader

getAttributeName

public javax.xml.namespace.QName getAttributeName(int index)
Specified by:
getAttributeName in interface javax.xml.stream.XMLStreamReader

getAttributeNamespace

public java.lang.String getAttributeNamespace(int index)
Specified by:
getAttributeNamespace in interface javax.xml.stream.XMLStreamReader

getAttributePrefix

public java.lang.String getAttributePrefix(int index)
Specified by:
getAttributePrefix in interface javax.xml.stream.XMLStreamReader

getAttributeType

public java.lang.String getAttributeType(int index)
Specified by:
getAttributeType in interface javax.xml.stream.XMLStreamReader

getAttributeValue

public java.lang.String getAttributeValue(int index)
Specified by:
getAttributeValue in interface javax.xml.stream.XMLStreamReader

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String nsURI,
                                          java.lang.String localName)
Specified by:
getAttributeValue in interface javax.xml.stream.XMLStreamReader

getElementText

public java.lang.String getElementText()
                                throws javax.xml.stream.XMLStreamException
From StAX specs:
Reads the content of a text-only element, an exception is thrown if this is not a text-only element. Regardless of value of javax.xml.stream.isCoalescing this method always returns coalesced content.
Precondition: the current event is START_ELEMENT.
Postcondition: the current event is the corresponding END_ELEMENT.

Specified by:
getElementText in interface javax.xml.stream.XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException

getEventType

public int getEventType()
Returns type of the last event returned; or START_DOCUMENT before any events has been explicitly returned.

Specified by:
getEventType in interface javax.xml.stream.XMLStreamReader

getLocalName

public java.lang.String getLocalName()
Specified by:
getLocalName in interface javax.xml.stream.XMLStreamReader

getName

public javax.xml.namespace.QName getName()
Specified by:
getName in interface javax.xml.stream.XMLStreamReader

getNamespaceContext

public javax.xml.namespace.NamespaceContext getNamespaceContext()
Specified by:
getNamespaceContext in interface javax.xml.stream.XMLStreamReader

getNamespaceCount

public int getNamespaceCount()
Specified by:
getNamespaceCount in interface javax.xml.stream.XMLStreamReader

getNamespacePrefix

public java.lang.String getNamespacePrefix(int index)
Specified by:
getNamespacePrefix in interface javax.xml.stream.XMLStreamReader

getNamespaceURI

public java.lang.String getNamespaceURI()
Specified by:
getNamespaceURI in interface javax.xml.stream.XMLStreamReader

getNamespaceURI

public java.lang.String getNamespaceURI(int index)
Specified by:
getNamespaceURI in interface javax.xml.stream.XMLStreamReader

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Specified by:
getNamespaceURI in interface javax.xml.stream.XMLStreamReader

getPIData

public java.lang.String getPIData()
Specified by:
getPIData in interface javax.xml.stream.XMLStreamReader

getPITarget

public java.lang.String getPITarget()
Specified by:
getPITarget in interface javax.xml.stream.XMLStreamReader

getPrefix

public java.lang.String getPrefix()
Specified by:
getPrefix in interface javax.xml.stream.XMLStreamReader

getText

public java.lang.String getText()
Specified by:
getText in interface javax.xml.stream.XMLStreamReader

getTextCharacters

public char[] getTextCharacters()
Specified by:
getTextCharacters in interface javax.xml.stream.XMLStreamReader

getTextCharacters

public int getTextCharacters(int sourceStart,
                             char[] target,
                             int targetStart,
                             int len)
Specified by:
getTextCharacters in interface javax.xml.stream.XMLStreamReader

getTextLength

public int getTextLength()
Specified by:
getTextLength in interface javax.xml.stream.XMLStreamReader

getTextStart

public int getTextStart()
Specified by:
getTextStart in interface javax.xml.stream.XMLStreamReader

hasName

public boolean hasName()
Specified by:
hasName in interface javax.xml.stream.XMLStreamReader

hasNext

public boolean hasNext()
Specified by:
hasNext in interface javax.xml.stream.XMLStreamReader

hasText

public boolean hasText()
Specified by:
hasText in interface javax.xml.stream.XMLStreamReader

isAttributeSpecified

public boolean isAttributeSpecified(int index)
Specified by:
isAttributeSpecified in interface javax.xml.stream.XMLStreamReader

isCharacters

public boolean isCharacters()
Specified by:
isCharacters in interface javax.xml.stream.XMLStreamReader

isEndElement

public boolean isEndElement()
Specified by:
isEndElement in interface javax.xml.stream.XMLStreamReader

isStartElement

public boolean isStartElement()
Specified by:
isStartElement in interface javax.xml.stream.XMLStreamReader

isWhiteSpace

public boolean isWhiteSpace()

05-Apr-2004, TSa: Could try to determine status when text is actually read. That'd prevent double reads... but would it slow down that one reading so that net effect would be negative?

Specified by:
isWhiteSpace in interface javax.xml.stream.XMLStreamReader

require

public void require(int type,
                    java.lang.String nsUri,
                    java.lang.String localName)
             throws javax.xml.stream.XMLStreamException
Specified by:
require in interface javax.xml.stream.XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException

next

public int next()
         throws javax.xml.stream.XMLStreamException
Specified by:
next in interface javax.xml.stream.XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException

nextTag

public int nextTag()
            throws javax.xml.stream.XMLStreamException
Specified by:
nextTag in interface javax.xml.stream.XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException

close

public void close()

Note: as per StAX 1.0 specs, this method does NOT close the underlying input reader.

Specified by:
close in interface javax.xml.stream.XMLStreamReader

getFeature

public java.lang.Object getFeature(java.lang.String name)
Description copied from interface: XMLStreamReader2
Method that can be used to get per-reader values; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.

Note: although some feature names are shared with XMLStreamReader2.setFeature(java.lang.String, java.lang.Object), not all are: some features are read-only, some write-only

Specified by:
getFeature in interface XMLStreamReader2
Parameters:
name - Name of the feature of which value to get
Returns:
Value of the feature (possibly null), if supported; null otherwise

setFeature

public void setFeature(java.lang.String name,
                       java.lang.Object value)
Description copied from interface: XMLStreamReader2
Method that can be used to set per-reader features such as configuration settings; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.

Note: although some feature names are shared with XMLStreamReader2.getFeature(java.lang.String), not all are: some features are read-only, some write-only

Specified by:
setFeature in interface XMLStreamReader2
Parameters:
name - Name of the feature to set
value - Value to set feature to.

skipElement

public void skipElement()
                 throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamReader2
Method that will skip all the contents of the element that the stream currently points to. Current event when calling the method has to be START_ELEMENT (or otherwise IllegalStateException is thrown); after the call the stream will point to the matching END_ELEMENT event, having skipped zero or more intervening events for the contents.

Specified by:
skipElement in interface XMLStreamReader2
Throws:
javax.xml.stream.XMLStreamException

getAttributeInfo

public AttributeInfo getAttributeInfo()
                               throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamReader2
Method that can be called to get additional information about attributes related to the current start element, as well as related DTD-based information if available. Note that the reader has to currently point to START_ELEMENT; if not, a IllegalStateException will be thrown.

Specified by:
getAttributeInfo in interface XMLStreamReader2
Throws:
javax.xml.stream.XMLStreamException

getDTDInfo

public DTDInfo getDTDInfo()
                   throws javax.xml.stream.XMLStreamException
Since this class implements DTDInfo, method can just return this.

Specified by:
getDTDInfo in interface XMLStreamReader2
Returns:
Information object for accessing further DOCTYPE information, iff the reader currently points to DTD event, AND is operating in mode that parses such information (DTD-aware at least, and usually also validating)
Throws:
javax.xml.stream.XMLStreamException

getLocationInfo

public final LocationInfo getLocationInfo()
Location information is always accessible, for this reader.

Specified by:
getLocationInfo in interface XMLStreamReader2

getText

public int getText(java.io.Writer w,
                   boolean preserveContents)
            throws java.io.IOException,
                   javax.xml.stream.XMLStreamException
Method similar to getText(), except that it just uses provided Writer to write all textual content. For further optimization, it may also be allowed to do true pass-through, thus possibly avoiding one temporary copy of the data.

TODO: try to optimize to allow completely streaming pass-through: currently will still read all data in memory buffers before outputting

Specified by:
getText in interface XMLStreamReader2
Parameters:
w - Writer to use for writing textual contents
preserveContents - If true, reader has to preserve contents so that further calls to getText will return proper conntets. If false, reader is allowed to skip creation of such copies: this can improve performance, but it also means that further calls to getText is not guaranteed to return meaningful data.
Returns:
Number of characters written to the reader
Throws:
java.io.IOException
javax.xml.stream.XMLStreamException

getDepth

public int getDepth()
Description copied from interface: XMLStreamReader2
Method that returns the number of open elements in the stack; 0 when the reader is in prolog/epilog, 1 inside root element and so on. Depth is same for matching start/end elements, as well as for the immediate non-element children of the element.

Specified by:
getDepth in interface XMLStreamReader2
Returns:
Number of open elements in the stack; 0 when parser is in prolog/epilog, 1 inside root element and so on.

isEmptyElement

public boolean isEmptyElement()
                       throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamReader2
Method that can be used to check whether current START_ELEMENT event was created for an empty element (xml short-hand notation where one tag implies start and end, ending with "/>"), or not.

Note: method may need to read more data to know if the element is an empty one, and as such may throw an i/o or parsing exception (as XMLStreamException); however, it won't throw exceptions for non-START_ELEMENT event types.

Specified by:
isEmptyElement in interface XMLStreamReader2
Returns:
True, if cursor points to a start or end element that is constructed from 'empty' element (ends with '/>'); false otherwise.
Throws:
javax.xml.stream.XMLStreamException

getProcessedDTD

public java.lang.Object getProcessedDTD()

Note: DTD-handling sub-classes need to override this method.

Specified by:
getProcessedDTD in interface DTDInfo
Returns:
If current event is DTD, DTD support is enabled, and reader supports DTD processing, returns an internal Object implementation uses for storing/processing DTD; otherwise returns null.

getDTDRootName

public java.lang.String getDTDRootName()
Specified by:
getDTDRootName in interface DTDInfo
Returns:
If current event is DTD, returns the full root name (including prefix, if any); otherwise returns null

getDTDPublicId

public java.lang.String getDTDPublicId()
Specified by:
getDTDPublicId in interface DTDInfo
Returns:
If current event is DTD, and has a public id, returns the public id; otherwise returns null.

getDTDSystemId

public java.lang.String getDTDSystemId()
Specified by:
getDTDSystemId in interface DTDInfo
Returns:
If current event is DTD, and has a system id, returns the system id; otherwise returns null.

getDTDInternalSubset

public java.lang.String getDTDInternalSubset()
Specified by:
getDTDInternalSubset in interface DTDInfo
Returns:
Internal subset portion of the DOCTYPE declaration, if any; empty String if none

getStartingByteOffset

public long getStartingByteOffset()
Description copied from interface: LocationInfo
Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.

Note: this value MAY be the same as the one returned by LocationInfo.getStartingCharOffset(), but usually only for single-byte character streams (Ascii, ISO-Latin).

Specified by:
getStartingByteOffset in interface LocationInfo
Returns:
Byte offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from the character offset, for variable-byte encodings); -1 if not.

getStartingCharOffset

public long getStartingCharOffset()
Description copied from interface: LocationInfo
Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.

Note: this value MAY be the same as the one returned by LocationInfo.getStartingByteOffset(); this is the case for single-byte character streams (Ascii, ISO-Latin), as well as for streams for which byte offset information is not available (Readers, Strings).

Specified by:
getStartingCharOffset in interface LocationInfo
Returns:
Character offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from byte offset, for variable-byte encodings); -1 if not.

getEndingByteOffset

public long getEndingByteOffset()
                         throws javax.xml.stream.XMLStreamException
Description copied from interface: LocationInfo
Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.

Note: this value MAY be the same as the one returned by LocationInfo.getEndingCharOffset(), but usually only for single-byte character streams (Ascii, ISO-Latin).

Note: for lazy-loading implementations, calling this method may require the underlying stream to be advanced and contents parsed; this is why it is possible that an exception be thrown.

Specified by:
getEndingByteOffset in interface LocationInfo
Returns:
Byte offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from the character offset, for variable-byte encodings); -1 if not.
Throws:
javax.xml.stream.XMLStreamException

getEndingCharOffset

public long getEndingCharOffset()
                         throws javax.xml.stream.XMLStreamException
Description copied from interface: LocationInfo
Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.

Note: this value MAY be the same as the one returned by LocationInfo.getEndingByteOffset(); this is the case for single-byte character streams (Ascii, ISO-Latin), as well as for streams for which byte offset information is not available (Readers, Strings).

Note: for lazy-loading implementations, calling this method may require the underlying stream to be advanced and contents parsed; this is why it is possible that an exception be thrown.

Specified by:
getEndingCharOffset in interface LocationInfo
Returns:
Character offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from byte offset, for variable-byte encodings); -1 if not.
Throws:
javax.xml.stream.XMLStreamException

getLocation

public final javax.xml.stream.Location getLocation()
Description copied from class: StreamScanner
Returns location of last properly parsed token; as per StAX specs, apparently needs to be the end of current event, which is the same as the start of the following event (or EOF if that's next).

Specified by:
getLocation in interface javax.xml.stream.XMLStreamReader
Specified by:
getLocation in class StreamScanner

getEndLocation

public final XMLStreamLocation2 getEndLocation()
                                        throws javax.xml.stream.XMLStreamException
Description copied from interface: LocationInfo
An optional method that either returns the location object that points the ending position of the current event, or null if implementation does not keep track of it (some may return only start location; and some no location at all).

Note: since some implementations may not yet know the end location (esp. ones that do lazy loading), this call may require further parsing. As a result, this method may throw a parsing or I/O errors.

Specified by:
getEndLocation in interface LocationInfo
Returns:
Location right after the end of the current event (which will also be the start location of the next event, if any, or of EOF otherwise).
Throws:
javax.xml.stream.XMLStreamException - If the stream reader had to advance to the end of the event (to find the location), it may encounter a parsing (or I/O) error; if so, that gets thrown

getCurrentEntityDecl

public EntityDecl getCurrentEntityDecl()
Specified by:
getCurrentEntityDecl in interface StreamReaderImpl

withStartElement

public java.lang.Object withStartElement(ElemCallback cb,
                                         javax.xml.stream.Location loc)
Method called by DefaultEventAllocator to get double-indirection necessary for constructing start element events.

Specified by:
withStartElement in interface StreamReaderImpl
Returns:
Null, if stream does not point to start element; whatever callback returns otherwise.

isNamespaceAware

public boolean isNamespaceAware()
Specified by:
isNamespaceAware in interface StreamReaderImpl

getInputElementStack

public InputElementStack getInputElementStack()
Method needed by classes (like stream writer implementations) that want to have efficient direct access to element stack implementation

Specified by:
getInputElementStack in interface StreamReaderImpl

getAttributeCollector

public AttributeCollector getAttributeCollector()
Method needed by classes (like stream writer implementations) that want to have efficient direct access to attribute collector Object, for optimal attribute name and value access.

Specified by:
getAttributeCollector in interface StreamReaderImpl

hasConfigFlags

protected final boolean hasConfigFlags(int flags)

checkKeyword

protected java.lang.String checkKeyword(char c,
                                        java.lang.String expected)
                                 throws java.io.IOException,
                                        WstxException
Returns:
Null, if keyword matches ok; String that contains erroneous keyword if not.
Throws:
java.io.IOException