org.codehaus.stax2.typed
Interface TypedXMLStreamReader


public interface TypedXMLStreamReader

This interface provides a typed extension to XMLStreamReader. It defines methods for reading XML data and converting it into Java types.

Author:
Santiago.PericasGeertsen@sun.com, Tatu Saloranta

Method Summary
 byte[] getAttributeAsBinary(int index)
          Read an attribute value as a byte array.
 boolean getAttributeAsBoolean(int index)
          Read an attribute value as a boolean.
 java.math.BigDecimal getAttributeAsDecimal(int index)
          [TODO] Same as getAttributeAsBoolean(int) replacing boolean by decimal.
 double getAttributeAsDouble(int index)
          [TODO] Same as getAttributeAsBoolean(int) replacing boolean by double.
 double[] getAttributeAsDoubleArray(int index)
          [TODO] Same as getAttributeAsIntArray(int) replacing int by double.
 float getAttributeAsFloat(int index)
          [TODO] Same as getAttributeAsBoolean(int) replacing boolean by float.
 float[] getAttributeAsFloatArray(int index)
          [TODO] Same as getAttributeAsIntArray(int) replacing int by float.
 int getAttributeAsInt(int index)
          [TODO] Same as getAttributeAsBoolean(int) replacing boolean by int.
 int[] getAttributeAsIntArray(int index)
          Read an attribute content as an int array.
 java.math.BigInteger getAttributeAsInteger(int index)
          [TODO] Same as getAttributeAsBoolean(int) replacing boolean by integer.
 long getAttributeAsLong(int index)
          [TODO] Same as getAttributeAsBoolean(int) replacing boolean by long.
 long[] getAttributeAsLongArray(int index)
          [TODO] Same as getAttributeAsIntArray(int) replacing int by long.
 javax.xml.namespace.QName getAttributeAsQName(int index)
          [TODO] Same as getAttributeAsBoolean(int) replacing boolean by QName.
 int getAttributeIndex(java.lang.String namespaceURI, java.lang.String localName)
          Returns the index of the attribute whose local name is localName and URI is namespaceURI or -1 if no such attribute exists.
 int getElementAsBinary(byte[] value, int from, int length)
          Read an element content as a byte array.
 boolean getElementAsBoolean()
          Read an element content as a boolean.
 java.math.BigDecimal getElementAsDecimal()
          [TODO] Same as getElementAsBoolean() replacing boolean by decimal.
 double getElementAsDouble()
          [TODO] Same as getElementAsBoolean() replacing boolean by double.
 int getElementAsDoubleArray(double[] value, int from, int length)
          [TODO] Same as getElementAsIntArray(int[], int, int) replacing int by double.
 float getElementAsFloat()
          [TODO] Same as getElementAsBoolean() replacing boolean by float.
 int getElementAsFloatArray(float[] value, int from, int length)
          [TODO] Same as getElementAsIntArray(int[], int, int) replacing int by float.
 int getElementAsInt()
          [TODO] Same as getElementAsBoolean() replacing boolean by int.
 int getElementAsIntArray(int[] value, int from, int length)
          Read an element content as an int array.
 java.math.BigInteger getElementAsInteger()
          [TODO] Same as getElementAsBoolean() replacing boolean by long.
 long getElementAsLong()
          [TODO] Same as getElementAsBoolean() replacing boolean by long.
 int getElementAsLongArray(long[] value, int from, int length)
          [TODO] Same as getElementAsIntArray(int[], int, int) replacing int by long.
 javax.xml.namespace.QName getElementAsQName()
          [TODO] Same as getElementAsBoolean() replacing boolean by QName.
 

Method Detail

getElementAsBoolean

public boolean getElementAsBoolean()
                            throws TypedXMLStreamException

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.

These are the pre and post conditions of calling this method, regardless of whether an exception is thrown or not.

Throws:
TypedXMLStreamException - If unable to convert the resulting character sequence into an XML Schema boolean value.

getElementAsInt

public int getElementAsInt()
                    throws TypedXMLStreamException

[TODO] Same as getElementAsBoolean() replacing boolean by int.

Throws:
TypedXMLStreamException

getElementAsLong

public long getElementAsLong()
                      throws TypedXMLStreamException

[TODO] Same as getElementAsBoolean() replacing boolean by long.

Throws:
TypedXMLStreamException

getElementAsFloat

public float getElementAsFloat()
                        throws TypedXMLStreamException

[TODO] Same as getElementAsBoolean() replacing boolean by float.

Throws:
TypedXMLStreamException

getElementAsDouble

public double getElementAsDouble()
                          throws TypedXMLStreamException

[TODO] Same as getElementAsBoolean() replacing boolean by double.

Throws:
TypedXMLStreamException

getElementAsInteger

public java.math.BigInteger getElementAsInteger()
                                         throws TypedXMLStreamException

[TODO] Same as getElementAsBoolean() replacing boolean by long.

Throws:
TypedXMLStreamException

getElementAsDecimal

public java.math.BigDecimal getElementAsDecimal()
                                         throws TypedXMLStreamException

[TODO] Same as getElementAsBoolean() replacing boolean by decimal.

Throws:
TypedXMLStreamException

getElementAsQName

public javax.xml.namespace.QName getElementAsQName()
                                            throws TypedXMLStreamException

[TODO] Same as getElementAsBoolean() replacing boolean by QName.

Throws:
TypedXMLStreamException

getElementAsBinary

public int getElementAsBinary(byte[] value,
                              int from,
                              int length)
                       throws TypedXMLStreamException

Read an element content 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.

These are the pre and post conditions of calling this method:

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 more bytes available for reading. If an exception is thrown, the cursor will be moved to the END_ELEMENT position.

