public final class ReaderScanner extends XmlScanner
Reader
. In general using this scanner is quite
a bit less optimal than that of InputStream
based
scanner. Nonetheless, it is included for completeness, since Stax
interface allows passing Readers as input sources.Modifier and Type | Field and Description |
---|---|
protected java.io.Reader |
_in
Underlying InputStream to use for reading content.
|
protected char[] |
_inputBuffer |
protected int |
_inputEnd |
protected int |
_inputPtr |
protected CharBasedPNameTable |
_symbols
For now, symbol table contains prefixed names.
|
protected int |
mTmpChar
Storage location for a single character that can not be pushed
back (for example, multi-byte char)
|
private static XmlCharTypes |
sCharTypes
Although java chars are basically UTF-16 in memory, the closest
match for char types is Latin1.
|
_attrCollector, _attrCount, _cfgCoalescing, _cfgLazyParsing, _config, _currElem, _currNsCount, _currRow, _currToken, _defaultNs, _depth, _entityPending, _isEmptyTag, _lastNsContext, _lastNsDecl, _nameBuffer, _nsBindingCache, _nsBindingCount, _nsBindings, _nsBindMisses, _pastBytesOrChars, _publicId, _rowStartOffset, _startColumn, _startRawOffset, _startRow, _systemId, _textBuilder, _tokenIncomplete, _tokenName, _xml11, CDATA_STR, INT_0, INT_9, INT_a, INT_A, INT_AMP, INT_APOS, INT_COLON, INT_CR, INT_EQ, INT_EXCL, INT_f, INT_F, INT_GT, INT_HYPHEN, INT_LBRACKET, INT_LF, INT_LT, INT_NULL, INT_QMARK, INT_QUOTE, INT_RBRACKET, INT_SLASH, INT_SPACE, INT_TAB, INT_z, MAX_UNICODE_CHAR, TOKEN_EOI
CHAR_CR, CHAR_LF, CHAR_NULL, CHAR_SPACE, STAX_DEFAULT_OUTPUT_ENCODING, STAX_DEFAULT_OUTPUT_VERSION, XML_DECL_KW_ENCODING, XML_DECL_KW_STANDALONE, XML_DECL_KW_VERSION, XML_SA_NO, XML_SA_YES, XML_V_10, XML_V_10_STR, XML_V_11, XML_V_11_STR, XML_V_UNKNOWN
Constructor and Description |
---|
ReaderScanner(ReaderConfig cfg,
java.io.Reader r) |
ReaderScanner(ReaderConfig cfg,
java.io.Reader r,
char[] buffer,
int ptr,
int last) |
Modifier and Type | Method and Description |
---|---|
protected void |
_closeSource() |
protected int |
_nextEntity()
Helper method used to isolate things that need to be (re)set in
cases where
|
protected void |
_releaseBuffers() |
protected PName |
addPName(char[] nameBuffer,
int nameLen,
int hash) |
protected int |
checkInTreeIndentation(char c)
Note: consequtive white space is only considered indentation,
if the following token seems like a tag (start/end).
|
protected int |
checkPrologIndentation(char c) |
private char |
checkSurrogate(char firstChar)
This method is called to verify that a surrogate
pair found describes a legal surrogate pair (ie.
|
private int |
checkSurrogateNameChar(char firstChar,
char sec,
int index) |
private int |
collectValue(int attrPtr,
char quoteChar,
PName attrName)
This method implements the tight loop for parsing attribute
values.
|
private int |
decodeSurrogate(char firstChar)
This method is similar to
checkSurrogate , but
returns the actual character code encoded by the surrogate
pair. |
protected void |
finishCData() |
protected void |
finishCharacters() |
protected void |
finishCoalescedCData() |
protected void |
finishCoalescedCharacters() |
protected void |
finishCoalescedText()
Method that gets called after a primary text segment (of type
CHARACTERS or CDATA, not applicable to SPACE) has been read in
text buffer.
|
protected void |
finishComment() |
protected void |
finishDTD(boolean copyContents) |
protected void |
finishPI() |
protected void |
finishSpace() |
protected void |
finishToken()
This method is called to ensure that the current token/event has been
completely parsed, such that we have all the data needed to return
it (textual content, PI data, comment text etc)
|
int |
getCurrentColumnNr() |
org.codehaus.stax2.XMLStreamLocation2 |
getCurrentLocation() |
long |
getEndingByteOffset() |
long |
getEndingCharOffset() |
long |
getStartingByteOffset() |
long |
getStartingCharOffset() |
protected int |
handleCharEntity() |
protected int |
handleCommentOrCdataStart() |
private int |
handleDtdStart() |
protected int |
handleEndElement() |
protected int |
handleEntityInText(boolean inAttr) |
private void |
handleNsDeclaration(PName name,
char quoteChar)
Method called from the main START_ELEMENT handling loop, to
parse namespace URI values.
|
protected int |
handlePIStart() |
protected int |
handlePrologDeclStart(boolean isProlog) |
protected int |
handleStartElement(char c) |
protected boolean |
loadAndRetain(int nrOfChars) |
protected boolean |
loadMore() |
protected char |
loadOne() |
protected char |
loadOne(int type) |
protected void |
markLF() |
protected void |
markLF(int offset) |
private void |
matchAsciiKeyword(java.lang.String keyw) |
int |
nextFromProlog(boolean isProlog) |
int |
nextFromTree() |
protected PName |
parsePName(char c) |
protected java.lang.String |
parsePublicId(char quoteChar) |
protected java.lang.String |
parseSystemId(char quoteChar) |
private void |
reportInvalidFirstSurrogate(char ch) |
private void |
reportInvalidSecondSurrogate(char ch) |
protected void |
setStartLocation() |
protected void |
skipCData() |
protected boolean |
skipCharacters() |
protected boolean |
skipCoalescedText()
Method that gets called after a primary text segment (of type
CHARACTERS or CDATA, not applicable to SPACE) has been skipped.
|
protected void |
skipComment() |
protected char |
skipInternalWs(boolean reqd,
java.lang.String msg) |
protected void |
skipPI() |
protected void |
skipSpace() |
bindName, bindNs, checkImmutableBinding, close, decodeAttrBinaryValue, decodeAttrValue, decodeAttrValues, decodeElements, findAttrIndex, findOrCreateBinding, fireSaxCharacterEvents, fireSaxCommentEvent, fireSaxEndElement, fireSaxPIEvent, fireSaxSpaceEvents, fireSaxStartElement, getAttrCollector, getAttrCount, getAttrLocalName, getAttrNsURI, getAttrPrefix, getAttrPrefixedName, getAttrQName, getAttrType, getAttrValue, getAttrValue, getConfig, getCurrentLineNr, getDepth, getDTDPublicId, getDTDSystemId, getEndLocation, getInputPublicId, getInputSystemId, getName, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getNonTransientNamespaceContext, getNsCount, getPrefix, getPrefixes, getQName, getStartLocation, getText, getText, getTextCharacters, getTextCharacters, getTextLength, handleInvalidXmlChar, hasEmptyStack, isAttrSpecified, isEmptyTag, isTextWhitespace, loadMoreGuaranteed, loadMoreGuaranteed, reportDoubleHyphenInComments, reportDuplicateNsDecl, reportEntityOverflow, reportEofInName, reportIllegalCDataEnd, reportIllegalNsDecl, reportIllegalNsDecl, reportInputProblem, reportInvalidNameChar, reportInvalidNsIndex, reportInvalidXmlChar, reportMissingPISpace, reportMultipleColonsInName, reportPrologProblem, reportPrologUnexpChar, reportTreeUnexpChar, reportUnboundPrefix, reportUnexpandedEntityInAttr, reportUnexpectedEndTag, resetForDecoding, skipToken, throwInvalidSpace, throwNullChar, throwUnexpectedChar, verifyXmlChar
private static final XmlCharTypes sCharTypes
protected java.io.Reader _in
protected char[] _inputBuffer
protected int _inputPtr
protected int _inputEnd
protected int mTmpChar
protected final CharBasedPNameTable _symbols
public ReaderScanner(ReaderConfig cfg, java.io.Reader r, char[] buffer, int ptr, int last)
public ReaderScanner(ReaderConfig cfg, java.io.Reader r)
protected void _releaseBuffers()
_releaseBuffers
in class XmlScanner
protected void _closeSource() throws java.io.IOException
_closeSource
in class XmlScanner
java.io.IOException
protected final void finishToken() throws javax.xml.stream.XMLStreamException
XmlScanner
finishToken
in class XmlScanner
javax.xml.stream.XMLStreamException
public final int nextFromProlog(boolean isProlog) throws javax.xml.stream.XMLStreamException
nextFromProlog
in class XmlScanner
javax.xml.stream.XMLStreamException
public final int nextFromTree() throws javax.xml.stream.XMLStreamException
nextFromTree
in class XmlScanner
javax.xml.stream.XMLStreamException
protected int _nextEntity()
protected final int handlePrologDeclStart(boolean isProlog) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private final int handleDtdStart() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final int handleCommentOrCdataStart() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final int handlePIStart() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final int handleCharEntity() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final int handleStartElement(char c) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private final int collectValue(int attrPtr, char quoteChar, PName attrName) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private void handleNsDeclaration(PName name, char quoteChar) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final int handleEndElement() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final int handleEntityInText(boolean inAttr) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final void finishComment() throws javax.xml.stream.XMLStreamException
finishComment
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void finishPI() throws javax.xml.stream.XMLStreamException
finishPI
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void finishDTD(boolean copyContents) throws javax.xml.stream.XMLStreamException
finishDTD
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void finishCData() throws javax.xml.stream.XMLStreamException
finishCData
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void finishCharacters() throws javax.xml.stream.XMLStreamException
finishCharacters
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void finishSpace() throws javax.xml.stream.XMLStreamException
finishSpace
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void finishCoalescedText() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final void finishCoalescedCData() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final void finishCoalescedCharacters() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final boolean skipCoalescedText() throws javax.xml.stream.XMLStreamException
skipCoalescedText
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void skipComment() throws javax.xml.stream.XMLStreamException
skipComment
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void skipPI() throws javax.xml.stream.XMLStreamException
skipPI
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final boolean skipCharacters() throws javax.xml.stream.XMLStreamException
skipCharacters
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void skipCData() throws javax.xml.stream.XMLStreamException
skipCData
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void skipSpace() throws javax.xml.stream.XMLStreamException
skipSpace
in class XmlScanner
javax.xml.stream.XMLStreamException
protected char skipInternalWs(boolean reqd, java.lang.String msg) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private final void matchAsciiKeyword(java.lang.String keyw) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final int checkInTreeIndentation(char c) throws javax.xml.stream.XMLStreamException
Note: consequtive white space is only considered indentation, if the following token seems like a tag (start/end). This so that if a CDATA section follows, it can be coalesced in coalescing mode. Although we could check if coalescing mode is enabled, this should seldom have significant effect either way, so it removes one possible source of problems in coalescing mode.
javax.xml.stream.XMLStreamException
protected final int checkPrologIndentation(char c) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected PName parsePName(char c) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final PName addPName(char[] nameBuffer, int nameLen, int hash) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected java.lang.String parsePublicId(char quoteChar) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected java.lang.String parseSystemId(char quoteChar) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private char checkSurrogate(char firstChar) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private int checkSurrogateNameChar(char firstChar, char sec, int index) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private int decodeSurrogate(char firstChar) throws javax.xml.stream.XMLStreamException
checkSurrogate
, but
returns the actual character code encoded by the surrogate
pair. This is needed if further validation rules (such as name
charactert checks) are to be done.javax.xml.stream.XMLStreamException
private void reportInvalidFirstSurrogate(char ch) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private void reportInvalidSecondSurrogate(char ch) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public org.codehaus.stax2.XMLStreamLocation2 getCurrentLocation()
getCurrentLocation
in class XmlScanner
public int getCurrentColumnNr()
getCurrentColumnNr
in class XmlScanner
public long getStartingByteOffset()
getStartingByteOffset
in class XmlScanner
public long getStartingCharOffset()
getStartingCharOffset
in class XmlScanner
public long getEndingByteOffset() throws javax.xml.stream.XMLStreamException
getEndingByteOffset
in class XmlScanner
javax.xml.stream.XMLStreamException
public long getEndingCharOffset() throws javax.xml.stream.XMLStreamException
getEndingCharOffset
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final void markLF(int offset)
protected final void markLF()
protected final void setStartLocation()
protected final boolean loadMore() throws javax.xml.stream.XMLStreamException
loadMore
in class XmlScanner
javax.xml.stream.XMLStreamException
protected final char loadOne() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final char loadOne(int type) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final boolean loadAndRetain(int nrOfChars) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException