javax.xml.stream.XMLStreamReader . It defines methods for
reading XML data and converting it into Java types.
| Modifier and Type | Method and Description |
|---|---|
| public void | getAttributeAs(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. |
| public int | Returns: Number of tokens decoded, 0 if none foundMethod that allows reading contents of an attribute as an array of whitespace-separate tokens, decoded using specified decoder. |
| public byte[] | Returns: An array of bytes with the content.The attribute's index as returned by index)getAttributeIndex(String, String).Read an attribute value as a byte array. |
| public byte[] | |
| public boolean | getAttributeAsBoolean(int
The attribute's index as returned by index)getAttributeIndex(String, String)Read an attribute value as a boolean. |
| public BigDecimal | |
| public double | |
| public double[] | |
| public float | |
| public float[] | |
| public int | getAttributeAsInt(int
The attribute's index as returned by index)getAttributeIndex(String, String)Read an attribute value as a boolean. |
| public int[] | Returns: An array of ints with the content.The attribute's index as returned by index)getAttributeIndex(String, String).Read an attribute content as an int array. |
| public BigInteger | |
| public long | getAttributeAsLong(int
The attribute's index as returned by index)getAttributeIndex(String, String)Read an attribute value as a boolean. |
| public long[] | |
| public QName | |
| public int | Returns: The attribute's index or-1 if no
such attribute exists.The attribute's namespace URI. Values of
null and "" are considered the same, i.e. "no namespace"
(or "empty" namespace) namespaceURI, String The attribute's local name. localName)Returns the index of the attribute whose local name is
|
| public void | getElementAs(TypedValueDecoder tvd)
Generic decoding method that can be used for efficient decoding of additional types not support natively by the typed stream reader. |
| public byte[] | getElementAsBinary()
Convenience method that can be used similar to read binary content
instead of
|
| public byte[] | getElementAsBinary(Base64Variant
Base64 variant content is in; needed to decode
alternative variants ("modified base64") variant)Convenience method that can be used similar to read binary content
instead of
|
| public boolean | |
| public BigDecimal | |
| public double | |
| public float | |
| public int | |
| public BigInteger | |
| public long | |
| public QName | |
| public int | Returns: Number of elements decoded, or -1 to indicate that there was no more element content tokens to decode.Read an element content as an array of tokens. |
| public int | 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 thanmaxLength
Note that this value is not guaranteed to equal maxLength
even 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).Array in which to copy decoded bytes. resultBuffer, int Starting offset of the first decoded byte
within result buffer offset, int Maximum number of bytes to decode with this call maxLength, Base64Variant variant)Read element content as decoded byte sequence; possibly only reading a fragment of all element content. |
| public int | |
| public int | |
| public int | |
| public int | Returns: The number of ints actually copied which must be less or equal thanlength, but
at least one if any ints found. If not, -1 is returned
to signal end of ints to parse.The array in which to copy the ints. resultBuffer, int The index in the array from which copying starts. offset, int The maximun number of ints to copy. Minimum value
is 1; others an length)IllegalArgumentException is thrownRead an element content as an int array. |
| public int |
| getAttributeAs | back to summary |
|---|---|
| public void getAttributeAs(int index, TypedValueDecoder tvd) throws XMLStreamException Generic 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 | |
| getAttributeAsArray | back to summary |
|---|---|
| public int getAttributeAsArray(int index, TypedArrayDecoder tad) throws XMLStreamException Method that allows reading contents of an attribute as an array of whitespace-separate tokens, decoded using specified decoder.
| |
| getAttributeAsBinary | back to summary |
|---|---|
| public byte[] getAttributeAsBinary(int index) throws XMLStreamException Read 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.
| |
| getAttributeAsBinary | back to summary |
|---|---|
| public byte[] getAttributeAsBinary(int index, Base64Variant v) throws XMLStreamException | |
| getAttributeAsBoolean | back to summary |
|---|---|
| public boolean getAttributeAsBoolean(int index) throws XMLStreamException Read 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.
| |
| getAttributeAsDecimal | back to summary |
|---|---|
| public BigDecimal getAttributeAsDecimal(int index) throws XMLStreamException | |
| getAttributeAsDouble | back to summary |
|---|---|
| public double getAttributeAsDouble(int index) throws XMLStreamException | |
| getAttributeAsDoubleArray | back to summary |
|---|---|
| public double[] getAttributeAsDoubleArray(int index) throws XMLStreamException | |
| getAttributeAsFloat | back to summary |
|---|---|
| public float getAttributeAsFloat(int index) throws XMLStreamException | |
| getAttributeAsFloatArray | back to summary |
|---|---|
| public float[] getAttributeAsFloatArray(int index) throws XMLStreamException | |
| getAttributeAsInt | back to summary |
|---|---|
| public int getAttributeAsInt(int index) throws XMLStreamException Read 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.
| |
| getAttributeAsIntArray | back to summary |
|---|---|
| public int[] getAttributeAsIntArray(int index) throws XMLStreamException Read 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 the intArray
type shown above. An exception is thrown if, after whitespace is
collapsed, the resulting sequence of characters is not in
the lexical space defined by the intArray data
type.
| |
| getAttributeAsInteger | back to summary |
|---|---|
| public BigInteger getAttributeAsInteger(int index) throws XMLStreamException | |
| getAttributeAsLong | back to summary |
|---|---|
| public long getAttributeAsLong(int index) throws XMLStreamException Read 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.
| |
| getAttributeAsLongArray | back to summary |
|---|---|
| public long[] getAttributeAsLongArray(int index) throws XMLStreamException | |
| getAttributeAsQName | back to summary |
|---|---|
| public QName getAttributeAsQName(int index) throws XMLStreamException | |
| getAttributeIndex | back to summary |
|---|---|
| public int getAttributeIndex(String namespaceURI, String localName) Returns the index of the attribute whose local name is
| |
| getElementAs | back to summary |
|---|---|
| public void getElementAs(TypedValueDecoder tvd) throws XMLStreamException Generic 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 to
The main benefit of using this method (over just getting
all content by calling These are the pre- and post-conditions of calling this method:
Note that caller has to know more specific type of decoder, since the base interface does not specify methods for accessing actual decoded value. | |
| getElementAsBinary | back to summary |
|---|---|
| public byte[] getElementAsBinary() throws XMLStreamException Convenience method that can be used similar to read binary content
instead of
Note base64 variant defaults to
| |
| getElementAsBinary | back to summary |
|---|---|
| public byte[] getElementAsBinary(Base64Variant variant) throws XMLStreamException Convenience method that can be used similar to read binary content
instead of
| |
| getElementAsBoolean | back to summary |
|---|---|
| public boolean getElementAsBoolean() throws XMLStreamException Read 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:
| |
| getElementAsDecimal | back to summary |
|---|---|
| public BigDecimal getElementAsDecimal() throws XMLStreamException | |
| getElementAsDouble | back to summary |
|---|---|
| public double getElementAsDouble() throws XMLStreamException Read 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.
These are the pre and post conditions of calling this method:
| |
| getElementAsFloat | back to summary |
|---|---|
| public float getElementAsFloat() throws XMLStreamException Read 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.
These are the pre and post conditions of calling this method:
| |
| getElementAsInt | back to summary |
|---|---|
| public int getElementAsInt() throws XMLStreamException Read 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:
| |
| getElementAsInteger | back to summary |
|---|---|
| public BigInteger getElementAsInteger() throws XMLStreamException | |
| getElementAsLong | back to summary |
|---|---|
| public long getElementAsLong() throws XMLStreamException Read 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:
| |
| getElementAsQName | back to summary |
|---|---|
| public QName getElementAsQName() throws XMLStreamException | |
| readElementAsArray | back to summary |
|---|---|
| public int readElementAsArray(TypedArrayDecoder tad) throws XMLStreamException Read 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:
Note passed decoder must accept at least one value, reader will not verify capacity before calling it with the first token.
| |
| readElementAsBinary | back to summary |
|---|---|
| public int readElementAsBinary(byte[] resultBuffer, int offset, int maxLength, Base64Variant variant) throws XMLStreamException Read 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:
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.
| |
| readElementAsBinary | back to summary |
|---|---|
| public int readElementAsBinary(byte[] resultBuffer, int offset, int maxLength) throws XMLStreamException | |
| readElementAsDoubleArray | back to summary |
|---|---|
| public int readElementAsDoubleArray(double[] resultBuffer, int offset, int length) throws XMLStreamException | |
| readElementAsFloatArray | back to summary |
|---|---|
| public int readElementAsFloatArray(float[] resultBuffer, int offset, int length) throws XMLStreamException | |
| readElementAsIntArray | back to summary |
|---|---|
| public int readElementAsIntArray(int[] resultBuffer, int offset, int length) throws XMLStreamException Read 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 the intArray
type shown above. An exception is thrown if, after whitespace is
collapsed, the resulting sequence of characters is not in
the lexical space defined by the intArray data
type.
These are the pre and post conditions of calling this method:
| |
| readElementAsLongArray | back to summary |
|---|---|
| public int readElementAsLongArray(long[] resultBuffer, int offset, int length) throws XMLStreamException | |