com.datastax.driver.core

## Interface GettableByIndexData

• ### Method Summary

All Methods
Modifier and Type Method and Description
boolean getBool(int i)
Returns the ith value as a boolean.
ByteBuffer getBytes(int i)
Returns the ith value as a byte array.
ByteBuffer getBytesUnsafe(int i)
Returns the ith value as a ByteBuffer.
Date getDate(int i)
Returns the ith value as a date.
BigDecimal getDecimal(int i)
Returns the ith value as a variable length decimal.
double getDouble(int i)
Returns the ith value as a double.
float getFloat(int i)
Returns the ith value as a float.
InetAddress getInet(int i)
Returns the ith value as an InetAddress.
int getInt(int i)
Returns the ith value as an integer.
<T> List<T> getList(int i, Class<T> elementsClass)
Returns the ith value as a list.
<T> List<T> getList(int i, TypeToken<T> elementsType)
Returns the ith value as a list.
long getLong(int i)
Returns the ith value as a long.
<K,V> Map<K,V> getMap(int i, Class<K> keysClass, Class<V> valuesClass)
Returns the ith value as a map.
<K,V> Map<K,V> getMap(int i, TypeToken<K> keysType, TypeToken<V> valuesType)
Returns the ith value as a map.
Object getObject(int i)
Returns the ith value as the Java type matching its CQL type.
<T> Set<T> getSet(int i, Class<T> elementsClass)
Returns the ith value as a set.
<T> Set<T> getSet(int i, TypeToken<T> elementsType)
Returns the ith value as a set.
String getString(int i)
Returns the ith value as a string.
TupleValue getTupleValue(int i)
Return the ith value as a tuple value.
UDTValue getUDTValue(int i)
Return the ith value as a UDT value.
UUID getUUID(int i)
Returns the ith value as a UUID.
BigInteger getVarint(int i)
Returns the ith value as a variable length integer.
boolean isNull(int i)
Returns whether the ith value is NULL.
• ### Method Detail

• #### isNull

boolean isNull(int i)
Returns whether the ith value is NULL.
Parameters:
i - the index (0 <= i < size()) of the value to check.
Returns:
whether the ith value is NULL.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
• #### getBool

boolean getBool(int i)
Returns the ith value as a boolean.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the boolean value of the ith element. If the value is NULL, false is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type BOOLEAN.
• #### getInt

int getInt(int i)
Returns the ith value as an integer.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as an integer. If the value is NULL, 0 is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type INT.
• #### getLong

long getLong(int i)
Returns the ith value as a long.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a long. If the value is NULL, 0L is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type BIGINT or COUNTER.
• #### getDate

Date getDate(int i)
Returns the ith value as a date.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a data. If the value is NULL, null is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type TIMESTAMP.
• #### getFloat

float getFloat(int i)
Returns the ith value as a float.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a float. If the value is NULL, 0.0f is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type FLOAT.
• #### getDouble

double getDouble(int i)
Returns the ith value as a double.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a double. If the value is NULL, 0.0 is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type DOUBLE.
• #### getBytesUnsafe

ByteBuffer getBytesUnsafe(int i)
Returns the ith value as a ByteBuffer.

Note: this method always return the bytes composing the value, even if the column is not of type BLOB. That is, this method never throw an InvalidTypeException. However, if the type is not BLOB, it is up to the caller to handle the returned value correctly.

Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a ByteBuffer. If the value is NULL, null is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
• #### getBytes

ByteBuffer getBytes(int i)
Returns the ith value as a byte array.

Note that this method validate that the column is of type BLOB. If you want to retrieve the bytes for any type, use getBytesUnsafe(int) instead.

Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a byte array. If the value is NULL, null is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i type is not of type BLOB.
• #### getString

String getString(int i)
Returns the ith value as a string.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a string. If the value is NULL, null is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i type is none of: VARCHAR, TEXT or ASCII.
• #### getVarint

BigInteger getVarint(int i)
Returns the ith value as a variable length integer.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a variable length integer. If the value is NULL, null is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type VARINT.
• #### getDecimal

BigDecimal getDecimal(int i)
Returns the ith value as a variable length decimal.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a variable length decimal. If the value is NULL, null is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type DECIMAL.
• #### getUUID

UUID getUUID(int i)
Returns the ith value as a UUID.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a UUID. If the value is NULL, null is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type UUID or TIMEUUID.
• #### getInet

InetAddress getInet(int i)
Returns the ith value as an InetAddress.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as an InetAddress. If the value is NULL, null is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not of type INET.
• #### getList

