public class TupleValue extends Object
Modifier and Type | Field and Description |
---|---|
protected ProtocolVersion |
protocolVersion |
Modifier and Type | Method and Description |
---|---|
protected void |
checkType(int i,
DataType.Name actual) |
protected <T> TypeCodec<T> |
codecFor(int i) |
protected <T> TypeCodec<T> |
codecFor(int i,
Class<T> javaClass) |
protected <T> TypeCodec<T> |
codecFor(int i,
T value) |
protected <T> TypeCodec<T> |
codecFor(int i,
com.google.common.reflect.TypeToken<T> javaType) |
boolean |
equals(Object o) |
<T> T |
get(int i,
Class<T> targetClass)
Returns the
i th value converted to the given Java type. |
<T> T |
get(int i,
TypeCodec<T> codec)
Returns the
i th value converted using the given TypeCodec . |
<T> T |
get(int i,
com.google.common.reflect.TypeToken<T> targetType)
Returns the
i th value converted to the given Java type. |
boolean |
getBool(int i)
Returns the
i th value as a boolean. |
byte |
getByte(int i)
Returns the
i th value as a byte. |
ByteBuffer |
getBytes(int i)
Returns the
i th value as a byte array. |
ByteBuffer |
getBytesUnsafe(int i)
Returns the
i th value as a ByteBuffer . |
protected CodecRegistry |
getCodecRegistry() |
LocalDate |
getDate(int i)
Returns the
i th value as a date (without time). |
BigDecimal |
getDecimal(int i)
Returns the
i th value as a variable length decimal. |
double |
getDouble(int i)
Returns the
i th value as a double. |
float |
getFloat(int i)
Returns the
i th value as a float. |
InetAddress |
getInet(int i)
Returns the
i th value as an InetAddress. |
int |
getInt(int i)
Returns the
i th value as an integer. |
<T> List<T> |
getList(int i,
Class<T> elementsClass)
Returns the
i th value as a list. |
<T> List<T> |
getList(int i,
com.google.common.reflect.TypeToken<T> elementsType)
Returns the
i th value as a list. |
long |
getLong(int i)
Returns the
i th value as a long. |
<K,V> Map<K,V> |
getMap(int i,
Class<K> keysClass,
Class<V> valuesClass)
Returns the
i th value as a map. |
<K,V> Map<K,V> |
getMap(int i,
com.google.common.reflect.TypeToken<K> keysType,
com.google.common.reflect.TypeToken<V> valuesType)
Returns the
i th value as a map. |
protected String |
getName(int i)
Returns the name corresponding to the value at index
i . |
Object |
getObject(int i)
Returns the
i th value as the Java type matching its CQL type. |
<T> Set<T> |
getSet(int i,
Class<T> elementsClass)
Returns the
i th value as a set. |
<T> Set<T> |
getSet(int i,
com.google.common.reflect.TypeToken<T> elementsType)
Returns the
i th value as a set. |
short |
getShort(int i)
Returns the
i th value as a short. |
String |
getString(int i)
Returns the
i th value as a string. |
long |
getTime(int i)
Returns the
i th value as a long in nanoseconds since midnight. |
Date |
getTimestamp(int i)
Returns the
i th value as a date. |
TupleValue |
getTupleValue(int i)
Return the
i th value as a tuple value. |
TupleType |
getType()
The tuple type this is a value of.
|
protected DataType |
getType(int i)
Returns the type for the value at index
i . |
UDTValue |
getUDTValue(int i)
Return the
i th value as a UDT value. |
UUID |
getUUID(int i)
Returns the
i th value as a UUID. |
protected ByteBuffer |
getValue(int i)
Returns the value at index
i . |
BigInteger |
getVarint(int i)
Returns the
i th value as a variable length integer. |
int |
hashCode() |
boolean |
isNull(int i)
Returns whether the
i th value is NULL. |
<V> T |
set(int i,
V v,
Class<V> targetClass)
Sets the
i th value to the provided value of the provided Java class. |
<V> T |
set(int i,
V v,
TypeCodec<V> codec)
Sets the
i th value to the provided value, converted using the given TypeCodec . |
<V> T |
set(int i,
V v,
com.google.common.reflect.TypeToken<V> targetType)
Sets the
i th value to the provided value of the provided Java type. |
T |
setBool(int i,
boolean v)
Sets the
i th value to the provided boolean. |
T |
setByte(int i,
byte v)
Set the
i th value to the provided byte. |
T |
setBytes(int i,
ByteBuffer v)
Sets the
i th value to the provided byte buffer. |
T |
setBytesUnsafe(int i,
ByteBuffer v)
Sets the
i th value to the provided byte buffer. |
T |
setDate(int i,
LocalDate v)
Set the
i th value to the provided date (without time). |
T |
setDecimal(int i,
BigDecimal v)
Sets the
i th value to the provided big decimal. |
T |
setDouble(int i,
double v)
Sets the
i th value to the provided double. |
T |
setFloat(int i,
float v)
Sets the
i th value to the provided float. |
T |
setInet(int i,
InetAddress v)
Sets the
i th value to the provided inet address. |
T |
setInt(int i,
int v)
Set the
i th value to the provided integer. |
<E> T |
setList(int i,
List<E> v)
Sets the
i th value to the provided list. |
<E> T |
setList(int i,
List<E> v,
Class<E> elementsClass)
Sets the
i th value to the provided list, which elements are of the provided
Java class. |
<E> T |
setList(int i,
List<E> v,
com.google.common.reflect.TypeToken<E> elementsType)
Sets the
i th value to the provided list, which elements are of the provided
Java type. |
T |
setLong(int i,
long v)
Sets the
i th value to the provided long. |
<K,V> T |
setMap(int i,
Map<K,V> v)
Sets the
i th value to the provided map. |
<K,V> T |
setMap(int i,
Map<K,V> v,
Class<K> keysClass,
Class<V> valuesClass)
Sets the
i th value to the provided map, which keys and values are of the provided
Java classes. |
<K,V> T |
setMap(int i,
Map<K,V> v,
com.google.common.reflect.TypeToken<K> keysType,
com.google.common.reflect.TypeToken<V> valuesType)
Sets the
i th value to the provided map, which keys and values are of the provided
Java types. |
<E> T |
setSet(int i,
Set<E> v)
Sets the
i th value to the provided set. |
<E> T |
setSet(int i,
Set<E> v,
Class<E> elementsClass)
Sets the
i th value to the provided set, which elements are of the provided
Java class. |
<E> T |
setSet(int i,
Set<E> v,
com.google.common.reflect.TypeToken<E> elementsType)
Sets the
i th value to the provided set, which elements are of the provided
Java type. |
T |
setShort(int i,
short v)
Set the
i th value to the provided short. |
T |
setString(int i,
String v)
Sets the
i th value to the provided string. |
T |
setTime(int i,
long v)
Set the
i th value to the provided time as a long in nanoseconds since midnight. |
T |
setTimestamp(int i,
Date v)
Set the
i th value to the provided date. |
T |
setToNull(int i)
Sets the
i th value to null . |
T |
setTupleValue(int i,
TupleValue v)
Sets the
i th value to the provided tuple value. |
T |
setUDTValue(int i,
UDTValue v)
Sets the
i th value to the provided UDT value. |
T |
setUUID(int i,
UUID v)
Sets the
i th value to the provided UUID. |
protected T |
setValue(int i,
ByteBuffer value) |
T |
setVarint(int i,
BigInteger v)
Sets the
i th value to the provided big integer. |
String |
toString() |
protected final ProtocolVersion protocolVersion
protected DataType getType(int i)
i
.i
- the index of the type to fetch.i
.protected String getName(int i)
i
.i
- the index of the name to fetch.i
.protected CodecRegistry getCodecRegistry()
public TupleType getType()
public boolean equals(Object o)
public int hashCode()
protected T setValue(int i, ByteBuffer value)
protected ByteBuffer getValue(int i)
i
.i
- the index to fetch.i
.public T setBool(int i, boolean v)
SettableByIndexData
i
th value to the provided boolean.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type boolean
, this will be the built-in codec).setBool
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. To set the value to NULL, use SettableByIndexData.setToNull(int)
or
set(i, v, Boolean.class)
public T setByte(int i, byte v)
SettableByIndexData
i
th value to the provided byte.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type tinyint
, this will be the built-in codec).setByte
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. To set the value to NULL, use SettableByIndexData.setToNull(int)
or
set(i, v, Byte.class)
public T setShort(int i, short v)
SettableByIndexData
i
th value to the provided short.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type smallint
, this will be the built-in codec).setShort
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. To set the value to NULL, use SettableByIndexData.setToNull(int)
or
set(i, v, Short.class)
public T setInt(int i, int v)
SettableByIndexData
i
th value to the provided integer.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type int
, this will be the built-in codec).setInt
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. To set the value to NULL, use SettableByIndexData.setToNull(int)
or
set(i, v, Integer.class)
public T setLong(int i, long v)
SettableByIndexData
i
th value to the provided long.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type bigint
, this will be the built-in codec).setLong
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. To set the value to NULL, use SettableByIndexData.setToNull(int)
or
set(i, v, Long.class)
public T setTimestamp(int i, Date v)
SettableByIndexData
i
th value to the provided date.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type timestamp
, this will be the built-in codec).setTimestamp
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setDate(int i, LocalDate v)
SettableByIndexData
i
th value to the provided date (without time).
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type date
, this will be the built-in codec).setDate
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setTime(int i, long v)
SettableByIndexData
i
th value to the provided time as a long in nanoseconds since midnight.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type time
, this will be the built-in codec).setTime
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setFloat(int i, float v)
SettableByIndexData
i
th value to the provided float.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type float
, this will be the built-in codec).setFloat
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. To set the value to NULL, use SettableByIndexData.setToNull(int)
or
set(i, v, Float.class)
public T setDouble(int i, double v)
SettableByIndexData
i
th value to the provided double.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type double
, this will be the built-in codec).setDouble
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. To set the value to NULL, use SettableByIndexData.setToNull(int)
or
set(i, v, Double.class)
.public T setString(int i, String v)
SettableByIndexData
i
th value to the provided string.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL types text
, varchar
and ascii
,
this will be the built-in codec).setString
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setBytes(int i, ByteBuffer v)
SettableByIndexData
i
th value to the provided byte buffer.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type blob
, this will be the built-in codec).setBytes
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setBytesUnsafe(int i, ByteBuffer v)
SettableByIndexData
i
th value to the provided byte buffer.
This method does not use any codec; it sets the value in its binary form directly. If you insert
data that is not compatible with the underlying CQL type, you will get an InvalidQueryException
at
execute time.setBytesUnsafe
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setVarint(int i, BigInteger v)
SettableByIndexData
i
th value to the provided big integer.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type varint
, this will be the built-in codec).setVarint
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setDecimal(int i, BigDecimal v)
SettableByIndexData
i
th value to the provided big decimal.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type decimal
, this will be the built-in codec).setDecimal
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setUUID(int i, UUID v)
SettableByIndexData
i
th value to the provided UUID.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL types uuid
and timeuuid
, this will
be the built-in codec).setUUID
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setInet(int i, InetAddress v)
SettableByIndexData
i
th value to the provided inet address.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (for CQL type inet
, this will be the built-in codec).setInet
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public <E> T setList(int i, List<E> v)
SettableByIndexData
i
th value to the provided list.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (the type of the elements in the Java list is not considered).
If two or more codecs target that CQL type, the one that was first registered will be used.
For this reason, it is generally preferable to use the more deterministic methods
SettableByIndexData.setList(int, List, Class)
or SettableByIndexData.setList(int, List, TypeToken)
.setList
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. Note that null
values inside collections are not supported by CQL.public <E> T setList(int i, List<E> v, Class<E> elementsClass)
SettableByIndexData
i
th value to the provided list, which elements are of the provided
Java class.
This method uses the CodecRegistry
to find a codec to handle the conversion of lists of the given
Java type to the underlying CQL type.
If the type of the elements is generic, use SettableByIndexData.setList(int, List, TypeToken)
.setList
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. Note that null
values inside collections are not supported by CQL.elementsClass
- the class for the elements of the list.public <E> T setList(int i, List<E> v, com.google.common.reflect.TypeToken<E> elementsType)
SettableByIndexData
i
th value to the provided list, which elements are of the provided
Java type.
This method uses the CodecRegistry
to find a codec to handle the conversion of lists of the given
Java type to the underlying CQL type.setList
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. Note that null
values inside collections are not supported by CQL.elementsType
- the type for the elements of the list.public <K,V> T setMap(int i, Map<K,V> v)
SettableByIndexData
i
th value to the provided map.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (the type of the elements in the Java map is not considered).
If two or more codecs target that CQL type, the one that was first registered will be used.
For this reason, it is generally preferable to use the more deterministic methods
SettableByIndexData.setMap(int, Map, Class, Class)
or SettableByIndexData.setMap(int, Map, TypeToken, TypeToken)
.setMap
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. Note that null
values inside collections are not supported by CQL.public <K,V> T setMap(int i, Map<K,V> v, Class<K> keysClass, Class<V> valuesClass)
SettableByIndexData
i
th value to the provided map, which keys and values are of the provided
Java classes.
This method uses the CodecRegistry
to find a codec to handle the conversion of lists of the given
Java types to the underlying CQL type.
If the type of the keys or values is generic, use SettableByIndexData.setMap(int, Map, TypeToken, TypeToken)
.setMap
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. Note that null
values inside collections are not supported by CQL.keysClass
- the class for the keys of the map.valuesClass
- the class for the values of the map.public <K,V> T setMap(int i, Map<K,V> v, com.google.common.reflect.TypeToken<K> keysType, com.google.common.reflect.TypeToken<V> valuesType)
SettableByIndexData
i
th value to the provided map, which keys and values are of the provided
Java types.
This method uses the CodecRegistry
to find a codec to handle the conversion of lists of the given
Java types to the underlying CQL type.setMap
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. Note that null
values inside collections are not supported by CQL.keysType
- the type for the keys of the map.valuesType
- the type for the values of the map.public <E> T setSet(int i, Set<E> v)
SettableByIndexData
i
th value to the provided set.
This method uses the CodecRegistry
to find a codec to handle the conversion
to the underlying CQL type (the type of the elements in the Java set is not considered).
If two or more codecs target that CQL type, the one that was first registered will be used.
For this reason, it is generally preferable to use the more deterministic methods
SettableByIndexData.setSet(int, Set, Class)
or SettableByIndexData.setSet(int, Set, TypeToken)
.setSet
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. Note that null
values inside collections are not supported by CQL.public <E> T setSet(int i, Set<E> v, Class<E> elementsClass)
SettableByIndexData
i
th value to the provided set, which elements are of the provided
Java class.
This method uses the CodecRegistry
to find a codec to handle the conversion of sets of the given
Java type to the underlying CQL type.
If the type of the elements is generic, use SettableByIndexData.setSet(int, Set, TypeToken)
.setSet
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. Note that null
values inside collections are not supported by CQL.elementsClass
- the class for the elements of the set.public <E> T setSet(int i, Set<E> v, com.google.common.reflect.TypeToken<E> elementsType)
SettableByIndexData
i
th value to the provided set, which elements are of the provided
Java type.
This method uses the CodecRegistry
to find a codec to handle the conversion of sets of the given
Java type to the underlying CQL type.setSet
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set. Note that null
values inside collections are not supported by CQL.elementsType
- the type for the elements of the set.public T setUDTValue(int i, UDTValue v)
SettableByIndexData
i
th value to the provided UDT value.
This method uses the CodecRegistry
to find a codec to handle the conversion of UDTValue
to the underlying CQL type.setUDTValue
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public T setTupleValue(int i, TupleValue v)
SettableByIndexData
i
th value to the provided tuple value.
This method uses the CodecRegistry
to find a codec to handle the conversion of TupleValue
to the underlying CQL type.setTupleValue
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set.public <V> T set(int i, V v, Class<V> targetClass)
SettableByIndexData
i
th value to the provided value of the provided Java class.
This method uses the CodecRegistry
to find a codec to handle the conversion of the provided Java class
to the underlying CQL type.
If the Java type is generic, use SettableByIndexData.set(int, Object, TypeToken)
instead.set
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set; may be null
.targetClass
- The Java class to convert to; must not be null
;public <V> T set(int i, V v, com.google.common.reflect.TypeToken<V> targetType)
SettableByIndexData
i
th value to the provided value of the provided Java type.
This method uses the CodecRegistry
to find a codec to handle the conversion of the provided Java type
to the underlying CQL type.set
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set; may be null
.targetType
- The Java type to convert to; must not be null
;public <V> T set(int i, V v, TypeCodec<V> codec)
SettableByIndexData
i
th value to the provided value, converted using the given TypeCodec
.
This method entirely bypasses the CodecRegistry
and forces the driver to use the given codec instead.
This can be useful if the codec would collide with a previously registered one, or if you want to use the
codec just once without registering it.
It is the caller's responsibility to ensure that the given codec accepts
the underlying CQL type; failing to do so may result in InvalidTypeException
s being thrown.set
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.v
- the value to set; may be null
.codec
- The TypeCodec
to use to serialize the value; may not be null
.public T setToNull(int i)
SettableByIndexData
i
th value to null
.
This is mainly intended for CQL types which map to native Java types.setToNull
in interface SettableByIndexData<T extends SettableByIndexData<T>>
i
- the index of the value to set.protected <T> TypeCodec<T> codecFor(int i)
protected <T> TypeCodec<T> codecFor(int i, com.google.common.reflect.TypeToken<T> javaType)
protected <T> TypeCodec<T> codecFor(int i, T value)
protected void checkType(int i, DataType.Name actual)
public boolean isNull(int i)
i
th value is NULL.isNull
in interface GettableByIndexData
i
- the index (0 <= i < size()
) of the value to check.i
th value is NULL.public boolean getBool(int i)
i
th value as a boolean.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java boolean
(for CQL type boolean
, this will be the built-in codec).getBool
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element. If the value is NULL, false
is returned.
If you need to distinguish NULL and false values, check first with GettableByIndexData.isNull(int)
or use get(i, Boolean.class)
.public byte getByte(int i)
i
th value as a byte.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java byte
(for CQL type tinyint
, this will be the built-in codec).getByte
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a byte. If the value is NULL, 0
is returned.
If you need to distinguish NULL and 0, check first with GettableByIndexData.isNull(int)
or use get(i, Byte.class)
.public short getShort(int i)
i
th value as a short.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java short
(for CQL type smallint
, this will be the built-in codec).getShort
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a short. If the value is NULL, 0
is returned.
If you need to distinguish NULL and 0, check first with GettableByIndexData.isNull(int)
or use get(i, Short.class)
.public int getInt(int i)
i
th value as an integer.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java int
(for CQL type int
, this will be the built-in codec).getInt
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as an integer. If the value is NULL, 0
is returned.
If you need to distinguish NULL and 0, check first with GettableByIndexData.isNull(int)
or use get(i, Integer.class)
.public long getLong(int i)
i
th value as a long.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java byte
(for CQL types bigint
and counter
, this will be the built-in codec).getLong
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a long. If the value is NULL, 0L
is returned.
If you need to distinguish NULL and 0L, check first with GettableByIndexData.isNull(int)
or use get(i, Long.class)
.public Date getTimestamp(int i)
i
th value as a date.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Date
(for CQL type timestamp
, this will be the built-in codec).getTimestamp
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a data. If the
value is NULL, null
is returned.public LocalDate getDate(int i)
i
th value as a date (without time).
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a LocalDate
(for CQL type date
, this will be the built-in codec).getDate
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as an date. If the
value is NULL, null
is returned.public long getTime(int i)
i
th value as a long in nanoseconds since midnight.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java long
(for CQL type time
, this will be the built-in codec).getTime
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a long. If the
value is NULL, 0L
is returned.public float getFloat(int i)
i
th value as a float.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java float
(for CQL type float
, this will be the built-in codec).getFloat
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a float. If the value is NULL, 0.0f
is returned.
If you need to distinguish NULL and 0.0f, check first with GettableByIndexData.isNull(int)
or use get(i, Float.class)
.public double getDouble(int i)
i
th value as a double.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java double
(for CQL type double
, this will be the built-in codec).getDouble
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a double. If the value is NULL, 0.0
is returned.
If you need to distinguish NULL and 0.0, check first with GettableByIndexData.isNull(int)
or use get(i, Double.class)
.public ByteBuffer getBytesUnsafe(int i)
i
th value as a ByteBuffer
.
This method does not use any codec; it returns a copy of the binary representation of the value. It is up to the
caller to convert the returned value appropriately.getBytesUnsafe
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a ByteBuffer. If the
value is NULL, null
is returned.public ByteBuffer getBytes(int i)
i
th value as a byte array.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java ByteBuffer
(for CQL type blob
, this will be the built-in codec).getBytes
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a byte array. If the
value is NULL, null
is returned.public String getString(int i)
i
th value as a string.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a Java string
(for CQL types text
, varchar
and ascii
, this will be the built-in codec).getString
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a string. If the
value is NULL, null
is returned.public BigInteger getVarint(int i)
i
th value as a variable length integer.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a BigInteger
(for CQL type varint
, this will be the built-in codec).getVarint
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a variable
length integer. If the value is NULL, null
is returned.public BigDecimal getDecimal(int i)
i
th value as a variable length decimal.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a BigDecimal
(for CQL type decimal
, this will be the built-in codec).getDecimal
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a variable
length decimal. If the value is NULL, null
is returned.public UUID getUUID(int i)
i
th value as a UUID.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a UUID
(for CQL types uuid
and timeuuid
, this will be the built-in codec).getUUID
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a UUID.
If the value is NULL, null
is returned.public InetAddress getInet(int i)
i
th value as an InetAddress.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to an InetAddress
(for CQL type inet
, this will be the built-in codec).getInet
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as an InetAddress.
If the value is NULL, null
is returned.public <T> List<T> getList(int i, Class<T> elementsClass)
i
th value as a list.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a list of the specified type.
If the type of the elements is generic, use GettableByIndexData.getList(int, TypeToken)
.
Implementation note: the actual List
implementation will depend
on the codec
being used; therefore, callers should
make no assumptions concerning its mutability nor its thread-safety.
Furthermore, the behavior of this method in respect to CQL NULL
values is also
codec-dependent. By default, the driver will return mutable instances, and
a CQL NULL
will be mapped to an empty collection (note that Cassandra
makes no distinction between NULL
and an empty collection).getList
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.elementsClass
- the class for the elements of the list to retrieve.i
th element as a list of
T
objects.public <T> List<T> getList(int i, com.google.common.reflect.TypeToken<T> elementsType)
i
th value as a list.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a list of the specified type.
Use this variant with nested collections, which produce a generic element type:
List<List<String>> l = row.getList(1, new TypeToken<List<String>>() {});
Implementation note: the actual List
implementation will depend
on the codec
being used; therefore, callers should
make no assumptions concerning its mutability nor its thread-safety.
Furthermore, the behavior of this method in respect to CQL NULL
values is also
codec-dependent. By default, the driver will return mutable instances, and
a CQL NULL
will mapped to an empty collection (note that Cassandra
makes no distinction between NULL
and an empty collection).getList
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.elementsType
- the type of the elements of the list to retrieve.i
th element as a list of
T
objects.public <T> Set<T> getSet(int i, Class<T> elementsClass)
i
th value as a set.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a set of the specified type.
If the type of the elements is generic, use GettableByIndexData.getSet(int, TypeToken)
.
Implementation note: the actual Set
implementation will depend
on the codec
being used; therefore, callers should
make no assumptions concerning its mutability nor its thread-safety.
Furthermore, the behavior of this method in respect to CQL NULL
values is also
codec-dependent. By default, the driver will return mutable instances, and
a CQL NULL
will mapped to an empty collection (note that Cassandra
makes no distinction between NULL
and an empty collection).getSet
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.elementsClass
- the class for the elements of the set to retrieve.i
th element as a set of
T
objects.public <T> Set<T> getSet(int i, com.google.common.reflect.TypeToken<T> elementsType)
i
th value as a set.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a set of the specified type.
Use this variant with nested collections, which produce a generic element type:
Set<List<String>> l = row.getSet(1, new TypeToken<List<String>>() {});
Implementation note: the actual Set
implementation will depend
on the codec
being used; therefore, callers should
make no assumptions concerning its mutability nor its thread-safety.
Furthermore, the behavior of this method in respect to CQL NULL
values is also
codec-dependent. By default, the driver will return mutable instances, and
a CQL NULL
will mapped to an empty collection (note that Cassandra
makes no distinction between NULL
and an empty collection).getSet
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.elementsType
- the type for the elements of the set to retrieve.i
th element as a set of
T
objects.public <K,V> Map<K,V> getMap(int i, Class<K> keysClass, Class<V> valuesClass)
i
th value as a map.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a map of the specified types.
If the type of the keys and/or values is generic, use GettableByIndexData.getMap(int, TypeToken, TypeToken)
.
Implementation note: the actual Map
implementation will depend
on the codec
being used; therefore, callers should
make no assumptions concerning its mutability nor its thread-safety.
Furthermore, the behavior of this method in respect to CQL NULL
values is also
codec-dependent. By default, the driver will return mutable instances, and
a CQL NULL
will mapped to an empty collection (note that Cassandra
makes no distinction between NULL
and an empty collection).getMap
in interface GettableByIndexData
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.i
th element as a map of
K
to V
objects.public <K,V> Map<K,V> getMap(int i, com.google.common.reflect.TypeToken<K> keysType, com.google.common.reflect.TypeToken<V> valuesType)
i
th value as a map.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a map of the specified types.
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>>() {});
Implementation note: the actual Map
implementation will depend
on the codec
being used; therefore, callers should
make no assumptions concerning its mutability nor its thread-safety.
Furthermore, the behavior of this method in respect to CQL NULL
values is also
codec-dependent. By default, the driver will return mutable instances, and
a CQL NULL
will mapped to an empty collection (note that Cassandra
makes no distinction between NULL
and an empty collection).getMap
in interface GettableByIndexData
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.i
th element as a map of
K
to V
objects.public UDTValue getUDTValue(int i)
i
th value as a UDT value.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a UDTValue
(if the CQL type is a UDT, the registry will generate a codec automatically).getUDTValue
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a UDT value. If the value is NULL,
then null
will be returned.public TupleValue getTupleValue(int i)
i
th value as a tuple value.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to a TupleValue
(if the CQL type is a tuple, the registry will generate a codec automatically).getTupleValue
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element as a tuple value. If the value is NULL,
then null
will be returned.public Object getObject(int i)
i
th value as the Java type matching its CQL type.
This method uses the CodecRegistry
to find the first codec that handles the underlying CQL type. The Java type
of the returned object will be determined by the codec that was selected.
Use this method to dynamically inspect elements when types aren't known in advance, for instance if you're writing a
generic row logger. If you know the target Java type, it is generally preferable to use typed getters, such as the
ones for built-in types (GettableByIndexData.getBool(int)
, GettableByIndexData.getInt(int)
, etc.), or GettableByIndexData.get(int, Class)
and
GettableByIndexData.get(int, TypeToken)
for custom types.getObject
in interface GettableByIndexData
i
- the index to retrieve.i
th value as the Java type matching its CQL type.CodecRegistry.codecFor(DataType)
public <T> T get(int i, Class<T> targetClass)
GettableByIndexData
i
th value converted to the given Java type.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to the given Java type.
If the target type is generic, use GettableByIndexData.get(int, TypeToken)
.
Implementation note: the actual object returned by this method will depend
on the codec
being used; therefore, callers should
make no assumptions concerning its mutability nor its thread-safety.
Furthermore, the behavior of this method in respect to CQL NULL
values is also
codec-dependent; by default, a CQL NULL
value translates to null
for
simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types.get
in interface GettableByIndexData
i
- the index to retrieve.targetClass
- The Java type the value should be converted to.i
th value converted to the given Java type.public <T> T get(int i, com.google.common.reflect.TypeToken<T> targetType)
GettableByIndexData
i
th value converted to the given Java type.
This method uses the CodecRegistry
to find a codec to convert the underlying CQL type to the given Java type.
Implementation note: the actual object returned by this method will depend
on the codec
being used; therefore, callers should
make no assumptions concerning its mutability nor its thread-safety.
Furthermore, the behavior of this method in respect to CQL NULL
values is also
codec-dependent; by default, a CQL NULL
value translates to null
for
simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types.get
in interface GettableByIndexData
i
- the index to retrieve.targetType
- The Java type the value should be converted to.i
th value converted to the given Java type.public <T> T get(int i, TypeCodec<T> codec)
GettableByIndexData
i
th value converted using the given TypeCodec
.
This method entirely bypasses the CodecRegistry
and forces the driver to use the given codec instead.
This can be useful if the codec would collide with a previously registered one, or if you want to use the
codec just once without registering it.
It is the caller's responsibility to ensure that the given codec accepts
the underlying CQL type; failing to do so may result in InvalidTypeException
s being thrown.
Implementation note: the actual object returned by this method will depend
on the codec
being used; therefore, callers should
make no assumptions concerning its mutability nor its thread-safety.
Furthermore, the behavior of this method in respect to CQL NULL
values is also
codec-dependent; by default, a CQL NULL
value translates to null
for
simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types.get
in interface GettableByIndexData
i
- the index to retrieve.codec
- The TypeCodec
to use to deserialize the value; may not be null
.i
th value converted using the given TypeCodec
.