Package com.ctc.wstx.sr
Class TypedStreamReader
java.lang.Object
com.ctc.wstx.io.WstxInputData
com.ctc.wstx.sr.StreamScanner
com.ctc.wstx.sr.BasicStreamReader
com.ctc.wstx.sr.TypedStreamReader
- All Implemented Interfaces:
InputConfigFlags
,ParsingErrorMsgs
,InputProblemReporter
,StreamReaderImpl
,XMLStreamConstants
,XMLStreamReader
,org.codehaus.stax2.DTDInfo
,org.codehaus.stax2.LocationInfo
,org.codehaus.stax2.typed.TypedXMLStreamReader
,org.codehaus.stax2.validation.Validatable
,org.codehaus.stax2.XMLStreamReader2
- Direct Known Subclasses:
ValidatingStreamReader
Complete implementation of
XMLStreamReader2
,
including Typed Access API (Stax2 v3.0) implementation.
Only functionality missing is DTD validation, which is provided by a
specialized sub-class.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.codehaus.stax2.ri.typed.CharArrayBase64Decoder
Lazily-constructed decoder object for decoding base64 encoded element binary content.protected org.codehaus.stax2.ri.typed.ValueDecoderFactory
Factory used for constructing decoders we need for typed accessprotected static final int
Mask of event types that are legal (starting) states to call Typed Access API from.protected static final int
(package private) static final int
Minimum length of text chunks to parse before base64 decoding.Fields inherited from class com.ctc.wstx.sr.BasicStreamReader
ALL_WS_NO, ALL_WS_UNKNOWN, ALL_WS_YES, DOC_STANDALONE_NO, DOC_STANDALONE_UNKNOWN, DOC_STANDALONE_YES, MASK_GET_ELEMENT_TEXT, MASK_GET_TEXT, MASK_GET_TEXT_WITH_WRITER, MASK_GET_TEXT_XXX, mAttrCollector, mCfgCoalesceText, mCfgLazyParsing, mCfgReportTextAsChars, mCheckIndentation, mConfigFlags, mCurrTextLength, mCurrToken, mDocStandalone, mDtdPublicId, mDtdSystemId, mElementStack, mGeneralEntities, mOwner, mParseState, mPendingException, mReturnNullForDefaultNamespace, mRootLName, mRootPrefix, mSecondaryToken, mShortestTextSegment, mStDoctypeFound, mStEmptyElem, mStTextThreshold, mTextBuffer, mTokenState, mValidateText, mVldContent, mWsStatus, sPrefixXml, sPrefixXmlns, STATE_CLOSED, STATE_EPILOG, STATE_MULTIDOC_HACK, STATE_PROLOG, STATE_TREE, TOKEN_FULL_COALESCED, TOKEN_FULL_SINGLE, TOKEN_NOT_STARTED, TOKEN_PARTIAL_SINGLE, TOKEN_STARTED
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, mAllowXml11EscapedCharsInXml10, mCachedEntities, mCfgNsEnabled, mCfgReplaceEntities, mCfgTreatCharRefsAsEntities, mConfig, mCurrDepth, mCurrEntity, mCurrName, mDocInputEncoding, mDocXmlEncoding, mDocXmlVersion, mEntityExpansionCount, mEntityResolver, mInput, mInputTopDepth, mNameBuffer, mNormalizeLFs, mRootInput, mSymbols, 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, mInputEnd, mInputPtr, mXml11
Fields inherited from interface com.ctc.wstx.cfg.InputConfigFlags
CFG_ALLOW_XML11_ESCAPED_CHARS_IN_XML10, CFG_AUTO_CLOSE_INPUT, CFG_CACHE_DTDS, CFG_CACHE_DTDS_BY_PUBLIC_ID, CFG_COALESCE_TEXT, CFG_INTERN_NAMES, CFG_INTERN_NS_URIS, CFG_JAXP_FEATURE_SECURE_PROCESSING, CFG_LAZY_PARSING, CFG_NAMESPACE_AWARE, CFG_NORMALIZE_LFS, CFG_PRESERVE_LOCATION, CFG_REPLACE_ENTITY_REFS, CFG_REPORT_CDATA, CFG_REPORT_PROLOG_WS, CFG_SUPPORT_DTD, CFG_SUPPORT_DTDPP, CFG_SUPPORT_EXTERNAL_ENTITIES, CFG_TREAT_CHAR_REFS_AS_ENTS, CFG_VALIDATE_AGAINST_DTD, CFG_XMLID_TYPING, CFG_XMLID_UNIQ_CHECKS
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
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 org.codehaus.stax2.XMLStreamReader2
FEATURE_DTD_OVERRIDE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TypedStreamReader
(InputBootstrapper bs, BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputElementStack elemStack, boolean forER) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.codehaus.stax2.ri.typed.CharArrayBase64Decoder
protected org.codehaus.stax2.typed.TypedXMLStreamException
_constructTypeException
(IllegalArgumentException iae, String lexicalValue) Method called to wrap or convert given conversion-fail exception into a fullTypedXMLStreamException
,protected org.codehaus.stax2.ri.typed.ValueDecoderFactory
private void
_handleEmptyValue
(org.codehaus.stax2.typed.TypedValueDecoder dec) Method called to handle value that has empty String as representation.private final void
_initBinaryChunks
(org.codehaus.stax2.typed.Base64Variant v, org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec, int type, boolean isFirst) protected QName
Method called to verify validity of the parsed QName element or attribute value.static TypedStreamReader
createStreamReader
(BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputBootstrapper bs, boolean forER) Factory method for constructing readers.void
getAttributeAs
(int index, org.codehaus.stax2.typed.TypedValueDecoder tvd) int
getAttributeAsArray
(int index, org.codehaus.stax2.typed.TypedArrayDecoder tad) Method that allows reading contents of an attribute as an array of whitespace-separate tokens, decoded using specified decoder.byte[]
getAttributeAsBinary
(int index) byte[]
getAttributeAsBinary
(int index, org.codehaus.stax2.typed.Base64Variant v) boolean
getAttributeAsBoolean
(int index) getAttributeAsDecimal
(int index) double
getAttributeAsDouble
(int index) double[]
getAttributeAsDoubleArray
(int index) float
getAttributeAsFloat
(int index) float[]
getAttributeAsFloatArray
(int index) int
getAttributeAsInt
(int index) int[]
getAttributeAsIntArray
(int index) getAttributeAsInteger
(int index) long
getAttributeAsLong
(int index) long[]
getAttributeAsLongArray
(int index) getAttributeAsQName
(int index) int
getAttributeIndex
(String namespaceURI, String localName) void
getElementAs
(org.codehaus.stax2.typed.TypedValueDecoder tvd) final byte[]
byte[]
getElementAsBinary
(org.codehaus.stax2.typed.Base64Variant v) boolean
double
float
int
long
final int
readElementAsArray
(org.codehaus.stax2.typed.TypedArrayDecoder dec) Method called to parse array of primitives.final int
readElementAsBinary
(byte[] resultBuffer, int offset, int maxLength) int
readElementAsBinary
(byte[] resultBuffer, int offset, int maxLength, org.codehaus.stax2.typed.Base64Variant v) int
readElementAsDoubleArray
(double[] value, int from, int length) int
readElementAsFloatArray
(float[] value, int from, int length) int
readElementAsIntArray
(int[] value, int from, int length) int
readElementAsLongArray
(long[] value, int from, int length) Methods inherited from class com.ctc.wstx.sr.BasicStreamReader
_constructTypeException, _constructUnexpectedInTyped, checkCData, checkKeyword, close, closeCompletely, createElementStack, ensureFinishToken, findEntity, finishDTD, finishToken, fireSaxCharacterEvents, fireSaxCommentEvent, fireSaxEndElement, fireSaxPIEvent, fireSaxSpaceEvents, fireSaxStartElement, getAttributeCollector, getAttributeCount, getAttributeInfo, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getCurrentEntityDecl, getDepth, getDTDInfo, getDTDInternalSubset, getDTDPublicId, getDTDRootName, getDTDSystemId, getElementText, getEncoding, getEndingByteOffset, getEndingCharOffset, getEndLocation, getEventType, getFeature, getInputElementStack, getLocalName, getLocation, getLocationInfo, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getNonTransientNamespaceContext, getPIData, getPITarget, getPrefix, getPrefixedName, getProcessedDTD, getProcessedDTDSchema, getProperty, getStartingByteOffset, getStartingCharOffset, getText, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, handleEOF, handleGreedyEntityProblem, handleIncompleteEntityProblem, handleMultiDocStart, handleMultiDocXmlDecl, handleRootElem, handleUndeclaredEntity, hasConfigFlags, hasName, hasNext, hasText, initValidation, isAttributeSpecified, isCharacters, isEmptyElement, isEndElement, isNamespaceAware, isPropertySupported, isStandalone, isStartElement, isWhiteSpace, next, nextTag, parseQuoted, readCDataSecondary, readCoalescedText, readEndElem, readTextSecondary, reportInvalidContent, require, safeEnsureFinishToken, safeFinishToken, setFeature, setProperty, setValidationProblemHandler, skipElement, skipEquals, skipWS, standaloneSet, stopValidatingAgainst, stopValidatingAgainst, throwNotTextualOrElem, throwUnexpectedEOF, validateAgainst, withStartElement
Methods inherited from class com.ctc.wstx.sr.StreamScanner
_reportProblem, _reportProblem, closeAllInput, constructFromIOE, constructLimitViolation, constructNullCharException, constructWfcException, ensureInput, expandBy50Pct, expandEntity, fullyResolveEntity, getConfig, getCurrentInput, getCurrentLocation, getIntEntity, getLastCharLocation, getNameBuffer, getNext, getNextAfterWS, getNextChar, 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, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, resolveCharOnlyEntity, resolveNonCharEntity, resolveSimpleEntity, skipCRLF, skipFullName, throwFromIOE, throwFromStrE, throwInvalidSpace, throwInvalidSpace, throwLazyError, throwNullChar, throwNullParent, throwParseError, throwParseError, throwUnexpectedChar, throwUnexpectedEOB, throwUnexpectedEOF, throwWfcException, tokenTypeDesc, verifyLimit
Methods inherited from class com.ctc.wstx.io.WstxInputData
copyBufferStateFrom, findIllegalNameChar, findIllegalNmtokenChar, getCharDesc, isNameChar, isNameChar, isNameStartChar, isNameStartChar, 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 Details
-
MASK_TYPED_ACCESS_ARRAY
protected static final int MASK_TYPED_ACCESS_ARRAYMask of event types that are legal (starting) states to call Typed Access API from.- See Also:
-
MASK_TYPED_ACCESS_BINARY
protected static final int MASK_TYPED_ACCESS_BINARY- See Also:
-
MIN_BINARY_CHUNK
static final int MIN_BINARY_CHUNKMinimum length of text chunks to parse before base64 decoding. Will try to limit it to fit within regular result buffers.- See Also:
-
_decoderFactory
protected org.codehaus.stax2.ri.typed.ValueDecoderFactory _decoderFactoryFactory used for constructing decoders we need for typed access -
_base64Decoder
protected org.codehaus.stax2.ri.typed.CharArrayBase64Decoder _base64DecoderLazily-constructed decoder object for decoding base64 encoded element binary content.
-
-
Constructor Details
-
TypedStreamReader
protected TypedStreamReader(InputBootstrapper bs, BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputElementStack elemStack, boolean forER) throws XMLStreamException - Throws:
XMLStreamException
-
-
Method Details
-
createStreamReader
public static TypedStreamReader createStreamReader(BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputBootstrapper bs, boolean forER) throws XMLStreamException Factory method for constructing readers.- Parameters:
input
- Input source used to read the XML document.owner
- "Owner" of this reader, factory that created the reader; needed for returning updated symbol table information after parsing.cfg
- Object that contains reader configuration info.- Throws:
XMLStreamException
-
getElementAsBoolean
- Throws:
XMLStreamException
-
getElementAsInt
- Throws:
XMLStreamException
-
getElementAsLong
- Throws:
XMLStreamException
-
getElementAsFloat
- Throws:
XMLStreamException
-
getElementAsDouble
- Throws:
XMLStreamException
-
getElementAsInteger
- Throws:
XMLStreamException
-
getElementAsDecimal
- Throws:
XMLStreamException
-
getElementAsQName
- Throws:
XMLStreamException
-
getElementAsBinary
- Throws:
XMLStreamException
-
getElementAsBinary
public byte[] getElementAsBinary(org.codehaus.stax2.typed.Base64Variant v) throws XMLStreamException - Throws:
XMLStreamException
-
getElementAs
- Throws:
XMLStreamException
-
readElementAsIntArray
- Throws:
XMLStreamException
-
readElementAsLongArray
- Throws:
XMLStreamException
-
readElementAsFloatArray
- Throws:
XMLStreamException
-
readElementAsDoubleArray
- Throws:
XMLStreamException
-
readElementAsArray
public final int readElementAsArray(org.codehaus.stax2.typed.TypedArrayDecoder dec) throws XMLStreamException Method called to parse array of primitives.!!! 05-Sep-2008, tatu: Current implementation is not optimal either performance-wise, or from getting accurate Location for decoding problems. But it works otherwise, and we need to get Woodstox 4.0 out by the end of the year... so it'll do, for now.
- Returns:
- Number of elements decoded (if any were decoded), or -1 to indicate that no more values can be decoded.
- Throws:
XMLStreamException
-
readElementAsBinary
public final int readElementAsBinary(byte[] resultBuffer, int offset, int maxLength) throws XMLStreamException - Throws:
XMLStreamException
-
readElementAsBinary
public int readElementAsBinary(byte[] resultBuffer, int offset, int maxLength, org.codehaus.stax2.typed.Base64Variant v) throws XMLStreamException - Throws:
XMLStreamException
-
_initBinaryChunks
private final void _initBinaryChunks(org.codehaus.stax2.typed.Base64Variant v, org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec, int type, boolean isFirst) throws XMLStreamException - Throws:
XMLStreamException
-
getAttributeIndex
-
getAttributeAsBoolean
- Throws:
XMLStreamException
-
getAttributeAsInt
- Throws:
XMLStreamException
-
getAttributeAsLong
- Throws:
XMLStreamException
-
getAttributeAsFloat
- Throws:
XMLStreamException
-
getAttributeAsDouble
- Throws:
XMLStreamException
-
getAttributeAsInteger
- Throws:
XMLStreamException
-
getAttributeAsDecimal
- Throws:
XMLStreamException
-
getAttributeAsQName
- Throws:
XMLStreamException
-
getAttributeAs
public void getAttributeAs(int index, org.codehaus.stax2.typed.TypedValueDecoder tvd) throws XMLStreamException - Throws:
XMLStreamException
-
getAttributeAsIntArray
- Throws:
XMLStreamException
-
getAttributeAsLongArray
- Throws:
XMLStreamException
-
getAttributeAsFloatArray
- Throws:
XMLStreamException
-
getAttributeAsDoubleArray
- Throws:
XMLStreamException
-
getAttributeAsArray
public int getAttributeAsArray(int index, org.codehaus.stax2.typed.TypedArrayDecoder tad) throws XMLStreamException Method that allows reading contents of an attribute as an array of whitespace-separate tokens, decoded using specified decoder.- Returns:
- Number of tokens decoded, 0 if none found
- Throws:
XMLStreamException
-
getAttributeAsBinary
- Throws:
XMLStreamException
-
getAttributeAsBinary
public byte[] getAttributeAsBinary(int index, org.codehaus.stax2.typed.Base64Variant v) throws XMLStreamException - Throws:
XMLStreamException
-
_verifyQName
Method called to verify validity of the parsed QName element or attribute value. At this point binding of a prefixed name (if qname has a prefix) has been verified, and thereby prefix also must be valid (since there must have been a preceding declaration). But local name might still not be a legal well-formed xml name, so let's verify that.- Throws:
org.codehaus.stax2.typed.TypedXMLStreamException
-
_decoderFactory
protected org.codehaus.stax2.ri.typed.ValueDecoderFactory _decoderFactory() -
_base64Decoder
protected org.codehaus.stax2.ri.typed.CharArrayBase64Decoder _base64Decoder() -
_handleEmptyValue
private void _handleEmptyValue(org.codehaus.stax2.typed.TypedValueDecoder dec) throws XMLStreamException Method called to handle value that has empty String as representation. This will usually either lead to an exception, or parsing to the default value for the type in question (null for nullable types and so on).- Throws:
XMLStreamException
-
_constructTypeException
protected org.codehaus.stax2.typed.TypedXMLStreamException _constructTypeException(IllegalArgumentException iae, String lexicalValue) Method called to wrap or convert given conversion-fail exception into a fullTypedXMLStreamException
,- Parameters:
iae
- Problem as reported by converterlexicalValue
- Lexical value (element content, attribute value) that could not be converted succesfully.
-