<T> List<T> getList(int i,
Class<T> elementsClass)
Returns the ith value as a list.

If the type of the elements is generic, use getList(int, TypeToken).

Parameters:
i - the index (0 <= i < size()) to retrieve.
elementsClass - the class for the elements of the list to retrieve.
Returns:
the value of the ith element as a list of T objects. If the value is NULL, an empty list is returned (note that Cassandra makes no difference between an empty list and column of type list that is not set). The returned list is immutable.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not a list or if its elements are not of class T.
• #### getList

<T> List<T> getList(int i,
TypeToken<T> elementsType)
Returns the ith value as a list.

Use this variant with nested collections, which produce a generic element type:

  List<List<String>> l = row.getList(1, new TypeToken<List<String>>() {});

Parameters:
i - the index (0 <= i < size()) to retrieve.
elementsType - the type of the elements of the list to retrieve.
Returns:
the value of the ith element as a list of T objects. If the value is NULL, an empty list is returned (note that Cassandra makes no difference between an empty list and column of type list that is not set). The returned list is immutable.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not a list or if its elements are not of class T.
• #### getSet

<T> Set<T> getSet(int i,
Class<T> elementsClass)
Returns the ith value as a set.

If the type of the elements is generic, use getSet(int, TypeToken).

Parameters:
i - the index (0 <= i < size()) to retrieve.
elementsClass - the class for the elements of the set to retrieve.
Returns:
the value of the ith element as a set of T objects. If the value is NULL, an empty set is returned (note that Cassandra makes no difference between an empty set and column of type set that is not set). The returned set is immutable.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not a set or if its elements are not of class T.
• #### getSet

<T> Set<T> getSet(int i,
TypeToken<T> elementsType)
Returns the ith value as a set.

Use this variant with nested collections, which produce a generic element type:

  Set<List<String>> l = row.getSet(1, new TypeToken<List<String>>() {});

Parameters:
i - the index (0 <= i < size()) to retrieve.
elementsType - the type for the elements of the set to retrieve.
Returns:
the value of the ith element as a set of T objects. If the value is NULL, an empty set is returned (note that Cassandra makes no difference between an empty set and column of type set that is not set). The returned set is immutable.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not a set or if its elements are not of class T.
• #### getMap

<K,V> Map<K,V> getMap(int i,
Class<K> keysClass,
Class<V> valuesClass)
Returns the ith value as a map.

If the type of the keys and/or values is generic, use getMap(int, TypeToken, TypeToken).

Parameters:
i - the index (0 <= i < size()) to retrieve.
keysClass - the class for the keys of the map to retrieve.
valuesClass - the class for the values of the map to retrieve.
Returns:
the value of the ith element as a map of K to V objects. If the value is NULL, an empty map is returned (note that Cassandra makes no difference between an empty map and column of type map that is not set). The returned map is immutable.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not a map, if its keys are not of class K or if its values are not of class V.
• #### getMap

<K,V> Map<K,V> getMap(int i,
TypeToken<K> keysType,
TypeToken<V> valuesType)
Returns the ith value as a map.

Use this variant with nested collections, which produce a generic element type:

  Map<Int, List<String>> l = row.getMap(1, TypeToken.of(Integer.class), new TypeToken<List<String>>() {});

Parameters:
i - the index (0 <= i < size()) to retrieve.
keysType - the type for the keys of the map to retrieve.
valuesType - the type for the values of the map to retrieve.
Returns:
the value of the ith element as a map of K to V objects. If the value is NULL, an empty map is returned (note that Cassandra makes no difference between an empty map and column of type map that is not set). The returned map is immutable.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not a map, if its keys are not of class K or if its values are not of class V.
• #### getUDTValue

UDTValue getUDTValue(int i)
Return the ith value as a UDT value.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a UDT value. If the value is NULL, then null will be returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not a UDT value.
• #### getTupleValue

TupleValue getTupleValue(int i)
Return the ith value as a tuple value.
Parameters:
i - the index (0 <= i < size()) to retrieve.
Returns:
the value of the ith element as a tuple value. If the value is NULL, then null will be returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.
InvalidTypeException - if value i is not a tuple value.
• #### getObject

Object getObject(int i)
Returns the ith value as the Java type matching its CQL type.
Parameters:
i - the index to retrieve.
Returns:
the value of the ith value as the Java type matching its CQL type. If the value is NULL and is a simple type, UDT or tuple, null is returned. If it is NULL and is a collection type, an empty (immutable) collection is returned.
Throws:
IndexOutOfBoundsException - if i is not a valid index for this object.