Class StreamReader2Delegate
- java.lang.Object
-
- javax.xml.stream.util.StreamReaderDelegate
-
- org.codehaus.stax2.util.StreamReader2Delegate
-
- All Implemented Interfaces:
XMLStreamConstants,XMLStreamReader,TypedXMLStreamReader,Validatable,XMLStreamReader2
- Direct Known Subclasses:
Stax2FilteredStreamReader
public class StreamReader2Delegate extends StreamReaderDelegate implements XMLStreamReader2
-
-
Field Summary
Fields Modifier and Type Field Description protected XMLStreamReader2_delegate2-
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 Constructor Description StreamReader2Delegate(XMLStreamReader2 sr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseCompletely()Method similar toXMLStreamReader.close(), except that this method also does close the underlying input source if it has not yet been closed.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.AttributeInfogetAttributeInfo()Method that can be called to get additional information about attributes related to the current start element, as well as related DTD-based information if available.intgetDepth()Method that returns the number of open elements in the stack; 0 when the reader is in prolog/epilog, 1 inside root element (including when pointing at the root element itself) and so on.DTDInfogetDTDInfo()Method that can be called to get information about DOCTYPE declaration that the reader is currently pointing to, if the reader has parsed it.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()ObjectgetFeature(String name)Method that can be used to get per-reader values; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.LocationInfogetLocationInfo()NamespaceContextgetNonTransientNamespaceContext()This method returns a namespace context object that contains information identical to that returned byXMLStreamReader.getNamespaceContext(), but one that is not transient.StringgetPrefixedName()This method returns "prefix-qualified" name of the current element.intgetText(Writer w, boolean preserveContents)Method similar toXMLStreamReader.getText(), except that it just uses provided Writer to write all textual content, and that it works for wider range of event types.booleanisEmptyElement()Method that can be used to check whether current START_ELEMENT event was created for an empty element (xml short-hand notation where one tag implies start and end, ending with "/>"), or not.booleanisPropertySupported(String name)Method similar toXMLInputFactory.isPropertySupported(java.lang.String), used to determine whether a property is supported by the Reader instance.intreadElementAsArray(TypedArrayDecoder tad)Read an element content as an array of tokens.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)voidsetFeature(String name, Object value)Method that can be used to set per-reader features such as configuration settings; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.voidsetParent(XMLStreamReader pr)booleansetProperty(String name, Object value)Method that can be used to set per-reader properties; a subset of properties one can set via matchingXMLInputFactory2instance.ValidationProblemHandlersetValidationProblemHandler(ValidationProblemHandler h)Method that application can call to define a custom handler for validation problems encountered during validation process.voidskipElement()Method that will skip all the contents of the element that the stream currently points to.XMLValidatorstopValidatingAgainst(XMLValidationSchema schema)Method that can be called by application to stop validating output against a schema, for whichValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)was called earlier.XMLValidatorstopValidatingAgainst(XMLValidator validator)Method that can be called by application to stop validating output using specified validator.XMLValidatorvalidateAgainst(XMLValidationSchema schema)Method that will construct aXMLValidatorinstance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call toValidatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema).-
Methods inherited from class javax.xml.stream.util.StreamReaderDelegate
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getParent, getPIData, getPITarget, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, next, nextTag, require, standaloneSet
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.xml.stream.XMLStreamReader
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getPIData, getPITarget, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, next, nextTag, require, standaloneSet
-
-
-
-
Field Detail
-
_delegate2
protected XMLStreamReader2 _delegate2
-
-
Constructor Detail
-
StreamReader2Delegate
public StreamReader2Delegate(XMLStreamReader2 sr)
-
-
Method Detail
-
setParent
public void setParent(XMLStreamReader pr)
- Overrides:
setParentin classStreamReaderDelegate
-
closeCompletely
public void closeCompletely() throws XMLStreamExceptionDescription copied from interface:XMLStreamReader2Method similar toXMLStreamReader.close(), except that this method also does close the underlying input source if it has not yet been closed. It is generally preferable to call this method if the parsing ends in an exception; and for some input sources (when passing aFileorURLfor factory method) it has to be called as the application does not have access to the actually input source (InputStreamopened from aURLand so on).- Specified by:
closeCompletelyin interfaceXMLStreamReader2- Throws:
XMLStreamException
-
getAttributeInfo
public AttributeInfo getAttributeInfo() throws XMLStreamException
Description copied from interface:XMLStreamReader2Method that can be called to get additional information about attributes related to the current start element, as well as related DTD-based information if available. Note that the reader has to currently point to START_ELEMENT; if not, aIllegalStateExceptionwill be thrown.- Specified by:
getAttributeInfoin interfaceXMLStreamReader2- Throws:
XMLStreamException
-
getDTDInfo
public DTDInfo getDTDInfo() throws XMLStreamException
Description copied from interface:XMLStreamReader2Method that can be called to get information about DOCTYPE declaration that the reader is currently pointing to, if the reader has parsed it. Implementations can also choose to return null to indicate they do not provide extra information; but they should not throw any exceptions beyond normal parsing exceptions.- Specified by:
getDTDInfoin interfaceXMLStreamReader2- Returns:
- Information object for accessing further DOCTYPE information, iff the reader currently points to DTD event, AND is operating in mode that parses such information (DTD-aware at least, and usually also validating)
- Throws:
XMLStreamException
-
getDepth
public int getDepth()
Description copied from interface:XMLStreamReader2Method that returns the number of open elements in the stack; 0 when the reader is in prolog/epilog, 1 inside root element (including when pointing at the root element itself) and so on. Depth is same for matching start/end elements, as well as for the all children of an element.- Specified by:
getDepthin interfaceXMLStreamReader2- Returns:
- Number of open elements currently in the reader's stack, including current START_ELEMENT or END_ELEMENT (if pointing to one).
-
getFeature
public Object getFeature(String name)
Description copied from interface:XMLStreamReader2Method that can be used to get per-reader values; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.Note: although some feature names are shared with
XMLStreamReader2.setFeature(java.lang.String, java.lang.Object), not all are: some features are read-only, some write-only- Specified by:
getFeaturein interfaceXMLStreamReader2- Parameters:
name- Name of the feature of which value to get- Returns:
- Value of the feature (possibly null), if supported; null otherwise
-
getLocationInfo
public LocationInfo getLocationInfo()
- Specified by:
getLocationInfoin interfaceXMLStreamReader2
-
getNonTransientNamespaceContext
public NamespaceContext getNonTransientNamespaceContext()
Description copied from interface:XMLStreamReader2This method returns a namespace context object that contains information identical to that returned byXMLStreamReader.getNamespaceContext(), but one that is not transient. That is, one that will remain valid and unchanged after its creation. This allows the namespace context to be used independent of its source documents life cycle. One possible use case is to use this namespace context for 'initializing' writers (especially ones that use repairing mode) with optimal/preferred name space bindings.- Specified by:
getNonTransientNamespaceContextin interfaceXMLStreamReader2- Returns:
- Non-transient namespace context as explained above.
-
getPrefixedName
public String getPrefixedName()
Description copied from interface:XMLStreamReader2This method returns "prefix-qualified" name of the current element. In general, this means character-by-character exact name of the element in XML content, and may be useful in informational purposes, as well as when interacting with packages and APIs that use such names (such as what SAX may use as qnames).Note: implementations are encouraged to provide an implementation that would be more efficient than calling
getLocalNameandgetPrefixseparately, but are not required to do so. Nonetheless it is usually at least as efficient (if not more) to call this method as to do it fully in calling code.- Specified by:
getPrefixedNamein interfaceXMLStreamReader2- Returns:
- Prefix-qualified name of the current element; essentially 'prefix:localName' if the element has a prefix, or 'localName' if it does not have one (belongs to the default namespace)
-
getText
public int getText(Writer w, boolean preserveContents) throws IOException, XMLStreamException
Description copied from interface:XMLStreamReader2Method similar toXMLStreamReader.getText(), except that it just uses provided Writer to write all textual content, and that it works for wider range of event types. For further optimization, it may also be allowed to do true pass-through, thus possibly avoiding one temporary copy of the data. Finally, note that this method is also guaranteed NOT to return fragments, even when coalescing is not enabled and a parser is otherwised allowed to return partial segments: this requirement is due to there being little benefit in returning such short chunks when streaming. Coalescing property is still honored normally.Method can only be called on states CDATA, CHARACTERS, COMMENT, DTD, ENTITY_REFERENCE, SPACE and PROCESSING_INSTRUCTION; if called when reader is in another state,
IllegalStateExceptionwill be thrown. Content written for elements is same as withXMLStreamReader.getText().- Specified by:
getTextin interfaceXMLStreamReader2- Parameters:
w- Writer to use for writing textual contentspreserveContents- If true, reader has to preserve contents so that further calls togetTextwill return proper conntets. If false, reader is allowed to skip creation of such copies: this can improve performance, but it also means that further calls togetTextis not guaranteed to return meaningful data.- Returns:
- Number of characters written to the reader
- Throws:
IOExceptionXMLStreamException
-
isEmptyElement
public boolean isEmptyElement() throws XMLStreamExceptionDescription copied from interface:XMLStreamReader2Method that can be used to check whether current START_ELEMENT event was created for an empty element (xml short-hand notation where one tag implies start and end, ending with "/>"), or not.Note: method may need to read more data to know if the element is an empty one, and as such may throw an i/o or parsing exception (as
XMLStreamException); however, it won't throw exceptions for non-START_ELEMENT event types.- Specified by:
isEmptyElementin interfaceXMLStreamReader2- Returns:
- True, if current event is START_ELEMENT and is based on a parsed empty element; otherwise false
- Throws:
XMLStreamException
-
isPropertySupported
public boolean isPropertySupported(String name)
Description copied from interface:XMLStreamReader2Method similar toXMLInputFactory.isPropertySupported(java.lang.String), used to determine whether a property is supported by the Reader instance. This means that this method may return false for some properties that the input factory does support: specifically, it should only return true if the value is mutable on per-instance basis. False means that either the property is not recognized, or is not mutable via reader instance.- Specified by:
isPropertySupportedin interfaceXMLStreamReader2
-
setFeature
public void setFeature(String name, Object value)
Description copied from interface:XMLStreamReader2Method that can be used to set per-reader features such as configuration settings; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.Note: although some feature names are shared with
XMLStreamReader2.getFeature(java.lang.String), not all are: some features are read-only, some write-only- Specified by:
setFeaturein interfaceXMLStreamReader2- Parameters:
name- Name of the feature to setvalue- Value to set feature to.
-
setProperty
public boolean setProperty(String name, Object value)
Description copied from interface:XMLStreamReader2Method that can be used to set per-reader properties; a subset of properties one can set via matchingXMLInputFactory2instance. Exactly which methods are mutable is implementation specific.- Specified by:
setPropertyin interfaceXMLStreamReader2- Parameters:
name- Name of the property to setvalue- Value to set property to.- Returns:
- True, if the specified property was succesfully set to specified value; false if its value was not changed
-
skipElement
public void skipElement() throws XMLStreamExceptionDescription copied from interface:XMLStreamReader2Method that will skip all the contents of the element that the stream currently points to. Current event when calling the method has to be START_ELEMENT (or otherwiseIllegalStateExceptionis thrown); after the call the stream will point to the matching END_ELEMENT event, having skipped zero or more intervening events for the contents.- Specified by:
skipElementin interfaceXMLStreamReader2- Throws:
XMLStreamException
-
setValidationProblemHandler
public ValidationProblemHandler setValidationProblemHandler(ValidationProblemHandler h)
Description copied from interface:ValidatableMethod that application can call to define a custom handler for validation problems encountered during validation process.- Specified by:
setValidationProblemHandlerin interfaceValidatable- Parameters:
h- Handler to install, if non null; if null, indicates that the default (implementation-specific) handling should be used- Returns:
- Previously set validation problem handler, if any; null if none was set
-
stopValidatingAgainst
public XMLValidator stopValidatingAgainst(XMLValidationSchema schema) throws XMLStreamException
Description copied from interface:ValidatableMethod that can be called by application to stop validating output against a schema, for whichValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)was called earlier.- Specified by:
stopValidatingAgainstin interfaceValidatable- Returns:
- Validator instance created from the schema that was removed, if one was in use; null if no such schema in use.
- Throws:
XMLStreamException
-
stopValidatingAgainst
public XMLValidator stopValidatingAgainst(XMLValidator validator) throws XMLStreamException
Description copied from interface:ValidatableMethod that can be called by application to stop validating output using specified validator. The validator passed should be an earlier return value for a call toValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema).Note: the specified validator is compared for identity with validators in use, not for equality.
- Specified by:
stopValidatingAgainstin interfaceValidatable- Returns:
- Validator instance found (ie. argument
validator) if it was being used for validating current document; null if not. - Throws:
XMLStreamException
-
validateAgainst
public XMLValidator validateAgainst(XMLValidationSchema schema) throws XMLStreamException
Description copied from interface:ValidatableMethod that will construct aXMLValidatorinstance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call toValidatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema).Note that while this method can be called at any point in output processing, validator instances are not required to be able to handle addition at other points than right before outputting the root element.
- Specified by:
validateAgainstin interfaceValidatable- Returns:
- Validator instance constructed, if validator was added, or null if a validator for the schema has already been constructed.
- 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.- Specified by:
getAttributeIndexin interfaceTypedXMLStreamReader- 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.
- Specified by:
getAttributeAsBooleanin interfaceTypedXMLStreamReader- 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.
-
getAttributeAsDecimal
public BigDecimal getAttributeAsDecimal(int index) throws XMLStreamException
- Specified by:
getAttributeAsDecimalin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
getAttributeAsDouble
public double getAttributeAsDouble(int index) throws XMLStreamException- Specified by:
getAttributeAsDoublein interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
getAttributeAsFloat
public float getAttributeAsFloat(int index) throws XMLStreamException- Specified by:
getAttributeAsFloatin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
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.
- Specified by:
getAttributeAsIntin interfaceTypedXMLStreamReader- 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.
-
getAttributeAsInteger
public BigInteger getAttributeAsInteger(int index) throws XMLStreamException
- Specified by:
getAttributeAsIntegerin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
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.
- Specified by:
getAttributeAsLongin interfaceTypedXMLStreamReader- 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.
-
getAttributeAsQName
public QName getAttributeAsQName(int index) throws XMLStreamException
- Specified by:
getAttributeAsQNamein interfaceTypedXMLStreamReader- 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.- Specified by:
getAttributeAsIntArrayin interfaceTypedXMLStreamReader- 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- Specified by:
getAttributeAsLongArrayin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
getAttributeAsFloatArray
public float[] getAttributeAsFloatArray(int index) throws XMLStreamException- Specified by:
getAttributeAsFloatArrayin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
getAttributeAsDoubleArray
public double[] getAttributeAsDoubleArray(int index) throws XMLStreamException- Specified by:
getAttributeAsDoubleArrayin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
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.
- Specified by:
getElementAsin interfaceTypedXMLStreamReader- 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.
- Specified by:
getElementAsBooleanin interfaceTypedXMLStreamReader- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getElementAsDecimal
public BigDecimal getElementAsDecimal() throws XMLStreamException
- Specified by:
getElementAsDecimalin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
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.
- Specified by:
getElementAsDoublein interfaceTypedXMLStreamReader- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into a Java double
-
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.
- Specified by:
getElementAsFloatin interfaceTypedXMLStreamReader- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into a Java float
-
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.
- Specified by:
getElementAsIntin interfaceTypedXMLStreamReader- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into a Java (32-bit) integer.
-
getElementAsInteger
public BigInteger getElementAsInteger() throws XMLStreamException
- Specified by:
getElementAsIntegerin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
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.
- Specified by:
getElementAsLongin interfaceTypedXMLStreamReader- Throws:
XMLStreamException- If unable to access contentTypedXMLStreamException- If unable to convert the resulting character sequence into a Java (64-bit) integer.
-
getElementAsQName
public QName getElementAsQName() throws XMLStreamException
- Specified by:
getElementAsQNamein interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
getElementAsBinary
public 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.- Specified by:
getElementAsBinaryin interfaceTypedXMLStreamReader- Throws:
XMLStreamException- See Also:
TypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
-
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.- Specified by:
getElementAsBinaryin interfaceTypedXMLStreamReader- 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)
-
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.- Specified by:
getAttributeAsin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
getAttributeAsArray
public int getAttributeAsArray(int index, TypedArrayDecoder tad) throws XMLStreamExceptionDescription copied from interface:TypedXMLStreamReaderMethod that allows reading contents of an attribute as an array of whitespace-separate tokens, decoded using specified decoder.- Specified by:
getAttributeAsArrayin interfaceTypedXMLStreamReader- 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.- Specified by:
getAttributeAsBinaryin interfaceTypedXMLStreamReader- 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- Specified by:
getAttributeAsBinaryin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
readElementAsDoubleArray
public int readElementAsDoubleArray(double[] value, int from, int length) throws XMLStreamException- Specified by:
readElementAsDoubleArrayin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
readElementAsFloatArray
public int readElementAsFloatArray(float[] value, int from, int length) throws XMLStreamException- Specified by:
readElementAsFloatArrayin interfaceTypedXMLStreamReader- 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.
- Specified by:
readElementAsIntArrayin interfaceTypedXMLStreamReader- 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- Specified by:
readElementAsLongArrayin interfaceTypedXMLStreamReader- Throws:
XMLStreamException
-
readElementAsArray
public int readElementAsArray(TypedArrayDecoder tad) throws XMLStreamException
Description copied from interface:TypedXMLStreamReaderRead an element content as an array of tokens. This is done by reader tokenizing textual content by white space, and sending each token to specified decoder for decoding. This is repeated as long as element content has more tokens and decoder can accept more values.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.
Note: passed decoder must accept at least one value, reader will not verify capacity before calling it with the first token.
- Specified by:
readElementAsArrayin interfaceTypedXMLStreamReader- Returns:
- Number of elements decoded, or -1 to indicate that there was no more element content tokens to decode.
- Throws:
XMLStreamException
-
readElementAsBinary
public int readElementAsBinary(byte[] resultBuffer, int offset, int maxLength) throws XMLStreamException- Specified by:
readElementAsBinaryin interfaceTypedXMLStreamReader- 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.
- Specified by:
readElementAsBinaryin interfaceTypedXMLStreamReader- 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
-
-