Parameters:
value - The array in which to copy the bytes.
from - The index in the array from which copying starts.
length - The maximun number of bytes to copy.
Returns:
The number of bytes actually copied which must be less or equal than length.
Throws:
TypedXMLStreamException

getElementAsIntArray

public int getElementAsIntArray(int[] value,
                                int from,
                                int length)
                         throws TypedXMLStreamException

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:

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 more bytes available for reading. If an exception is thrown, the cursor will be moved to the END_ELEMENT position.

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.
Returns:
The number of ints actually copied which must be less or equal than length.
Throws:
TypedXMLStreamException

getElementAsLongArray

public int getElementAsLongArray(long[] value,
                                 int from,
                                 int length)
                          throws TypedXMLStreamException

[TODO] Same as getElementAsIntArray(int[], int, int) replacing int by long.

Throws:
TypedXMLStreamException

getElementAsFloatArray

public int getElementAsFloatArray(float[] value,
                                  int from,
                                  int length)
                           throws TypedXMLStreamException

[TODO] Same as getElementAsIntArray(int[], int, int) replacing int by float.

Throws:
TypedXMLStreamException

getElementAsDoubleArray

public int getElementAsDoubleArray(double[] value,
                                   int from,
                                   int length)
                            throws TypedXMLStreamException

[TODO] Same as getElementAsIntArray(int[], int, int) replacing int by double.

Throws:
TypedXMLStreamException

getAttributeIndex

public int getAttributeIndex(java.lang.String namespaceURI,
                             java.lang.String localName)
Returns the index of the attribute whose local name is localName and URI is namespaceURI or -1 if no such attribute exists. If namespaceURI is null the namespace is not checked for equality.

Parameters:
namespaceURI - The attribute's namespace URI.
localName - The attribute's local name.
Returns:
The attribute's index or -1 if no such attribute exists.
Throws:
java.lang.IllegalStateException - If this is not a START_ELEMENT or ATTRIBUTE event.
TypedXMLStreamException - If unable to convert the resulting character sequence into an XML Schema boolean value.

getAttributeAsBoolean

public boolean getAttributeAsBoolean(int index)
                              throws TypedXMLStreamException

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.

Parameters:
index - The attribute's index as returned by getAttributeIndex(String, String)
Throws:
java.lang.IllegalStateException - If this is not a START_ELEMENT or ATTRIBUTE event.
TypedXMLStreamException - If unable to convert the resulting character sequence into an XML Schema boolean value.

getAttributeAsInt

public int getAttributeAsInt(int index)
                      throws TypedXMLStreamException

[TODO] Same as getAttributeAsBoolean(int) replacing boolean by int.

Throws:
TypedXMLStreamException

getAttributeAsLong

public long getAttributeAsLong(int index)
                        throws TypedXMLStreamException

[TODO] Same as getAttributeAsBoolean(int) replacing boolean by long.

Throws:
TypedXMLStreamException

getAttributeAsFloat

public float getAttributeAsFloat(int index)
                          throws TypedXMLStreamException

[TODO] Same as getAttributeAsBoolean(int) replacing boolean by float.

Throws:
TypedXMLStreamException

getAttributeAsDouble

public double getAttributeAsDouble(int index)
                            throws TypedXMLStreamException

[TODO] Same as getAttributeAsBoolean(int) replacing boolean by double.

Throws:
TypedXMLStreamException

getAttributeAsInteger

public java.math.BigInteger getAttributeAsInteger(int index)
                                           throws TypedXMLStreamException

[TODO] Same as getAttributeAsBoolean(int) replacing boolean by integer.

Throws:
TypedXMLStreamException

getAttributeAsDecimal

public java.math.BigDecimal getAttributeAsDecimal(int index)
                                           throws TypedXMLStreamException

[TODO] Same as getAttributeAsBoolean(int) replacing boolean by decimal.

Throws:
TypedXMLStreamException

getAttributeAsQName

public javax.xml.namespace.QName getAttributeAsQName(int index)
                                              throws TypedXMLStreamException

[TODO] Same as getAttributeAsBoolean(int) replacing boolean by QName.

Throws:
TypedXMLStreamException

getAttributeAsBinary

public byte[] getAttributeAsBinary(int index)
                            throws TypedXMLStreamException

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.

Parameters:
index - The attribute's index as returned by getAttributeIndex(String, String).
Returns:
An array of bytes with the content.
Throws:
java.lang.IllegalStateException - If this is not a START_ELEMENT or ATTRIBUTE event.
TypedXMLStreamException - If unable to convert the resulting character sequence into an XML Schema boolean value.

getAttributeAsIntArray

public int[] getAttributeAsIntArray(int index)
                             throws TypedXMLStreamException

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.

Parameters:
index - The attribute's index as returned by getAttributeIndex(String, String).
Returns:
An array of ints with the content.
Throws:
java.lang.IllegalStateException - If this is not a START_ELEMENT or ATTRIBUTE event.
TypedXMLStreamException - If unable to convert the resulting character sequence into an XML Schema boolean value.

getAttributeAsLongArray

public long[] getAttributeAsLongArray(int index)
                               throws TypedXMLStreamException

[TODO] Same as getAttributeAsIntArray(int) replacing int by long.

Throws:
TypedXMLStreamException

getAttributeAsFloatArray

public float[] getAttributeAsFloatArray(int index)
                                 throws TypedXMLStreamException

[TODO] Same as getAttributeAsIntArray(int) replacing int by float.

Throws:
TypedXMLStreamException

getAttributeAsDoubleArray

public double[] getAttributeAsDoubleArray(int index)
                                   throws TypedXMLStreamException

[TODO] Same as getAttributeAsIntArray(int) replacing int by double.

Throws:
TypedXMLStreamException