|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.fasterxml.aalto.in.XmlScanner
com.fasterxml.aalto.in.ByteBasedScanner
com.fasterxml.aalto.async.AsyncByteScanner
public abstract class AsyncByteScanner
This is the base class for asynchronous (non-blocking) xml scanners. Due to basic complexity of async approach, character-based doesn't make much sense, so only byte-based input is supported.
| Field Summary | |
|---|---|
protected int |
_currQuad
Bytes parsed for the current, incomplete, quad |
protected int |
_currQuadBytes
Number of bytes pending/buffered, stored in _currQuad |
protected byte[] |
_inputBuffer
This buffer is actually provided by caller |
static int |
EVENT_INCOMPLETE
As per javadocs of XMLStreamConstants,
event codes 0 through 256 (inclusive?) are reserved by the Stax
specs, so we'll use the next available code. |
protected boolean |
mElemAllNsBound
|
protected boolean |
mElemAttrCount
|
protected PName |
mElemAttrName
|
protected int |
mElemAttrPtr
|
protected byte |
mElemAttrQuote
|
protected int |
mNextEvent
Due to asynchronous nature of parsing, we may know what event we are trying to parse, even if it's not yet complete. |
protected int |
mOrigBufferLen
In addition to current buffer pointer, and end pointer, we will also need to know number of bytes originally contained. |
protected int |
mPendingInput
There are some multi-byte combinations that must be handled as a unit: CR+LF linefeeds, multi-byte UTF-8 characters, and multi-character end markers for comments and PIs. |
protected int |
mQuadCount
Number of complete quads parsed for current name (quads themselves are stored in ByteBasedScanner.mQuadBuffer). |
protected int |
mState
In addition to the event type, there is need for additional state information |
protected int |
mSurroundingEvent
For token/state combinations that are 'shared' between events (or embedded in them), this is where the surrounding event state is retained. |
| Fields inherited from class com.fasterxml.aalto.in.ByteBasedScanner |
|---|
_inputEnd, _inputPtr, BYTE_a, BYTE_A, BYTE_AMP, BYTE_APOS, BYTE_C, BYTE_CR, BYTE_D, BYTE_EQ, BYTE_EXCL, BYTE_g, BYTE_GT, BYTE_HASH, BYTE_HYPHEN, BYTE_l, BYTE_LBRACKET, BYTE_LF, BYTE_LT, BYTE_m, BYTE_NULL, BYTE_o, BYTE_p, BYTE_P, BYTE_q, BYTE_QMARK, BYTE_QUOT, BYTE_RBRACKET, BYTE_s, BYTE_S, BYTE_SEMICOLON, BYTE_SLASH, BYTE_SPACE, BYTE_t, BYTE_T, BYTE_TAB, BYTE_u, BYTE_x, mCharTypes, mPastBytes, mQuadBuffer, mRowStartOffset, mSymbols, mTmpChar |
| Fields inherited from class com.fasterxml.aalto.in.XmlScanner |
|---|
_attrCollector, _attrCount, _cfgCoalescing, _cfgLazyParsing, _config, _currElem, _currNsCount, _currRow, _currToken, _defaultNs, _depth, _entityPending, _isEmptyTag, _lastNsContext, _lastNsDecl, _nameBuffer, _publicId, _systemId, _textBuilder, _tokenIncomplete, _tokenName, _xml11, CDATA_STR, INT_A, INT_AMP, INT_APOS, INT_COLON, INT_CR, INT_EQ, INT_EXCL, INT_GT, INT_HYPHEN, INT_LBRACKET, INT_LF, INT_LT, INT_NULL, INT_QMARK, INT_QUOTE, INT_RBRACKET, INT_SLASH, INT_SPACE, INT_TAB, MAX_UNICODE_CHAR, TOKEN_EOI |
| Fields inherited from interface com.fasterxml.aalto.XmlConsts |
|---|
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 |
| 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 | |
|---|---|
AsyncByteScanner(ReaderConfig cfg)
|
|
| Method Summary | |
|---|---|
protected void |
_closeSource()
Since the async scanner has no access to whatever passes content, there is no input source in same sense as with blocking scanner; and there is nothing to close. |
void |
addInput(byte[] buf,
int start,
int len)
|
protected abstract PName |
addPName(int hash,
int[] quads,
int qlen,
int lastQuadBytes)
|
protected int |
decodeCharForError(byte b)
Method called by methods when encountering a byte that can not be part of a valid character in the current context. |
protected void |
finishCData()
|
protected abstract void |
finishCharacters()
|
protected abstract int |
finishCharactersCoalescing()
|
protected void |
finishComment()
|
protected void |
finishDTD(boolean copyContents)
|
protected void |
finishPI()
|
protected void |
finishSpace()
|
protected abstract boolean |
handleAttrValue()
|
protected int |
handleCharacterEntity()
|
protected int |
handleEntity()
|
protected int |
handleEntityStart(int surroundingEvent,
byte b)
|
protected int |
handleGeneralEntity(PName entityName)
|
protected abstract boolean |
handleNsDecl()
|
protected boolean |
handlePartialCR()
Method called when there is a pending \r (from past buffer), and we need to see |
protected int |
handleStartElement()
|
protected int |
handleStartElementStart(byte b)
Method called when '<' and (what appears to be) a name start character have been seen. |
boolean |
hasInput()
|
protected boolean |
loadMore()
|
int |
nextFromProlog(boolean isProlog)
|
int |
nextFromTree()
|
protected abstract int |
parseCommentContents()
|
protected PName |
parseEntityName()
|
protected PName |
parseNewEntityName(byte b)
|
protected PName |
parseNewName(byte b)
|
protected abstract int |
parsePIData()
|
protected PName |
parsePName()
This method can (for now?) be shared between all Ascii-based encodings, since it only does coarse validity checking -- real checks are done in different method. |
protected void |
skipCData()
|
protected abstract boolean |
skipCharacters()
|
protected void |
skipComment()
|
protected void |
skipPI()
|
protected void |
skipSpace()
|
protected abstract int |
startCharacters(byte b)
Method called to initialize state for CHARACTERS event, after just a single byte has been seen. |
protected abstract int |
startCharactersPending()
This method gets called, if the first character of a CHARACTERS event could not be fully read (multi-byte, split over buffer boundary). |
protected int |
throwInternal()
|
java.lang.String |
toString()
|
| Methods inherited from class com.fasterxml.aalto.in.ByteBasedScanner |
|---|
_releaseBuffers, addUtfPName, getCurrentColumnNr, getCurrentLineNr, getCurrentLocation, markLF, markLF, reportInvalidInitial, reportInvalidOther |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int EVENT_INCOMPLETE
XMLStreamConstants,
event codes 0 through 256 (inclusive?) are reserved by the Stax
specs, so we'll use the next available code.
protected byte[] _inputBuffer
protected int mOrigBufferLen
protected int mNextEvent
protected int mState
protected int mSurroundingEvent
protected int mPendingInput
If so, this int will store byte(s), in little-endian format (that is, first pending byte is at 0x000000FF, second [if any] at 0x0000FF00, and third at 0x00FF0000). This can be (and is) used to figure out actual number of bytes pending, for multi-byte (UTF-8) character decoding.
Note: it is assumed that if value is 0, there is no data. Thus, if 0 needed to be added pending, it has to be masked.
protected int mQuadCount
ByteBasedScanner.mQuadBuffer).
protected int _currQuad
protected int _currQuadBytes
_currQuad
protected boolean mElemAllNsBound
protected boolean mElemAttrCount
protected byte mElemAttrQuote
protected PName mElemAttrName
protected int mElemAttrPtr
| Constructor Detail |
|---|
public AsyncByteScanner(ReaderConfig cfg)
| Method Detail |
|---|
public java.lang.String toString()
toString in class java.lang.Objectpublic final boolean hasInput()
public void addInput(byte[] buf,
int start,
int len)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected void _closeSource()
throws java.io.IOException
_closeSource in class ByteBasedScannerjava.io.IOException
public final int nextFromProlog(boolean isProlog)
throws javax.xml.stream.XMLStreamException
nextFromProlog in class XmlScannerjavax.xml.stream.XMLStreamException
public int nextFromTree()
throws javax.xml.stream.XMLStreamException
nextFromTree in class XmlScannerjavax.xml.stream.XMLStreamException
protected abstract int parseCommentContents()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected abstract int parsePIData()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected abstract int startCharacters(byte b)
throws javax.xml.stream.XMLStreamException
XMLStreamReader.next() returns, no
blocking can occur when calling other methods.
javax.xml.stream.XMLStreamException
protected abstract int startCharactersPending()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected abstract int finishCharactersCoalescing()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected int handleEntityStart(int surroundingEvent,
byte b)
throws javax.xml.stream.XMLStreamException
surroundingEvent - Context (next event at the time
ampersand was encountered) in which entity is found. Will
often be the next event set after entity is resolve.
javax.xml.stream.XMLStreamException
protected int handleEntity()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionprotected final int handleGeneralEntity(PName entityName)
protected int handleStartElementStart(byte b)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected int handleStartElement()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected abstract boolean handleAttrValue()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected abstract boolean handleNsDecl()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected abstract void finishCharacters()
throws javax.xml.stream.XMLStreamException
finishCharacters in class XmlScannerjavax.xml.stream.XMLStreamException
protected void finishCData()
throws javax.xml.stream.XMLStreamException
finishCData in class XmlScannerjavax.xml.stream.XMLStreamException
protected void finishComment()
throws javax.xml.stream.XMLStreamException
finishComment in class XmlScannerjavax.xml.stream.XMLStreamException
protected void finishDTD(boolean copyContents)
throws javax.xml.stream.XMLStreamException
finishDTD in class XmlScannerjavax.xml.stream.XMLStreamException
protected void finishPI()
throws javax.xml.stream.XMLStreamException
finishPI in class XmlScannerjavax.xml.stream.XMLStreamException
protected void finishSpace()
throws javax.xml.stream.XMLStreamException
finishSpace in class XmlScannerjavax.xml.stream.XMLStreamException
protected abstract boolean skipCharacters()
throws javax.xml.stream.XMLStreamException
skipCharacters in class XmlScannerjavax.xml.stream.XMLStreamException
protected void skipCData()
throws javax.xml.stream.XMLStreamException
skipCData in class XmlScannerjavax.xml.stream.XMLStreamException
protected void skipComment()
throws javax.xml.stream.XMLStreamException
skipComment in class XmlScannerjavax.xml.stream.XMLStreamException
protected void skipPI()
throws javax.xml.stream.XMLStreamException
skipPI in class XmlScannerjavax.xml.stream.XMLStreamException
protected void skipSpace()
throws javax.xml.stream.XMLStreamException
skipSpace in class XmlScannerjavax.xml.stream.XMLStreamException
protected boolean loadMore()
throws javax.xml.stream.XMLStreamException
loadMore in class XmlScannerjavax.xml.stream.XMLStreamException
protected PName parseNewName(byte b)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected PName parseNewEntityName(byte b)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected PName parsePName()
throws javax.xml.stream.XMLStreamException
Some notes about assumption implementation makes:
javax.xml.stream.XMLStreamException
protected PName parseEntityName()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected abstract PName addPName(int hash,
int[] quads,
int qlen,
int lastQuadBytes)
throws javax.xml.stream.XMLStreamException
addPName in class ByteBasedScannerjavax.xml.stream.XMLStreamException
protected int decodeCharForError(byte b)
throws javax.xml.stream.XMLStreamException
ByteBasedScanner
decodeCharForError in class ByteBasedScannerjavax.xml.stream.XMLStreamException
protected int handleCharacterEntity()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionprotected final boolean handlePartialCR()
protected int throwInternal()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||