Package com.fasterxml.aalto.async
Class AsyncByteArrayScanner
- java.lang.Object
-
- com.fasterxml.aalto.in.XmlScanner
-
- com.fasterxml.aalto.in.ByteBasedScanner
-
- com.fasterxml.aalto.async.AsyncByteScanner
-
- com.fasterxml.aalto.async.AsyncByteArrayScanner
-
- All Implemented Interfaces:
AsyncByteArrayFeeder,AsyncInputFeeder,XmlConsts,javax.xml.namespace.NamespaceContext,javax.xml.stream.XMLStreamConstants
public class AsyncByteArrayScanner extends AsyncByteScanner implements AsyncByteArrayFeeder
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
Fields Modifier and Type Field Description protected byte[]_inputBufferThis buffer is actually provided by callerprotected int_origBufferLenIn addition to current buffer pointer, and end pointer, we will also need to know number of bytes originally contained.-
Fields inherited from class com.fasterxml.aalto.async.AsyncByteScanner
_charTypes, _currQuad, _currQuadBytes, _elemAllNsBound, _elemAttrCount, _elemAttrName, _elemAttrPtr, _elemAttrQuote, _elemNsPtr, _endOfInput, _entityValue, _inDtdDeclaration, _nextEvent, _pendingInput, _quadBuffer, _quadCount, _state, _surroundingEvent, _symbols, EVENT_INCOMPLETE, PENDING_STATE_ATTR_VALUE_AMP, PENDING_STATE_ATTR_VALUE_AMP_HASH, PENDING_STATE_ATTR_VALUE_AMP_HASH_X, PENDING_STATE_ATTR_VALUE_DEC_DIGIT, PENDING_STATE_ATTR_VALUE_ENTITY_NAME, PENDING_STATE_ATTR_VALUE_HEX_DIGIT, PENDING_STATE_CDATA_BRACKET1, PENDING_STATE_CDATA_BRACKET2, PENDING_STATE_COMMENT_HYPHEN1, PENDING_STATE_COMMENT_HYPHEN2, PENDING_STATE_CR, PENDING_STATE_ENT_IN_DEC_DIGIT, PENDING_STATE_ENT_IN_HEX_DIGIT, PENDING_STATE_ENT_SEEN_HASH, PENDING_STATE_ENT_SEEN_HASH_X, PENDING_STATE_PI_QMARK, PENDING_STATE_TEXT_AMP, PENDING_STATE_TEXT_AMP_HASH, PENDING_STATE_TEXT_BRACKET1, PENDING_STATE_TEXT_BRACKET2, PENDING_STATE_TEXT_DEC_ENTITY, PENDING_STATE_TEXT_HEX_ENTITY, PENDING_STATE_TEXT_IN_ENTITY, PENDING_STATE_XMLDECL_LT, PENDING_STATE_XMLDECL_LTQ, PENDING_STATE_XMLDECL_TARGET, STATE_CDATA_C, STATE_CDATA_CD, STATE_CDATA_CDA, STATE_CDATA_CDAT, STATE_CDATA_CDATA, STATE_CDATA_CONTENT, STATE_COMMENT_CONTENT, STATE_COMMENT_HYPHEN, STATE_COMMENT_HYPHEN2, STATE_DEFAULT, STATE_DTD_AFTER_DOCTYPE, STATE_DTD_AFTER_PUBLIC, STATE_DTD_AFTER_PUBLIC_ID, STATE_DTD_AFTER_ROOT_NAME, STATE_DTD_AFTER_SYSTEM, STATE_DTD_AFTER_SYSTEM_ID, STATE_DTD_BEFORE_IDS, STATE_DTD_BEFORE_PUBLIC_ID, STATE_DTD_BEFORE_ROOT_NAME, STATE_DTD_BEFORE_SYSTEM_ID, STATE_DTD_DOCTYPE, STATE_DTD_EXPECT_CLOSING_GT, STATE_DTD_INT_SUBSET, STATE_DTD_PUBLIC_ID, STATE_DTD_PUBLIC_OR_SYSTEM, STATE_DTD_ROOT_NAME, STATE_DTD_SYSTEM_ID, STATE_EE_NEED_GT, STATE_PI_AFTER_TARGET, STATE_PI_AFTER_TARGET_QMARK, STATE_PI_AFTER_TARGET_WS, STATE_PI_IN_DATA, STATE_PI_IN_TARGET, STATE_PROLOG_DECL, STATE_PROLOG_INITIAL, STATE_PROLOG_SEEN_LT, STATE_SE_ATTR_NAME, STATE_SE_ATTR_VALUE_NORMAL, STATE_SE_ATTR_VALUE_NSDECL, STATE_SE_ELEM_NAME, STATE_SE_SEEN_SLASH, STATE_SE_SPACE_OR_ATTRNAME, STATE_SE_SPACE_OR_ATTRVALUE, STATE_SE_SPACE_OR_END, STATE_SE_SPACE_OR_EQ, STATE_TEXT_AMP, STATE_TEXT_AMP_NAME, STATE_TREE_NAMED_ENTITY_START, STATE_TREE_NUMERIC_ENTITY_START, STATE_TREE_SEEN_AMP, STATE_TREE_SEEN_EXCL, STATE_TREE_SEEN_LT, STATE_TREE_SEEN_SLASH, STATE_XMLDECL_AFTER_ENCODING, STATE_XMLDECL_AFTER_ENCODING_VALUE, STATE_XMLDECL_AFTER_STANDALONE, STATE_XMLDECL_AFTER_STANDALONE_VALUE, STATE_XMLDECL_AFTER_VERSION, STATE_XMLDECL_AFTER_VERSION_VALUE, STATE_XMLDECL_AFTER_XML, STATE_XMLDECL_BEFORE_ENCODING, STATE_XMLDECL_BEFORE_STANDALONE, STATE_XMLDECL_BEFORE_VERSION, STATE_XMLDECL_ENCODING, STATE_XMLDECL_ENCODING_EQ, STATE_XMLDECL_ENCODING_VALUE, STATE_XMLDECL_ENDQ, STATE_XMLDECL_STANDALONE, STATE_XMLDECL_STANDALONE_EQ, STATE_XMLDECL_STANDALONE_VALUE, STATE_XMLDECL_VERSION, STATE_XMLDECL_VERSION_EQ, STATE_XMLDECL_VERSION_VALUE
-
Fields inherited from class com.fasterxml.aalto.in.ByteBasedScanner
_inputEnd, _inputPtr, _tmpChar, 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
-
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, _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
-
Fields inherited from interface com.fasterxml.aalto.util.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
-
-
Constructor Summary
Constructors Constructor Description AsyncByteArrayScanner(ReaderConfig cfg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte_currentByte()protected byte_nextByte()protected byte_prevByte()protected booleanasyncSkipSpace()Method to skip whatever space can be skipped.protected booleandecodeDecEntity()protected intdecodeGeneralEntity(PName entityName)Method that verifies that given named entity is followed by a semi-colon (meaning next byte must be available for reading); and if so, whether it is one of pre-defined general entities.protected booleandecodeHexEntity()protected intdecodeUtf8_2(int c)Note: caller must guarantee enough data is available before calling the methodprotected intdecodeUtf8_3(int c1)Note: caller must guarantee enough data is available before calling the methodprotected intdecodeUtf8_3(int c1, int c2, int c3)protected intdecodeUtf8_4(int c)protected intdecodeUtf8_4(int c1, int c2, int c3, int c4)voidfeedInput(byte[] buf, int start, int len)Method that can be called to feed more data, if (and only if)AsyncInputFeeder.needMoreInput()returns true.protected voidfinishCharacters()This method only gets called in non-coalescing mode; and if so, needs to parse as many characters of the current text segment from the current input block as possible.protected intfinishCharactersCoalescing()TODO: Method not yet implementedprivate intfinishStartElement(boolean emptyTag)Method called to wrap up settings when the whole start (or empty) element has been parsed.private booleanhandleAndAppendPending()Method called to handle split multi-byte character, by decoding it and appending to the text buffer, if possible.protected booleanhandleAttrValue()private booleanhandleAttrValuePending()private inthandleAttrValuePendingUTF8()private inthandleCData()protected inthandleCDataPending()private inthandleCDataStartMarker(byte b)protected inthandleComment()protected inthandleCommentPending()private inthandleDecEntityInAttribute(boolean starting)protected inthandleDecEntityInCharacters(int ptr)protected booleanhandleDTDInternalSubset(boolean init)private inthandleEndElement()This method is "slow" version of above, used when name of the end element can split input buffer boundaryprivate inthandleEndElementStart()protected inthandleEntityInAttributeValue()Method called to handle entity encountered inside attribute value.protected inthandleEntityInCharacters()Method called to handle entity encountered inside CHARACTERS segment, when trying to complete a non-coalescing text segment.protected inthandleEntityStartingToken()Method called when a new token (within tree) starts with an entity.private inthandleHexEntityInAttribute(boolean starting)protected inthandleHexEntityInCharacters(int ptr)protected inthandleNamedEntityStartingToken()Method called when we see an entity that is starting a new token, and part of its name has been decoded (but not all)protected booleanhandleNsDecl()private booleanhandleNsValuePending()protected inthandleNumericEntityStartingToken()Method called to handle cases where we find something other than a character entity (or one of 4 pre-defined general entities that act like character entities)protected booleanhandlePartialCR()Method called when there is a pending \r (from past buffer), and we need to seeprotected inthandlePI()protected inthandlePIPending()protected inthandleStartElement()protected inthandleStartElementStart(byte b)Method called when '<' and (what appears to be) a name start character have been seen.private voidinitAttribute(byte quoteChar)private voidinitStartElement(PName elemName)booleanneedMoreInput()Method called to check whether it is ok to feed more data: parser returns true if it has no more content to parse (and it is ok to feed more); otherwise false (and no data should yet be fed).intnextFromTree()protected intparseCDataContents()protected intparseCommentContents()protected PNameparseEntityName()protected PNameparseNewEntityName(byte b)protected PNameparseNewName(byte b)protected intparsePIData()protected PNameparsePName()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 booleanskipCharacters()Method that will be called to skip all possible characters from the input buffer, but without blocking.protected booleanskipCoalescedText()Coalescing mode is (and will) not be implemented for non-blocking parsers, so this method should never get called.private intskipEntityInCharacters()Method called to handle entity encountered inside CHARACTERS segment, when trying to complete a non-coalescing text segment.private booleanskipPending()protected voidskipUtf8_2(int c)protected intstartCharacters(byte b)Method called to initialize state for CHARACTERS event, after just a single byte has been seen.protected intstartCharactersPending()This method gets called, if the first character of a CHARACTERS event could not be fully read (multi-byte, split over buffer boundary).java.lang.StringtoString()-
Methods inherited from class com.fasterxml.aalto.async.AsyncByteScanner
_activateEncoding, _closeSource, _findXmlDeclName, _releaseBuffers, _startDocumentNoXmlDecl, addPName, checkPITargetName, decodeCharForError, endOfInput, findPName, finishCData, finishComment, finishDTD, finishPI, finishSpace, finishToken, loadMore, nextFromProlog, parseXmlDeclAttr, reportInvalidOther, skipCData, skipComment, skipPI, skipSpace, throwInternal, validPublicIdChar, verifyAndAppendEntityCharacter, verifyAndSetPublicId, verifyAndSetSystemId, verifyAndSetXmlEncoding, verifyAndSetXmlStandalone, verifyAndSetXmlVersion
-
Methods inherited from class com.fasterxml.aalto.in.ByteBasedScanner
addUTFPName, getCurrentColumnNr, getCurrentLocation, getEndingByteOffset, getEndingCharOffset, getStartingByteOffset, getStartingCharOffset, markLF, markLF, reportInvalidInitial, reportInvalidOther, setStartLocation
-
Methods inherited from class com.fasterxml.aalto.in.XmlScanner
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, reportPrologUnexpElement, reportTreeUnexpChar, reportUnboundPrefix, reportUnexpandedEntityInAttr, reportUnexpectedEndTag, resetForDecoding, skipToken, throwInvalidSpace, throwNullChar, throwUnexpectedChar, verifyXmlChar
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.fasterxml.aalto.AsyncInputFeeder
endOfInput
-
-
-
-
Field Detail
-
_inputBuffer
protected byte[] _inputBuffer
This buffer is actually provided by caller
-
_origBufferLen
protected int _origBufferLen
In addition to current buffer pointer, and end pointer, we will also need to know number of bytes originally contained. This is needed to correctly update location information when the block has been completed.
-
-
Constructor Detail
-
AsyncByteArrayScanner
public AsyncByteArrayScanner(ReaderConfig cfg)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
_currentByte
protected final byte _currentByte() throws javax.xml.stream.XMLStreamException- Specified by:
_currentBytein classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
_nextByte
protected final byte _nextByte() throws javax.xml.stream.XMLStreamException- Specified by:
_nextBytein classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
_prevByte
protected final byte _prevByte() throws javax.xml.stream.XMLStreamException- Specified by:
_prevBytein classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
parseCommentContents
protected int parseCommentContents() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handleCommentPending
protected int handleCommentPending() throws javax.xml.stream.XMLStreamException- Returns:
- EVENT_INCOMPLETE, if there's not enough input to handle pending char, COMMENT, if we handled complete "-->" end marker, or 0 to indicate something else was succesfully handled.
- Throws:
javax.xml.stream.XMLStreamException
-
parsePIData
protected int parsePIData() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handlePIPending
protected int handlePIPending() throws javax.xml.stream.XMLStreamException- Returns:
- EVENT_INCOMPLETE, if there's not enough input to handle pending char, PROCESSING_INSTRUCTION, if we handled complete "?>" end marker, or 0 to indicate something else was succesfully handled.
- Throws:
javax.xml.stream.XMLStreamException
-
handleDTDInternalSubset
protected final boolean handleDTDInternalSubset(boolean init) throws javax.xml.stream.XMLStreamException- Specified by:
handleDTDInternalSubsetin classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
parseCDataContents
protected final int parseCDataContents() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handleCDataPending
protected final int handleCDataPending() throws javax.xml.stream.XMLStreamException- Returns:
- EVENT_INCOMPLETE, if there's not enough input to handle pending char, CDATA, if we handled complete "]]>" end marker, or 0 to indicate something else was succesfully handled.
- Throws:
javax.xml.stream.XMLStreamException
-
startCharactersPending
protected int startCharactersPending() throws javax.xml.stream.XMLStreamExceptionThis method gets called, if the first character of a CHARACTERS event could not be fully read (multi-byte, split over buffer boundary). If so, there is some pending data to be handled.- Throws:
javax.xml.stream.XMLStreamException
-
finishCharactersCoalescing
protected final int finishCharactersCoalescing() throws javax.xml.stream.XMLStreamExceptionTODO: Method not yet implemented- Throws:
javax.xml.stream.XMLStreamException
-
needMoreInput
public final boolean needMoreInput()
Description copied from interface:AsyncInputFeederMethod called to check whether it is ok to feed more data: parser returns true if it has no more content to parse (and it is ok to feed more); otherwise false (and no data should yet be fed).- Specified by:
needMoreInputin interfaceAsyncInputFeeder
-
feedInput
public void feedInput(byte[] buf, int start, int len) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:AsyncByteArrayFeederMethod that can be called to feed more data, if (and only if)AsyncInputFeeder.needMoreInput()returns true.- Specified by:
feedInputin interfaceAsyncByteArrayFeeder- Parameters:
buf- Byte array that containts data to feed: caller must ensure data remains stable until it is fully processed (which is true whenAsyncInputFeeder.needMoreInput()returns true)start- Offset within array where input data to process startslen- Length of input data within array to process.- Throws:
javax.xml.stream.XMLStreamException- if the state is such that this method should not be called (has not yet consumed existing input data, or has been marked as closed)
-
nextFromTree
public int nextFromTree() throws javax.xml.stream.XMLStreamException- Specified by:
nextFromTreein classXmlScanner- Throws:
javax.xml.stream.XMLStreamException
-
handleCData
private int handleCData() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handleCDataStartMarker
private int handleCDataStartMarker(byte b) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handlePI
protected int handlePI() throws javax.xml.stream.XMLStreamException- Specified by:
handlePIin classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
handleComment
protected final int handleComment() throws javax.xml.stream.XMLStreamException- Specified by:
handleCommentin classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
asyncSkipSpace
protected boolean asyncSkipSpace() throws javax.xml.stream.XMLStreamExceptionMethod to skip whatever space can be skipped.NOTE: if available content ends with a CR, method will set
_pendingInputtoPENDING_STATE_CR.- Specified by:
asyncSkipSpacein classAsyncByteScanner- Returns:
- True, if was able to skip through the space and find a non-space byte; false if reached end-of-buffer
- Throws:
javax.xml.stream.XMLStreamException
-
handleEntityStartingToken
protected int handleEntityStartingToken() throws javax.xml.stream.XMLStreamExceptionMethod called when a new token (within tree) starts with an entity.- Returns:
- Type of event to return
- Throws:
javax.xml.stream.XMLStreamException
-
handleNamedEntityStartingToken
protected int handleNamedEntityStartingToken() throws javax.xml.stream.XMLStreamExceptionMethod called when we see an entity that is starting a new token, and part of its name has been decoded (but not all)- Throws:
javax.xml.stream.XMLStreamException
-
handleNumericEntityStartingToken
protected int handleNumericEntityStartingToken() throws javax.xml.stream.XMLStreamExceptionMethod called to handle cases where we find something other than a character entity (or one of 4 pre-defined general entities that act like character entities)- Throws:
javax.xml.stream.XMLStreamException
-
decodeHexEntity
protected final boolean decodeHexEntity() throws javax.xml.stream.XMLStreamException- Returns:
- True if entity was decoded (and value assigned to
_entityValue; false otherwise - Throws:
javax.xml.stream.XMLStreamException
-
decodeDecEntity
protected final boolean decodeDecEntity() throws javax.xml.stream.XMLStreamException- Returns:
- True if entity was decoded (and value assigned to
_entityValue; false otherwise - Throws:
javax.xml.stream.XMLStreamException
-
decodeGeneralEntity
protected final int decodeGeneralEntity(PName entityName) throws javax.xml.stream.XMLStreamException
Method that verifies that given named entity is followed by a semi-colon (meaning next byte must be available for reading); and if so, whether it is one of pre-defined general entities.- Returns:
- Character of the expanded pre-defined general entity (if name matches one); zero if not.
- Throws:
javax.xml.stream.XMLStreamException
-
handleStartElementStart
protected int handleStartElementStart(byte b) throws javax.xml.stream.XMLStreamExceptionMethod called when '<' and (what appears to be) a name start character have been seen.- Specified by:
handleStartElementStartin classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
handleStartElement
protected int handleStartElement() throws javax.xml.stream.XMLStreamException- Specified by:
handleStartElementin classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
initStartElement
private void initStartElement(PName elemName)
-
initAttribute
private void initAttribute(byte quoteChar)
-
finishStartElement
private int finishStartElement(boolean emptyTag) throws javax.xml.stream.XMLStreamExceptionMethod called to wrap up settings when the whole start (or empty) element has been parsed.- Throws:
javax.xml.stream.XMLStreamException
-
handleEndElementStart
private int handleEndElementStart() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handleEndElement
private int handleEndElement() throws javax.xml.stream.XMLStreamExceptionThis method is "slow" version of above, used when name of the end element can split input buffer boundary- Throws:
javax.xml.stream.XMLStreamException
-
startCharacters
protected final int startCharacters(byte b) throws javax.xml.stream.XMLStreamExceptionDescription copied from class:AsyncByteScannerMethod called to initialize state for CHARACTERS event, after just a single byte has been seen. What needs to be done next depends on whether coalescing mode is set or not: if it is not set, just a single character needs to be decoded, after which current event will be incomplete, but defined as CHARACTERS. In coalescing mode, the whole content must be read before current event can be defined. The reason for difference is that whenXMLStreamReader.next()returns, no blocking can occur when calling other methods.- Specified by:
startCharactersin classAsyncByteScanner- Returns:
- Event type detected; either CHARACTERS, if at least one full character was decoded (and can be returned), EVENT_INCOMPLETE if not (part of a multi-byte character split across input buffer boundary)
- Throws:
javax.xml.stream.XMLStreamException
-
finishCharacters
protected final void finishCharacters() throws javax.xml.stream.XMLStreamExceptionThis method only gets called in non-coalescing mode; and if so, needs to parse as many characters of the current text segment from the current input block as possible.- Specified by:
finishCharactersin classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
handleEntityInCharacters
protected int handleEntityInCharacters() throws javax.xml.stream.XMLStreamExceptionMethod called to handle entity encountered inside CHARACTERS segment, when trying to complete a non-coalescing text segment.NOTE: unlike with generic parsing of named entities, where trailing semicolon needs to be left in place, here we should just process it right away.
- Returns:
- Expanded (character) entity, if positive number; 0 if incomplete.
- Throws:
javax.xml.stream.XMLStreamException
-
handleDecEntityInCharacters
protected int handleDecEntityInCharacters(int ptr) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handleHexEntityInCharacters
protected int handleHexEntityInCharacters(int ptr) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handleAndAppendPending
private final boolean handleAndAppendPending() throws javax.xml.stream.XMLStreamExceptionMethod called to handle split multi-byte character, by decoding it and appending to the text buffer, if possible.- Returns:
- True, if split character was completely handled; false if not
- Throws:
javax.xml.stream.XMLStreamException
-
skipCharacters
protected boolean skipCharacters() throws javax.xml.stream.XMLStreamExceptionMethod that will be called to skip all possible characters from the input buffer, but without blocking. Partial characters are not to be handled (not pending input is to be added).- Specified by:
skipCharactersin classAsyncByteScanner- Returns:
- True, if skipping ending with an unexpanded entity; false if not
- Throws:
javax.xml.stream.XMLStreamException
-
skipPending
private final boolean skipPending() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
skipEntityInCharacters
private int skipEntityInCharacters() throws javax.xml.stream.XMLStreamExceptionMethod called to handle entity encountered inside CHARACTERS segment, when trying to complete a non-coalescing text segment.- Returns:
- Expanded (character) entity, if positive number; 0 if incomplete.
- Throws:
javax.xml.stream.XMLStreamException
-
skipCoalescedText
protected boolean skipCoalescedText() throws javax.xml.stream.XMLStreamExceptionCoalescing mode is (and will) not be implemented for non-blocking parsers, so this method should never get called.- Specified by:
skipCoalescedTextin classXmlScanner- Returns:
- True, if an unexpanded entity was encountered (and is now pending)
- Throws:
javax.xml.stream.XMLStreamException
-
handleAttrValue
protected boolean handleAttrValue() throws javax.xml.stream.XMLStreamException- Specified by:
handleAttrValuein classAsyncByteScanner- Returns:
- True, if the whole value was read; false if only part (due to buffer ending)
- Throws:
javax.xml.stream.XMLStreamException
-
handleAttrValuePending
private final boolean handleAttrValuePending() throws javax.xml.stream.XMLStreamException- Returns:
- True if the partial information was succesfully handled; false if not
- Throws:
javax.xml.stream.XMLStreamException
-
handleAttrValuePendingUTF8
private final int handleAttrValuePendingUTF8() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handleDecEntityInAttribute
private final int handleDecEntityInAttribute(boolean starting) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handleHexEntityInAttribute
private final int handleHexEntityInAttribute(boolean starting) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
handleEntityInAttributeValue
protected int handleEntityInAttributeValue() throws javax.xml.stream.XMLStreamExceptionMethod called to handle entity encountered inside attribute value.- Returns:
- Value of expanded character entity, if processed (which must be 1 or above); 0 for general entity, or -1 for "not enough input"
- Throws:
javax.xml.stream.XMLStreamException
-
handleNsDecl
protected boolean handleNsDecl() throws javax.xml.stream.XMLStreamException- Specified by:
handleNsDeclin classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
handleNsValuePending
private final boolean handleNsValuePending() throws javax.xml.stream.XMLStreamException- Returns:
- True if the partial information was succesfully handled; false if not
- Throws:
javax.xml.stream.XMLStreamException
-
parseNewName
protected final PName parseNewName(byte b) throws javax.xml.stream.XMLStreamException
- Specified by:
parseNewNamein classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
parsePName
protected final PName parsePName() throws javax.xml.stream.XMLStreamException
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.Some notes about assumption implementation makes:
- Well-formed xml content can not end with a name: as such, end-of-input is an error and we can throw an exception
- Specified by:
parsePNamein classAsyncByteScanner- Throws:
javax.xml.stream.XMLStreamException
-
parseNewEntityName
protected final PName parseNewEntityName(byte b) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
parseEntityName
protected final PName parseEntityName() throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
handlePartialCR
protected final boolean handlePartialCR()
Method called when there is a pending \r (from past buffer), and we need to see- Specified by:
handlePartialCRin classAsyncByteScanner- Returns:
- True if the linefeed was succesfully processed (had enough input data to do that); or false if there is no data available to check this
-
decodeUtf8_2
protected final int decodeUtf8_2(int c) throws javax.xml.stream.XMLStreamExceptionNote: caller must guarantee enough data is available before calling the method
- Throws:
javax.xml.stream.XMLStreamException
-
skipUtf8_2
protected final void skipUtf8_2(int c) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
decodeUtf8_3
protected final int decodeUtf8_3(int c1) throws javax.xml.stream.XMLStreamExceptionNote: caller must guarantee enough data is available before calling the method
- Throws:
javax.xml.stream.XMLStreamException
-
decodeUtf8_3
protected final int decodeUtf8_3(int c1, int c2, int c3) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
decodeUtf8_4
protected final int decodeUtf8_4(int c) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
decodeUtf8_4
protected final int decodeUtf8_4(int c1, int c2, int c3, int c4) throws javax.xml.stream.XMLStreamException- Returns:
- Character value minus 0x10000; this so that caller can readily expand it to actual surrogates
- Throws:
javax.xml.stream.XMLStreamException
-
-