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,DTDInfo,LocationInfo,TypedXMLStreamReader,Validatable,XMLStreamReader2
- Direct Known Subclasses:
ValidatingStreamReader
public class TypedStreamReader extends BasicStreamReader
Complete implementation ofXMLStreamReader2, including Typed Access API (Stax2 v3.0) implementation. Only functionality missing is DTD validation, which is provided by a specialized sub-class.
-
-
Field Summary
Fields Modifier and Type Field Description protected CharArrayBase64Decoder_base64DecoderLazily-constructed decoder object for decoding base64 encoded element binary content.protected ValueDecoderFactory_decoderFactoryFactory used for constructing decoders we need for typed accessprotected static intMASK_TYPED_ACCESS_ARRAYMask of event types that are legal (starting) states to call Typed Access API from.protected static intMASK_TYPED_ACCESS_BINARY-
Fields inherited from class com.ctc.wstx.sr.BasicStreamReader
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
-
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, mCachedEntities, mCfgNsEnabled, mCfgReplaceEntities, mCfgTreatCharRefsAsEntities, mConfig, mCurrDepth, mCurrEntity, mCurrName, mDocInputEncoding, mDocXmlEncoding, mDocXmlVersion, mEntityExpansionCount, mEntityResolver, mInput, mInputTopDepth, mNameBuffer, mNormalizeLFs, mRootInput, 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_AUTO_CLOSE_INPUT, CFG_CACHE_DTDS, CFG_CACHE_DTDS_BY_PUBLIC_ID, CFG_COALESCE_TEXT, CFG_INTERN_NAMES, CFG_INTERN_NS_URIS, 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
Constructors Modifier Constructor Description protectedTypedStreamReader(InputBootstrapper bs, BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputElementStack elemStack, boolean forER)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CharArrayBase64Decoder_base64Decoder()protected TypedXMLStreamException_constructTypeException(IllegalArgumentException iae, String lexicalValue)Method called to wrap or convert given conversion-fail exception into a fullTypedXMLStreamException,protected ValueDecoderFactory_decoderFactory()protected QName_verifyQName(QName n)Method called to verify validity of the parsed QName element or attribute value.static TypedStreamReadercreateStreamReader(BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputBootstrapper bs, boolean forER)Factory method for constructing readers.voidgetAttributeAs(int index, TypedValueDecoder tvd)Generic access method that can be used for efficient decoding of additional types not support natively by the typed stream reader.intgetAttributeAsArray(int index, 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)Read an attribute value as a byte array.byte[]getAttributeAsBinary(int index, Base64Variant v)booleangetAttributeAsBoolean(int index)Read an attribute value as a boolean.BigDecimalgetAttributeAsDecimal(int index)doublegetAttributeAsDouble(int index)double[]getAttributeAsDoubleArray(int index)floatgetAttributeAsFloat(int index)float[]getAttributeAsFloatArray(int index)intgetAttributeAsInt(int index)Read an attribute value as a boolean.int[]getAttributeAsIntArray(int index)Read an attribute content as an int array.BigIntegergetAttributeAsInteger(int index)longgetAttributeAsLong(int index)Read an attribute value as a boolean.long[]getAttributeAsLongArray(int index)QNamegetAttributeAsQName(int index)intgetAttributeIndex(String namespaceURI, String localName)Returns the index of the attribute whose local name islocalNameand URI isnamespaceURIor-1if no such attribute exists.voidgetElementAs(TypedValueDecoder tvd)Generic decoding method that can be used for efficient decoding of additional types not support natively by the typed stream reader.byte[]getElementAsBinary()Convenience method that can be used similar to read binary content instead ofTypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant), in cases where neither performance nor memory usage is a big concern.byte[]getElementAsBinary(Base64Variant v)Convenience method that can be used similar to read binary content instead ofTypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant), in cases where neither performance nor memory usage is a big concern.booleangetElementAsBoolean()Read an element content as a boolean.BigDecimalgetElementAsDecimal()doublegetElementAsDouble()Read an element content as a 64-bit floating point value.floatgetElementAsFloat()Read an element content as a 32-bit floating point value.intgetElementAsInt()Read an element content as a 32-bit integer.BigIntegergetElementAsInteger()longgetElementAsLong()Read an element content as a 64-bit integer.QNamegetElementAsQName()intreadElementAsArray(TypedArrayDecoder dec)Method called to parse array of primitives.intreadElementAsBinary(byte[] resultBuffer, int offset, int maxLength)intreadElementAsBinary(byte[] resultBuffer, int offset, int maxLength, Base64Variant v)Read element content as decoded byte sequence; possibly only reading a fragment of all element content.intreadElementAsDoubleArray(double[] value, int from, int length)intreadElementAsFloatArray(float[] value, int from, int length)intreadElementAsIntArray(int[] value, int from, int length)Read an element content as an int array.intreadElementAsLongArray(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, 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 Detail
-
MASK_TYPED_ACCESS_ARRAY
protected static final int MASK_TYPED_ACCESS_ARRAY
Mask of event types that are legal (starting) states to call Typed Access API from.- See Also:
- Constant Field Values
-
MASK_TYPED_ACCESS_BINARY
protected static final int MASK_TYPED_ACCESS_BINARY
- See Also:
- Constant Field Values
-
_decoderFactory
protected ValueDecoderFactory _decoderFactory
Factory used for constructing decoders we need for typed access
-
_base64Decoder
protected CharArrayBase64Decoder _base64Decoder
Lazily-constructed decoder object for decoding base64 encoded element binary content.
-
-
Constructor Detail
-
TypedStreamReader
protected TypedStreamReader(InputBootstrapper bs, BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputElementStack elemStack, boolean forER) throws XMLStreamException
- Throws:
XMLStreamException
-
-
Method Detail
-
createStreamReader
public static TypedStreamReader createStreamReader(BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputBootstrapper bs, boolean forER) throws XMLStreamException
Factory method for constructing readers.- Parameters:
owner- "Owner" of this reader, factory that created the reader; needed for returning updated symbol table information after parsing.input- Input source used to read the XML document.cfg- Object that contains reader configuration info.- Throws:
XMLStreamException
-
getElementAsBoolean
public boolean getElementAsBoolean() throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an element content as a boolean. The lexical representation of a boolean is defined by the XML Schema boolean data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema boolean data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema boolean data type. (note: allowed lexical values are canonicals "true" and "false", as well as non-canonical "0" and "1")
These are the pre- and post-conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getElementAsInt
public int getElementAsInt() throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an element content as a 32-bit integer. The lexical representation of a integer is defined by the XML Schema integer data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema integer data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
These are the pre and post conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into a Java (32-bit) integer.
-
getElementAsLong
public long getElementAsLong() throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an element content as a 64-bit integer. The lexical representation of a integer is defined by the XML Schema integer data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema integer data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
These are the pre and post conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into a Java (64-bit) integer.
-
getElementAsFloat
public float getElementAsFloat() throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an element content as a 32-bit floating point value. The lexical representation is defined by the XML Schema float data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema float data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
Note that valid representations include basic Java textual representations, as well as 3 special tokens: "INF", "-INF" and "NaN"These are the pre and post conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into a Java float
-
getElementAsDouble
public double getElementAsDouble() throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an element content as a 64-bit floating point value. The lexical representation is defined by the XML Schema double data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema double data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
Note that valid representations include basic Java textual representations, as well as 3 special tokens: "INF", "-INF" and "NaN"These are the pre and post conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into a Java double
-
getElementAsInteger
public BigInteger getElementAsInteger() throws XMLStreamException
- Throws:
XMLStreamException
-
getElementAsDecimal
public BigDecimal getElementAsDecimal() throws XMLStreamException
- Throws:
XMLStreamException
-
getElementAsQName
public QName getElementAsQName() throws XMLStreamException
- Throws:
XMLStreamException
-
getElementAsBinary
public final byte[] getElementAsBinary() throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderConvenience method that can be used similar to read binary content instead ofTypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant), in cases where neither performance nor memory usage is a big concern.Note: base64 variant defaults to
Base64Variants.MIME.
-
getElementAsBinary
public byte[] getElementAsBinary(Base64Variant v) throws XMLStreamException
Description copied from interface:TypedXMLStreamReaderConvenience method that can be used similar to read binary content instead ofTypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant), in cases where neither performance nor memory usage is a big concern.- Parameters:
v- Base64 variant content is in; needed to decode alternative variants ("modified base64")- Throws:
XMLStreamException- See Also:
TypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
-
getElementAs
public void getElementAs(TypedValueDecoder tvd) throws XMLStreamException
Description copied from interface:TypedXMLStreamReaderGeneric decoding method that can be used for efficient decoding of additional types not support natively by the typed stream reader. When method is called, stream reader will collect all textual content of the current element (effectively doing something similar to a call toXMLStreamReader.getElementText(), and then call one of decode methods defined inTypedValueDecoder. The only difference is that passed value will be trimmed: that is, any leading or trailing white space will be removed prior to calling decode method. After the call, passed decoder object will have decoded and stored value (if succesful) or thrown an exception (if not).The main benefit of using this method (over just getting all content by calling
XMLStreamReader.getElementText()is efficiency: the stream reader can efficiently gather all textual content necessary and pass it to the decoder, often avoiding construction of intemediate Strings.These are the pre- and post-conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
Note that caller has to know more specific type of decoder, since the base interface does not specify methods for accessing actual decoded value.
- Throws:
XMLStreamException
-
readElementAsIntArray
public int readElementAsIntArray(int[] value, int from, int length) throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an element content as an int array. The lexical representation of a int array is defined by the following XML schema type:<xs:simpleType name="intArray"> <xs:list itemType="xs:int"/> </xs:simpleType>whose lexical space is a list of space-separated ints. Whitespace MUST be collapsed according to the whiteSpace facet for theintArraytype shown above. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by theintArraydata type.These are the pre and post conditions of calling this method:
- Precondition: the current event is either START_ELEMENT, or a textual event (CHARACTERS, CDATA), or END_ELEMENT (END_ELEMENT is allowed for convenience; if so, no read operation is tried, and -1 is returned immediately
- Postcondition: the current event is the corresponding END_ELEMENT or CHARACTERS if only a portion of the array has been copied thus far.
- Parameters:
value- The array in which to copy the ints.from- The index in the array from which copying starts.length- The maximun number of ints to copy. Minimum value is 1; others anIllegalArgumentExceptionis thrown- Returns:
- The number of ints actually copied which must
be less or equal than
length, but at least one if any ints found. If not, -1 is returned to signal end of ints to parse. - Throws:
XMLStreamException
-
readElementAsLongArray
public int readElementAsLongArray(long[] value, int from, int length) throws XMLStreamException- Throws:
XMLStreamException
-
readElementAsFloatArray
public int readElementAsFloatArray(float[] value, int from, int length) throws XMLStreamException- Throws:
XMLStreamException
-
readElementAsDoubleArray
public int readElementAsDoubleArray(double[] value, int from, int length) throws XMLStreamException- Throws:
XMLStreamException
-
readElementAsArray
public final int readElementAsArray(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, Base64Variant v) throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead element content as decoded byte sequence; possibly only reading a fragment of all element content. The lexical representation of a byte array is defined by the XML Schema base64Binary data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema base64Binary data type. An exception is thrown if content is not in the lexical space defined by the XML Schema base64Binary data type.Each call will read at least one decoded byte (and no more than the specified maximum length), if there is any content remaining. If none is available and END_ELEMENT is encountered, -1 is returned.
These are the pre and post conditions of calling this method:
- Precondition: the current event is either START_ELEMENT, or a textual event (CHARACTERS, CDATA), or END_ELEMENT (END_ELEMENT is allowed for convenience; if so, no read operation is tried, and -1 is returned immediately
- Postcondition: the current event is the corresponding END_ELEMENT, if all remaining binary content was read, or CHARACTERS if only a portion of the array was read
Additionally, caller MUST start decoding at START_ELEMENT; if the first decode calls is at CHARACTERS or CDATA event, results are not defined: result may be an exception, or invalid data being returned. Implementations are encouraged to throw an exception if possible, to make it easier to figure out the problem.
This method can be called multiple times until the cursor is positioned at the corresponding END_ELEMENT event. Stated differently, after the method is called for the first time, the cursor will move and remain in the CHARACTERS position while there are potentially more bytes available for reading.
- Parameters:
resultBuffer- Array in which to copy decoded bytes.offset- Starting offset of the first decoded byte within result buffermaxLength- Maximum number of bytes to decode with this call- Returns:
- The number of bytes actually decoded and returned,
if any were available; -1 if there is no more content.
If any content was copied, value must be less or equal than
maxLengthNote that this value is not guaranteed to equalmaxLengtheven if enough content was available; that is, implementations can return shorter sections if they choose to, down to and including returning zero (0) if it was not possible to decode a full base64 triplet (3 output bytes from 4 input characters). - Throws:
XMLStreamException
-
getAttributeIndex
public int getAttributeIndex(String namespaceURI, String localName)
Description copied from interface:TypedXMLStreamReaderReturns the index of the attribute whose local name islocalNameand URI isnamespaceURIor-1if no such attribute exists.- Parameters:
namespaceURI- The attribute's namespace URI. Values of null and "" are considered the same, i.e. "no namespace" (or "empty" namespace)localName- The attribute's local name.- Returns:
- The attribute's index or
-1if no such attribute exists.
-
getAttributeAsBoolean
public boolean getAttributeAsBoolean(int index) throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an attribute value as a boolean. The lexical representation of a boolean is defined by the XML Schema boolean data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema boolean data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema boolean data type.
- Parameters:
index- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String)- Throws:
XMLStreamException- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsInt
public int getAttributeAsInt(int index) throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an attribute value as a boolean. The lexical representation of a boolean is defined by the XML Schema integer data type. Whitespace MUST be collapsed according to the whiteSpace facet for the type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
- Parameters:
index- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String)- Throws:
XMLStreamException- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsLong
public long getAttributeAsLong(int index) throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an attribute value as a boolean. The lexical representation of a boolean is defined by the XML Schema long data type. Whitespace MUST be collapsed according to the whiteSpace facet for the type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema long data type.
- Parameters:
index- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String)- Throws:
XMLStreamException- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsFloat
public float getAttributeAsFloat(int index) throws XMLStreamException- Throws:
XMLStreamException
-
getAttributeAsDouble
public double getAttributeAsDouble(int index) throws XMLStreamException- Throws:
XMLStreamException
-
getAttributeAsInteger
public BigInteger getAttributeAsInteger(int index) throws XMLStreamException
- Throws:
XMLStreamException
-
getAttributeAsDecimal
public BigDecimal getAttributeAsDecimal(int index) throws XMLStreamException
- Throws:
XMLStreamException
-
getAttributeAsQName
public QName getAttributeAsQName(int index) throws XMLStreamException
- Throws:
XMLStreamException
-
getAttributeAs
public void getAttributeAs(int index, TypedValueDecoder tvd) throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderGeneric access method that can be used for efficient decoding of additional types not support natively by the typed stream reader. The main benefit of using this method is that the stream reader can efficient gather all textual content necessary and pass it to the decoder, often avoiding construction of intemediate Strings.As with
TypedXMLStreamReader.getElementAs(org.codehaus.stax2.typed.TypedValueDecoder), value passed to a decode method will be trimmed of any leading or trailing white space.- Throws:
XMLStreamException
-
getAttributeAsIntArray
public int[] getAttributeAsIntArray(int index) throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an attribute content as an int array. The lexical representation of a int array is defined by the following XML schema type:
<xs:simpleType name="intArray"> <xs:list itemType="xs:int"/> </xs:simpleType>whose lexical space is a list of space-separated ints. Whitespace MUST be collapsed according to the whiteSpace facet for theintArraytype shown above. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by theintArraydata type.- Parameters:
index- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String).- Returns:
- An array of ints with the content.
- Throws:
XMLStreamException- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsLongArray
public long[] getAttributeAsLongArray(int index) throws XMLStreamException- Throws:
XMLStreamException
-
getAttributeAsFloatArray
public float[] getAttributeAsFloatArray(int index) throws XMLStreamException- Throws:
XMLStreamException
-
getAttributeAsDoubleArray
public double[] getAttributeAsDoubleArray(int index) throws XMLStreamException- Throws:
XMLStreamException
-
getAttributeAsArray
public int getAttributeAsArray(int index, TypedArrayDecoder tad) throws XMLStreamExceptionMethod 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
public byte[] getAttributeAsBinary(int index) throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderRead an attribute value as a byte array. The lexical representation of a byte array is defined by the XML Schema base64Binary data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema base64Binary data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema base64Binary data type.- Parameters:
index- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String).- Returns:
- An array of bytes with the content.
- Throws:
XMLStreamException- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsBinary
public byte[] getAttributeAsBinary(int index, Base64Variant v) throws XMLStreamException- Throws:
XMLStreamException
-
_verifyQName
protected QName _verifyQName(QName n) throws TypedXMLStreamException
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:
TypedXMLStreamException
-
_decoderFactory
protected ValueDecoderFactory _decoderFactory()
-
_base64Decoder
protected CharArrayBase64Decoder _base64Decoder()
-
_constructTypeException
protected 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.
-
-