|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ctc.wstx.io.WstxInputData
com.ctc.wstx.sr.StreamScanner
Abstract base class that defines some basic functionality that all Woodstox reader classes (main XML reader, DTD reader) extend from.
| Field Summary | |
static char |
CHAR_CR_LF_OR_NULL
Last (highest) char code of the three, LF, CR and NULL |
protected static char |
CHAR_FIRST_PURE_TEXT
Character that allows quick check of whether a char can potentially be some kind of markup, WRT input stream processing; has to contain linefeeds, &, < and > (">" only matters when quoting text, as part of "]]>") |
protected static char |
CHAR_LOWEST_LEGAL_LOCALNAME_CHAR
First character in Unicode (ie one with lowest id) that is legal as part of a local name (all valid name chars minus ':'). |
static int |
INT_CR_LF_OR_NULL
|
protected boolean |
mCfgNsEnabled
If true, Reader is namespace aware, and should do basic checks (usually enforcing limitations on having colons in names) |
protected ReaderConfig |
mConfig
Copy of the configuration object passed by the factory. |
protected WstxInputSource |
mInput
Currently active input source; contains link to parent (nesting) input sources, if any. |
char[] |
mNameBuffer
Temporary buffer used if local name can not be just directly constructed from input buffer (name is on a boundary). |
protected javax.xml.stream.XMLReporter |
mReporter
Object through which non-fatal problems should be reported. |
protected WstxInputSource |
mRootInput
Top-most input source this reader can use; due to input source chaining, this is not necessarily the root of all input; for example, external DTD subset reader's root input still has original document input as its parent. |
protected TextBuffer |
mTextBuffer
TextBuffer mostly used to collect non-element text content; needs to be accessible here to make sure synchronized sharing with input is safe. |
protected int |
mTokenInputCol
Column on input row that current token starts; 0-based (although in the end it'll be converted to 1-based) |
protected int |
mTokenInputRow
Input row on which current token starts, 1-based |
protected long |
mTokenInputTotal
Total number of characters read before start of current token. |
| 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 |
| Constructor Summary | |
protected |
StreamScanner(WstxInputSource input,
ReaderConfig cfg,
javax.xml.stream.XMLResolver res)
Constructor used when creating a complete new (main-level) reader that does not share its input buffers or state with another reader. |
| Method Summary | |
protected boolean |
ensureInput(int minAmount)
Method called to make sure current main-level input buffer has at least specified number of characters available consequtively, without having to call loadMore(). |
protected char[] |
expandBy50Pct(char[] buf)
|
protected void |
expandEntity(EntityDecl ed,
boolean allowExt)
|
protected int |
expandEntity(java.lang.String id,
java.util.Map ent1,
java.util.Map ent2,
boolean allowExt)
Helper method that will try to expand a parsed entity (parameter or generic entity) |
protected char |
fullyResolveEntity(java.util.Map ent1,
java.util.Map ent2,
boolean allowExt)
Method that does full resolution of an entity reference, be it character entity, internal entity or external entity, including updating of input buffers, and depending on whether result is a character entity (or one of 5 pre-defined entities), returns char in question, or null character (code 0) to indicate it had to change input source. |
WstxInputSource |
getCurrentInput()
Returns current input source this source uses. |
XMLStreamLocation2 |
getCurrentLocation()
|
protected WstxInputLocation |
getLastCharLocation()
Method that returns location of the last character returned by this reader; that is, location "one less" than the currently pointed to location. |
abstract 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). |
protected char[] |
getNameBuffer(int minSize)
|
protected int |
getNext()
|
protected int |
getNextAfterWS()
|
protected int |
getNextAfterWS(char c)
Method that will completely skip and ignore zero or more white space characters, and return next character (or EOF marker) after white space. |
protected char |
getNextChar(java.lang.String errorMsg)
|
protected char |
getNextCharAfterWS(char c,
java.lang.String errorMsg)
|
protected char |
getNextCharAfterWS(java.lang.String errorMsg)
|
protected char |
getNextCharFromCurrent(java.lang.String errorMsg)
Similar to getNextChar(java.lang.String), but will not read more characters
from parent input source(s) if the current input source doesn't
have more content. |
protected char |
getNextInCurrAfterWS(java.lang.String errorMsg)
|
protected char |
getNextInCurrAfterWS(java.lang.String errorMsg,
char c)
|
protected java.net.URL |
getSource()
|
XMLStreamLocation2 |
getStartLocation()
|
protected java.lang.String |
getSystemId()
|
protected void |
initInputSource(WstxInputSource newInput,
boolean isExt)
Method called when an entity has been expanded (new input source has been created). |
protected int |
inputInBuffer()
|
protected boolean |
loadMore()
|
protected boolean |
loadMore(java.lang.String errorMsg)
|
protected boolean |
loadMoreFromCurrent()
|
protected boolean |
loadMoreFromCurrent(java.lang.String errorMsg)
|
protected void |
markLF()
|
protected void |
markLF(int inputPtr)
|
protected java.lang.String |
parseEntityName(char c)
|
protected java.lang.String |
parseFNameForError()
Method called to read in full name, including unlimited number of namespace separators (':'), for the purpose of displaying name in an error message. |
protected java.lang.String |
parseFullName()
Method that will parse 'full' name token; what full means depends on whether reader is namespace aware or not. |
protected java.lang.String |
parseFullName(char c)
|
protected java.lang.String |
parseFullName2(int start,
int hash)
|
protected java.lang.String |
parseLocalName(char c)
Method that will parse name token (roughly equivalent to XML specs; although bit lenier for more efficient handling); either uri prefix, or local name. |
protected java.lang.String |
parseLocalName2(int start,
int hash)
Second part of name token parsing; called when name can continue past input buffer end (so only part was read before calling this method to read the rest). |
protected java.lang.String |
parsePublicId(char quoteChar,
boolean convertLFs,
java.lang.String errorMsg)
Simple parsing method that parses system ids, which are generally used in entities (from DOCTYPE declaration to internal/external subsets). |
protected java.lang.String |
parseSystemId(char quoteChar,
boolean convertLFs,
java.lang.String errorMsg)
Simple parsing method that parses system ids, which are generally used in entities (from DOCTYPE declaration to internal/external subsets). |
protected void |
parseUntil(TextBuffer tb,
char endChar,
boolean convertLFs,
java.lang.String errorMsg)
|
protected int |
peekNext()
Similar to getNext(), but does not advance pointer
in input buffer. |
protected void |
pushback()
Method to push back last character read; can only be called once, that is, no more than one char can be guaranteed to be succesfully returned. |
void |
reportProblem(java.lang.String probType,
java.lang.String msg)
|
void |
reportProblem(java.lang.String probType,
java.lang.String msg,
javax.xml.stream.Location loc)
|
void |
reportProblem(java.lang.String probType,
java.lang.String format,
java.lang.Object arg)
|
void |
reportProblem(java.lang.String probType,
java.lang.String format,
java.lang.Object arg,
java.lang.Object arg2)
|
void |
reportProblem(java.lang.String probType,
java.lang.String format,
java.lang.Object arg,
java.lang.Object arg2,
javax.xml.stream.Location loc)
|
protected char |
resolveCharOnlyEntity(boolean checkStd)
Method called to resolve character entities, and only character entities (except that pre-defined char entities -- amp, apos, lt, gt, quote -- MAY be "char entities" in this sense, depending on arguments). |
protected EntityDecl |
resolveNonCharEntity(java.util.Map ent1,
java.util.Map ent2)
Reverse of resolveCharOnlyEntity(boolean); will only resolve entity
if it is NOT a character entity (or pre-defined 'generic' entity;
amp, apos, lt, gt or quot). |
protected char |
resolveSimpleEntity(boolean checkStd)
Method that tries to resolve a character entity, or (if caller so specifies), a pre-defined internal entity (lt, gt, amp, apos, quot). |
protected boolean |
skipCRLF(char c)
Method called when a CR has been spotted in input; checks if next char is LF, and if so, skips it. |
protected int |
skipFullName(char c)
Note: does not check for number of colons, amongst other things. |
protected void |
skipWS()
Method that will skip any white space potentially coming from the current input source, without returning next character. |
protected void |
throwFromIOE(java.io.IOException ioe)
|
protected void |
throwFromStrE(javax.xml.stream.XMLStreamException strex)
|
protected void |
throwLazyError(java.lang.Exception e)
Method called to report an error, when caller's signature only allows runtime exceptions to be thrown. |
protected void |
throwNullChar()
|
void |
throwParseError(javax.xml.stream.Location loc,
java.lang.String msg)
Similar to throwParseError(String), but specifically defines
location where the error happened. |
void |
throwParseError(java.lang.String msg)
Throws generic parse error with specified message and current parsing location. |
void |
throwParseError(java.lang.String format,
java.lang.Object arg)
|
void |
throwParseError(java.lang.String format,
java.lang.Object arg,
java.lang.Object arg2)
|
protected void |
throwUnexpectedChar(int i,
java.lang.String msg)
|
protected void |
throwUnexpectedEOB(java.lang.String msg)
Similar to throwUnexpectedEOF(java.lang.String), but only indicates ending
of an input block. |
protected void |
throwUnexpectedEOF(java.lang.String msg)
|
protected java.lang.String |
tokenTypeDesc(int type)
|
| 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 |
| Field Detail |
public static final char CHAR_CR_LF_OR_NULL
public static final int INT_CR_LF_OR_NULL
protected static final char CHAR_FIRST_PURE_TEXT
protected static final char CHAR_LOWEST_LEGAL_LOCALNAME_CHAR
protected final ReaderConfig mConfig
protected final javax.xml.stream.XMLReporter mReporter
protected final boolean mCfgNsEnabled
protected WstxInputSource mInput
protected final WstxInputSource mRootInput
public char[] mNameBuffer
Note: public only as some sub-classes need to access... weird.
protected TextBuffer mTextBuffer
protected long mTokenInputTotal
protected int mTokenInputRow
protected int mTokenInputCol
| Constructor Detail |
protected StreamScanner(WstxInputSource input,
ReaderConfig cfg,
javax.xml.stream.XMLResolver res)
| Method Detail |
protected WstxInputLocation getLastCharLocation()
protected java.net.URL getSource()
protected java.lang.String getSystemId()
public abstract javax.xml.stream.Location getLocation()
getLocation in interface InputProblemReporterpublic XMLStreamLocation2 getStartLocation()
public XMLStreamLocation2 getCurrentLocation()
public void throwParseError(java.lang.String msg)
throws WstxException
Note: public access only because core code in other packages needs to access it.
throwParseError in interface InputProblemReporterWstxException
public void throwParseError(javax.xml.stream.Location loc,
java.lang.String msg)
throws WstxException
InputProblemReporterInputProblemReporter.throwParseError(String), but specifically defines
location where the error happened. Used usually when validity of
a declaration can not be verified at the point of declaration but
only later on (reference to undefined id value, for example)
throwParseError in interface InputProblemReporterWstxException
public void throwParseError(java.lang.String format,
java.lang.Object arg)
throws WstxException
throwParseError in interface InputProblemReporterWstxException
public void throwParseError(java.lang.String format,
java.lang.Object arg,
java.lang.Object arg2)
throws WstxException
throwParseError in interface InputProblemReporterWstxException
public void reportProblem(java.lang.String probType,
java.lang.String msg)
reportProblem in interface InputProblemReporter
public void reportProblem(java.lang.String probType,
java.lang.String msg,
javax.xml.stream.Location loc)
reportProblem in interface InputProblemReporter
public void reportProblem(java.lang.String probType,
java.lang.String format,
java.lang.Object arg)
reportProblem in interface InputProblemReporter
public void reportProblem(java.lang.String probType,
java.lang.String format,
java.lang.Object arg,
java.lang.Object arg2)
reportProblem in interface InputProblemReporter
public void reportProblem(java.lang.String probType,
java.lang.String format,
java.lang.Object arg,
java.lang.Object arg2,
javax.xml.stream.Location loc)
reportProblem in interface InputProblemReporter
protected void throwUnexpectedChar(int i,
java.lang.String msg)
throws WstxException
WstxException
protected void throwNullChar()
throws WstxException
WstxException
protected void throwUnexpectedEOF(java.lang.String msg)
throws WstxException
WstxException
protected void throwUnexpectedEOB(java.lang.String msg)
throws WstxException
throwUnexpectedEOF(java.lang.String), but only indicates ending
of an input block. Used when reading a token that can not span
input block boundaries (ie. can not continue past end of an
entity expansion).
WstxException
protected void throwFromIOE(java.io.IOException ioe)
throws WstxException
WstxException
protected void throwFromStrE(javax.xml.stream.XMLStreamException strex)
throws WstxException
WstxExceptionprotected void throwLazyError(java.lang.Exception e)
protected java.lang.String tokenTypeDesc(int type)
public final WstxInputSource getCurrentInput()
Note: public only because some implementations are on different package.
protected final int inputInBuffer()
protected final int getNext()
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final char getNextChar(java.lang.String errorMsg)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final char getNextCharFromCurrent(java.lang.String errorMsg)
throws java.io.IOException,
WstxException
getNextChar(java.lang.String), but will not read more characters
from parent input source(s) if the current input source doesn't
have more content. This is often needed to prevent "runaway" content,
such as comments that start in an entity but do not have matching
close marker inside entity; XML specification specifically states
such markup is not legal.
java.io.IOException
WstxException
protected final int peekNext()
throws java.io.IOException,
WstxException
getNext(), but does not advance pointer
in input buffer.
Note: this method only peeks within current input source; it does not close it and check nested input source (if any). This because that's never the desired behaviour (if such behaviour is needed, have to create a new method).
java.io.IOException
WstxException
protected final int getNextAfterWS(char c)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final char getNextCharAfterWS(char c,
java.lang.String errorMsg)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final int getNextAfterWS()
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final char getNextCharAfterWS(java.lang.String errorMsg)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final char getNextInCurrAfterWS(java.lang.String errorMsg)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final char getNextInCurrAfterWS(java.lang.String errorMsg,
char c)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final void skipWS()
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final boolean skipCRLF(char c)
throws java.io.IOException,
WstxException
java.io.IOException
WstxExceptionprotected final void markLF()
protected final void markLF(int inputPtr)
protected final void pushback()
protected void initInputSource(WstxInputSource newInput,
boolean isExt)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected boolean loadMore()
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final boolean loadMore(java.lang.String errorMsg)
throws WstxException,
java.io.IOException
WstxException
java.io.IOException
protected boolean loadMoreFromCurrent()
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final boolean loadMoreFromCurrent(java.lang.String errorMsg)
throws WstxException,
java.io.IOException
WstxException
java.io.IOException
protected boolean ensureInput(int minAmount)
throws java.io.IOException
loadMore(). It can only be called
when input comes from main-level buffer; further, call can shift
content in input buffer, so caller has to flush any data still
pending. In short, caller has to know exactly what it's doing. :-)
Note: method does not check for any other input sources than the current one -- if current source can not fulfill the request, a failure is indicated.
java.io.IOException
protected char resolveSimpleEntity(boolean checkStd)
throws WstxException
Note: On entry we are guaranteed there are at least 3 more characters in this buffer; otherwise we shouldn't be called.
checkStd - If true, will check pre-defined internal entities
(gt, lt, amp, apos, quot); if false, will only check actual
character entities.
WstxException
protected char resolveCharOnlyEntity(boolean checkStd)
throws java.io.IOException,
WstxException
Most often this method is called when reader is not to expand non-char entities automatically, but to return them as separate events.
Main complication here is that we need to do 5-char lookahead. This is problematic if chars are on input buffer boundary. This is ok for the root level input buffer, but not for some nested buffers. However, according to XML specs, such split entities are actually illegal... so we can throw an exception in those cases.
checkStd - If true, will check pre-defined internal entities
(gt, lt, amp, apos, quot) as character entities; if false, will only
check actual 'real' character entities.
java.io.IOException
WstxException
protected EntityDecl resolveNonCharEntity(java.util.Map ent1,
java.util.Map ent2)
throws java.io.IOException,
WstxException
resolveCharOnlyEntity(boolean); will only resolve entity
if it is NOT a character entity (or pre-defined 'generic' entity;
amp, apos, lt, gt or quot). Only used in cases where entities
are to be separately returned unexpanded.
java.io.IOException
WstxException
protected char fullyResolveEntity(java.util.Map ent1,
java.util.Map ent2,
boolean allowExt)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
ent1 - ent2 - allowExt - If true, is allowed to expand external entities
(expanding text); if false, is not (expanding attribute value).
java.io.IOException
javax.xml.stream.XMLStreamException
protected int expandEntity(java.lang.String id,
java.util.Map ent1,
java.util.Map ent2,
boolean allowExt)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected void expandEntity(EntityDecl ed,
boolean allowExt)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected java.lang.String parseLocalName(char c)
throws java.io.IOException,
WstxException
Much of complexity in this method has to do with the intention to try to avoid any character copies. In this optimal case algorithm would be fairly simple. However, this only works if all data is already in input buffer... if not, copy has to be made halfway through parsing, and that complicates things.
One thing to note is that String returned has been canonicalized and (if necessary) added to symbol table. It can thus be compared against other such (usually id) Strings, with simple equality operator.
c - First character of the name; not yet checked for validity
java.io.IOException
WstxException
protected java.lang.String parseLocalName2(int start,
int hash)
throws java.io.IOException,
WstxException
Note that this isn't heavily optimized, on assumption it's not called very often.
java.io.IOException
WstxException
protected java.lang.String parseFullName()
throws java.io.IOException,
WstxException
Similar to parseLocalName(char), much of complexity stems from
trying to avoid copying name characters from input buffer.
Note that returned String will be canonicalized, similar to
parseLocalName(char), but without separating prefix/local name.
java.io.IOException
WstxException
protected java.lang.String parseFullName(char c)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected java.lang.String parseFullName2(int start,
int hash)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected java.lang.String parseFNameForError()
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final java.lang.String parseEntityName(char c)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected int skipFullName(char c)
throws java.io.IOException,
WstxException
java.io.IOException
WstxException
protected final java.lang.String parseSystemId(char quoteChar,
boolean convertLFs,
java.lang.String errorMsg)
throws java.io.IOException,
WstxException
NOTE: returned String is not canonicalized, on assumption that
external ids may be longish, and are not shared all that often, as
they are generally just used for resolving paths, if anything.
Also note that this method is not heavily optimized, as it's not
likely to be a bottleneck for parsing.
java.io.IOException
WstxException
protected final java.lang.String parsePublicId(char quoteChar,
boolean convertLFs,
java.lang.String errorMsg)
throws java.io.IOException,
WstxException
NOTE: returned String is not canonicalized, on assumption that
external ids may be longish, and are not shared all that often, as
they are generally just used for resolving paths, if anything.
Also note that this method is not heavily optimized, as it's not
likely to be a bottleneck for parsing.
java.io.IOException
WstxException
protected final void parseUntil(TextBuffer tb,
char endChar,
boolean convertLFs,
java.lang.String errorMsg)
throws java.io.IOException,
WstxException
java.io.IOException
WstxExceptionprotected final char[] getNameBuffer(int minSize)
protected final char[] expandBy50Pct(char[] buf)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||