public class BoundStatement extends Statement implements SettableData<BoundStatement>, GettableData
Once values has been provided for the variables of the PreparedStatement
it has been created from, such BoundStatement can be executed (through
Session.execute(Statement)
).
The values of a BoundStatement can be set by either index or name. When
setting them by name, names follow the case insensitivity rules explained in
ColumnDefinitions
but with the difference that if multiple bind
variables have the same name, setting that name will set all the
variables for that name.
All the variables of the statement must be bound. If you don't explicitly
set a value for a variable, an IllegalStateException
will be
thrown when submitting the statement. If you want to set a variable to
null
, use setToNull
.
idempotent, NULL_PAYLOAD_VALUE
Constructor and Description |
---|
BoundStatement(PreparedStatement statement)
Creates a new
BoundStatement from the provided prepared
statement. |
Modifier and Type | Method and Description |
---|---|
BoundStatement |
bind(Object... values)
Bound values to the variables of this statement.
|
<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. |
<T> T |
get(String name,
Class<T> targetClass)
Returns the value for
name converted to the given Java type. |
<T> T |
get(String name,
TypeCodec<T> codec)
Returns the value for
name converted using the given TypeCodec . |
<T> T |
get(String name,
com.google.common.reflect.TypeToken<T> targetType)
Returns the value for
name converted to the given Java type. |
boolean |
getBool(int i)
Returns the
i th value as a boolean. |
boolean |
getBool(String name)
Returns the value for
name as a boolean. |
byte |
getByte(int i)
Returns the
i th value as a byte. |
byte |
getByte(String name)
Returns the value for
name as a byte. |
ByteBuffer |
getBytes(int i)
Returns the
i th value as a byte array. |
ByteBuffer |
getBytes(String name)
Returns the value for
name as a byte array. |
ByteBuffer |
getBytesUnsafe(int i)
Returns the
i th value as a ByteBuffer. |
ByteBuffer |
getBytesUnsafe(String name)
Returns the value for
name as a ByteBuffer. |
LocalDate |
getDate(int i)
Returns the
i th value as a date (without time). |
LocalDate |
getDate(String name)
Returns the value for
name as a date (without time). |
BigDecimal |
getDecimal(int i)
Returns the
i th value as a variable length decimal. |
BigDecimal |
getDecimal(String name)
Returns the value for
name as a variable length decimal. |
double |
getDouble(int i)
Returns the
i th value as a double. |
double |
getDouble(String name)
Returns the value for
name as a double. |
float |
getFloat(int i)
Returns the
i th value as a float. |
float |
getFloat(String name)
Returns the value for
name as a float. |
InetAddress |
getInet(int i)
Returns the
i th value as an InetAddress. |
InetAddress |
getInet(String name)
Returns the value for
name as an InetAddress. |
int |
getInt(int i)
Returns the
i th value as an integer. |
int |
getInt(String name)
Returns the value for
name as an integer. |
String |
getKeyspace()
Returns the keyspace this query operates on.
|
<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. |
<T> List<T> |
getList(String name,
Class<T> elementsClass)
Returns the value for
name as a list. |
<T> List<T> |
getList(String name,
com.google.common.reflect.TypeToken<T> elementsType)
Returns the value for
name as a list. |
long |
getLong(int i)
Returns the
i th value as a long. |
long |
getLong(String name)
Returns the value for
name 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. |
<K,V> Map<K,V> |
getMap(String name,
Class<K> keysClass,
Class<V> valuesClass)
Returns the value for
name as a map. |
<K,V> Map<K,V> |
getMap(String name,
com.google.common.reflect.TypeToken<K> keysType,
com.google.common.reflect.TypeToken<V> valuesType)
Returns the value for
name as a map. |
Object |
getObject(int i)
Returns the
i th value as the Java type matching its CQL type. |
Object |
getObject(String name)
Returns the value for
name as the Java type matching its CQL type. |
ByteBuffer |
getRoutingKey()
The routing key for this bound query.
|
<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. |
<T> Set<T> |
getSet(String name,
Class<T> elementsClass)
Returns the value for
name as a set. |
<T> Set<T> |
getSet(String name,
com.google.common.reflect.TypeToken<T> elementsType)
Returns the value for
name as a set. |
short |
getShort(int i)
Returns the
i th value as a short. |
short |
getShort(String name)
Returns the value for
name as a short. |
String |
getString(int i)
Returns the
i th value as a string. |
String |
getString(String name)
Returns the value for
name as a string. |
long |
getTime(int i)
Returns the
i th value as a long in nanoseconds since midnight. |
long |
getTime(String name)
Returns the value for
name as a long in nanoseconds since midnight. |
Date |
getTimestamp(int i)
Returns the
i th value as a date. |
Date |
getTimestamp(String name)
Returns the value for
name as a date. |
TupleValue |
getTupleValue(int i)
Return the
i th value as a tuple value. |
TupleValue |
getTupleValue(String name)
Return the value for
name as a tuple value. |
UDTValue |
getUDTValue(int i)
Return the
i th value as a UDT value. |
UDTValue |
getUDTValue(String name)
Return the value for
name as a UDT value. |
UUID |
getUUID(int i)
Returns the
i th value as a UUID. |
UUID |
getUUID(String name)
Returns the value for
name as a UUID. |
BigInteger |
getVarint(int i)
Returns the
i th value as a variable length integer. |
BigInteger |
getVarint(String name)
Returns the value for
name as a variable length integer. |
boolean |
isNull(int i)
Returns whether the
i th value is NULL. |
boolean |
isNull(String name)
Returns whether the value for
name is NULL. |
boolean |
isSet(int i)
Returns whether the
i th variable has been bound. |
boolean |
isSet(String name)
Returns whether the first occurrence of variable
name has been
bound. |
PreparedStatement |
preparedStatement()
Returns the prepared statement on which this BoundStatement is based.
|
<V> BoundStatement |
set(int i,
V v,
Class<V> targetClass)
Sets the
i th value to the provided value of the provided Java class. |
<V> BoundStatement |
set(int i,
V v,
TypeCodec<V> codec)
Sets the
i th value to the provided value, converted using the given TypeCodec . |
<V> BoundStatement |
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. |
<V> BoundStatement |
set(String name,
V v,
Class<V> targetClass)
Sets the value for (all occurrences of) variable
name to the provided value of the provided Java class. |
<V> BoundStatement |
set(String name,
V v,
TypeCodec<V> codec)
Sets the value for (all occurrences of) variable
name to the provided value,
converted using the given TypeCodec . |
<V> BoundStatement |
set(String name,
V v,
com.google.common.reflect.TypeToken<V> targetType)
Sets the value for (all occurrences of) variable
name to the provided value of the provided Java type. |
BoundStatement |
setBool(int i,
boolean v)
Sets the
i th value to the provided boolean. |
BoundStatement |
setBool(String name,
boolean v)
Sets the value for (all occurrences of) variable
name to the
provided boolean. |
BoundStatement |
setByte(int i,
byte v)
Set the
i th value to the provided byte. |
BoundStatement |
setByte(String name,
byte v)
Sets the value for (all occurrences of) variable
name to the
provided byte. |
BoundStatement |
setBytes(int i,
ByteBuffer v)
Sets the
i th value to the provided byte buffer. |
BoundStatement |
setBytes(String name,
ByteBuffer v)
Sets the value for (all occurrences of) variable
name to the
provided byte buffer. |
BoundStatement |
setBytesUnsafe(int i,
ByteBuffer v)
Sets the
i th value to the provided byte buffer. |
BoundStatement |
setBytesUnsafe(String name,
ByteBuffer v)
Sets the value for (all occurrences of) variable
name to the
provided byte buffer. |
BoundStatement |
setDate(int i,
Date v)
Deprecated.
deprecated in favor of
setTimestamp(int, Date) |
BoundStatement |
setDate(int i,
LocalDate v)
Set the
i th value to the provided date (without time). |
BoundStatement |
setDate(String name,
Date v)
Deprecated.
deprecated in favor of
setTimestamp(String, Date) |
BoundStatement |
setDate(String name,
LocalDate v)
Sets the value for (all occurrences of) variable
name to the
provided date (without time). |
BoundStatement |
setDecimal(int i,
BigDecimal v)
Sets the
i th value to the provided big decimal. |
BoundStatement |
setDecimal(String name,
BigDecimal v)
Sets the value for (all occurrences of) variable
name to the
provided big decimal. |
BoundStatement |
setDouble(int i,
double v)
Sets the
i th value to the provided double. |
BoundStatement |
setDouble(String name,
double v)
Sets the value for (all occurrences of) variable
name to the
provided double. |
BoundStatement |
setFloat(int i,
float v)
Sets the
i th value to the provided float. |
BoundStatement |
setFloat(String name,
float v)
Sets the value for (all occurrences of) variable
name to the
provided float. |
BoundStatement |
setInet(int i,
InetAddress v)
Sets the
i th value to the provided inet address. |
BoundStatement |
setInet(String name,
InetAddress v)
Sets the value for (all occurrences of) variable
name to the
provided inet address. |
BoundStatement |
setInt(int i,
int v)
Set the
i th value to the provided integer. |
BoundStatement |
setInt(String name,
int v)
Sets the value for (all occurrences of) variable
name to the
provided integer. |
<E> BoundStatement |
setList(int i,
List<E> v,
Class<E> elementsClass)
Sets the
i th value to the provided list, whose elements are of the provided
Java class. |
<E> BoundStatement |
setList(int i,
List<E> v,
com.google.common.reflect.TypeToken<E> elementsType)
Sets the
i th value to the provided list, whose elements are of the provided
Java type. |
<T> BoundStatement |
setList(int i,
List<T> v)
Sets the
i th value to the provided list. |
<E> BoundStatement |
setList(String name,
List<E> v,
Class<E> elementsClass)
Sets the value for (all occurrences of) variable
name to the provided list,
whose elements are of the provided Java class. |
<E> BoundStatement |
setList(String name,
List<E> v,
com.google.common.reflect.TypeToken<E> elementsType)
Sets the value for (all occurrences of) variable
name to the provided list,
whose elements are of the provided Java type. |
<T> BoundStatement |
setList(String name,
List<T> v)
Sets the value for (all occurrences of) variable
name to the
provided list. |
BoundStatement |
setLong(int i,
long v)
Sets the
i th value to the provided long. |
BoundStatement |
setLong(String name,
long v)
Sets the value for (all occurrences of) variable
name to the
provided long. |
<K,V> BoundStatement |
setMap(int i,
Map<K,V> v)
Sets the
i th value to the provided map. |
<K,V> BoundStatement |
setMap(int i,
Map<K,V> v,
Class<K> keysClass,
Class<V> valuesClass)
Sets the
i th value to the provided map, whose keys and values are of the provided
Java classes. |
<K,V> BoundStatement |
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, whose keys and values are of the provided
Java types. |
<K,V> BoundStatement |
setMap(String name,
Map<K,V> v)
Sets the value for (all occurrences of) variable
name to the
provided map. |
<K,V> BoundStatement |
setMap(String name,
Map<K,V> v,
Class<K> keysClass,
Class<V> valuesClass)
Sets the value for (all occurrences of) variable
name to the provided map,
whose keys and values are of the provided Java classes. |
<K,V> BoundStatement |
setMap(String name,
Map<K,V> v,
com.google.common.reflect.TypeToken<K> keysType,
com.google.common.reflect.TypeToken<V> valuesType)
Sets the value for (all occurrences of) variable
name to the provided map,
whose keys and values are of the provided Java types. |
<V> BoundStatement |
setObject(int i,
V v)
Sets the
i th value to the provided value. |
<V> BoundStatement |
setObject(String name,
V v)
Sets the value for (all occurrences of) variable
name to the provided value. |
BoundStatement |
setPartitionKeyToken(Token v)
Sets the value for (all occurrences of) variable "
partition key token "
to the provided token (this is the name generated by Cassandra for markers
corresponding to a token(...) call). |
BoundStatement |
setRoutingKey(ByteBuffer routingKey)
Sets the routing key for this bound statement.
|
<E> BoundStatement |
setSet(int i,
Set<E> v,
Class<E> elementsClass)
Sets the
i th value to the provided set, whose elements are of the provided
Java class. |
<E> BoundStatement |
setSet(int i,
Set<E> v,
com.google.common.reflect.TypeToken<E> elementsType)
Sets the
i th value to the provided set, whose elements are of the provided
Java type. |
<T> BoundStatement |
setSet(int i,
Set<T> v)
Sets the
i th value to the provided set. |
<E> BoundStatement |
setSet(String name,
Set<E> v,
Class<E> elementsClass)
Sets the value for (all occurrences of) variable
name to the provided set,
whose elements are of the provided Java class. |
<E> BoundStatement |
setSet(String name,
Set<E> v,
com.google.common.reflect.TypeToken<E> elementsType)
Sets the value for (all occurrences of) variable
name to the provided set,
whose elements are of the provided Java type. |
<T> BoundStatement |
setSet(String name,
Set<T> v)
Sets the value for (all occurrences of) variable
name to the
provided set. |
BoundStatement |
setShort(int i,
short v)
Set the
i th value to the provided short. |
BoundStatement |
setShort(String name,
short v)
Sets the value for (all occurrences of) variable
name to the
provided short. |
BoundStatement |
setString(int i,
String v)
Sets the
i th value to the provided string. |
BoundStatement |
setString(String name,
String v)
Sets the value for (all occurrences of) variable
name to the
provided string. |
BoundStatement |
setTime(int i,
long v)
Set the
i th value to the provided time as a long in nanoseconds since midnight. |
BoundStatement |
setTime(String name,
long v)
Sets the value for (all occurrences of) variable
name to the
provided time as a long in nanoseconds since midnight. |
BoundStatement |
setTimestamp(int i,
Date v)
Set the
i th value to the provided date. |
BoundStatement |
setTimestamp(String name,
Date v)
Sets the value for (all occurrences of) variable
name to the
provided date. |
BoundStatement |
setToken(int i,
Token v)
Sets the
i th value to the provided Token . |
BoundStatement |
setToken(String name,
Token v)
Sets the value for (all occurrences of) variable
name to the
provided token. |
BoundStatement |
setToNull(int i)
Sets the
i th value to null . |
BoundStatement |
setToNull(String name)
Sets the value for (all occurrences of) variable
name to null . |
BoundStatement |
setTupleValue(int i,
TupleValue v)
Sets the
i th value to the provided tuple value. |
BoundStatement |
setTupleValue(String name,
TupleValue v)
Sets the value for (all occurrences of) variable
name to the
provided tuple value. |
BoundStatement |
setUDTValue(int i,
UDTValue v)
Sets the
i th value to the provided UDT value. |
BoundStatement |
setUDTValue(String name,
UDTValue v)
Sets the value for (all occurrences of) variable
name to the
provided UDT value. |
BoundStatement |
setUUID(int i,
UUID v)
Sets the
i th value to the provided UUID. |
BoundStatement |
setUUID(String name,
UUID v)
Sets the value for (all occurrences of) variable
name to the
provided UUID. |
BoundStatement |
setVarint(int i,
BigInteger v)
Sets the
i th value to the provided big integer. |
BoundStatement |
setVarint(String name,
BigInteger v)
Sets the value for (all occurrences of) variable
name to the
provided big integer. |
disableTracing, enableTracing, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getRetryPolicy, getSerialConsistencyLevel, isIdempotent, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setIdempotent, setOutgoingPayload, setPagingState, setPagingStateUnsafe, setRetryPolicy, setSerialConsistencyLevel
public BoundStatement(PreparedStatement statement)
BoundStatement
from the provided prepared
statement.statement
- the prepared statement from which to create a BoundStatement
.public PreparedStatement preparedStatement()
public boolean isSet(int i)
i
th variable has been bound.i
- the index of the variable to check.i
th variable has been bound.IndexOutOfBoundsException
- if i < 0 || i >= this.preparedStatement().variables().size()
.public boolean isSet(String name)
name
has been
bound.name
- the name of the variable to check.name
has been
bound to a non-null value.IllegalArgumentException
- if name
is not a prepared
variable, that is if !this.preparedStatement().variables().names().contains(name)
.public BoundStatement bind(Object... values)
BoundStatement
in one call.values
- the values to bind to the variables of the newly created
BoundStatement. The first element of values
will be bound to the
first bind variable, etc. It is legal to provide fewer values than the
statement has bound variables. In that case, the remaining variable need
to be bound before execution. If more values than variables are provided
however, an IllegalArgumentException wil be raised.IllegalArgumentException
- if more values
are provided
than there is of bound variables in this statement.InvalidTypeException
- if any of the provided value is not of
correct type to be bound to the corresponding bind variable.NullPointerException
- if one of values
is a collection
(List, Set or Map) containing a null value. Nulls are not supported in
collections by CQL.public ByteBuffer getRoutingKey()
This method will return a non-null
value if either of the following occur:
setRoutingKey(java.nio.ByteBuffer)
.PreparedStatement.setRoutingKey(java.nio.ByteBuffer)
for the
PreparedStatement
this statement has been built from.BoundStatement
. The routing
key will then be built using the values provided for these partition key columns.null
is returned.
Note that if the routing key has been set through setRoutingKey(java.nio.ByteBuffer)
, then that takes
precedence. If the routing key has been set through PreparedStatement.setRoutingKey(java.nio.ByteBuffer)
then that is used
next. If neither of those are set then it is computed.
getRoutingKey
in class Statement
null
.public BoundStatement setRoutingKey(ByteBuffer routingKey)
This is useful when the routing key can neither be set on the PreparedStatement
this bound statement
was built from, nor automatically computed from bound variables. In particular, this is the case if the
partition key is composite and only some of its components are bound.
routingKey
- the raw (binary) value to use as routing key.BoundStatement
object.getRoutingKey()
public String getKeyspace()
Note that not all query specify on which keyspace they operate on, and
so this method can always return null
. Firstly, some queries do
not operate inside a keyspace: keyspace creation, USE
queries,
user creation, etc. Secondly, even query that operate within a keyspace
do not have to specify said keyspace directly, in which case the
currently logged in keyspace (the one set through a USE
query
(or through the use of Cluster.connect(String)
)). Lastly, as
for the routing key, this keyspace information is only a hint for
token-aware routing (since replica placement depend on the replication
strategy in use which is a per-keyspace property) and having this method
return null
(or even a bogus keyspace name) will never cause the
query to fail.
getKeyspace
in class Statement
null
.public BoundStatement setBool(int i, boolean v)
i
th value to the provided boolean.setBool
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setBool(String name, boolean v)
name
to the
provided boolean.setBool
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setByte(int i, byte v)
i
th value to the provided byte.setByte
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setByte(String name, byte v)
name
to the
provided byte.setByte
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setShort(int i, short v)
i
th value to the provided short.setShort
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setShort(String name, short v)
name
to the
provided short.setShort
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setInt(int i, int v)
i
th value to the provided integer.setInt
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setInt(String name, int v)
name
to the
provided integer.setInt
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setLong(int i, long v)
i
th value to the provided long.setLong
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setLong(String name, long v)
name
to the
provided long.setLong
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.@Deprecated public BoundStatement setDate(int i, Date v)
setTimestamp(int, Date)
i
th value to the provided date.i
- the index of the variable to set.v
- the value to set.IndexOutOfBoundsException
- if i < 0 || i >= this.preparedStatement().variables().size()
.InvalidTypeException
- if column i
is not of type TIMESTAMP.@Deprecated public BoundStatement setDate(String name, Date v)
setTimestamp(String, Date)
name
to the
provided date.name
- the name of the variable to set; if multiple variables
name
are prepared, all of them are set.v
- the value to set.IllegalArgumentException
- if name
is not a prepared
variable, that is, if !this.preparedStatement().variables().names().contains(name)
.InvalidTypeException
- if (any occurrence of) name
is
not of type TIMESTAMP.public BoundStatement setTimestamp(int i, Date v)
i
th value to the provided date.setTimestamp
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setTimestamp(String name, Date v)
name
to the
provided date.setTimestamp
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setDate(int i, LocalDate v)
i
th value to the provided date (without time).setDate
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setDate(String name, LocalDate v)
name
to the
provided date (without time).setDate
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setTime(int i, long v)
i
th value to the provided time as a long in nanoseconds since midnight.setTime
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setTime(String name, long v)
name
to the
provided time as a long in nanoseconds since midnight.setTime
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setFloat(int i, float v)
i
th value to the provided float.setFloat
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setFloat(String name, float v)
name
to the
provided float.setFloat
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setDouble(int i, double v)
i
th value to the provided double.setDouble
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setDouble(String name, double v)
name
to the
provided double.setDouble
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setString(int i, String v)
i
th value to the provided string.setString
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setString(String name, String v)
name
to the
provided string.setString
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setBytes(int i, ByteBuffer v)
i
th value to the provided byte buffer.
This method validate that the type of the column set is BLOB. If you
want to insert manually serialized data into columns of another type,
use SettableByIndexData.setBytesUnsafe(int, java.nio.ByteBuffer)
instead.setBytes
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setBytes(String name, ByteBuffer v)
name
to the
provided byte buffer.
This method validate that the type of the column set is BLOB. If you
want to insert manually serialized data into columns of another type,
use SettableByNameData.setBytesUnsafe(java.lang.String, java.nio.ByteBuffer)
instead.setBytes
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setBytesUnsafe(int i, ByteBuffer v)
i
th value to the provided byte buffer.
Contrary to SettableByIndexData.setBytes(int, java.nio.ByteBuffer)
, this method does not check the
type of the column set. If you insert data that is not compatible with
the type of the column, you will get an InvalidQueryException
at
execute time.setBytesUnsafe
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setBytesUnsafe(String name, ByteBuffer v)
name
to the
provided byte buffer.
Contrary to SettableByNameData.setBytes(java.lang.String, java.nio.ByteBuffer)
, this method does not check the
type of the column set. If you insert data that is not compatible with
the type of the column, you will get an InvalidQueryException
at
execute time.setBytesUnsafe
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setVarint(int i, BigInteger v)
i
th value to the provided big integer.setVarint
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setVarint(String name, BigInteger v)
name
to the
provided big integer.setVarint
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setDecimal(int i, BigDecimal v)
i
th value to the provided big decimal.setDecimal
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setDecimal(String name, BigDecimal v)
name
to the
provided big decimal.setDecimal
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setUUID(int i, UUID v)
i
th value to the provided UUID.setUUID
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setUUID(String name, UUID v)
name
to the
provided UUID.setUUID
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setInet(int i, InetAddress v)
i
th value to the provided inet address.setInet
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setInet(String name, InetAddress v)
name
to the
provided inet address.setInet
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setToken(int i, Token v)
i
th value to the provided Token
.
setPartitionKeyToken(Token)
should generally be preferred if you
have a single token variable.
i
- the index of the variable to set.v
- the value to set.IndexOutOfBoundsException
- if i < 0 || i >= this.preparedStatement().variables().size()
.InvalidTypeException
- if column i
is not of the type of the token's value.public BoundStatement setToken(String name, Token v)
name
to the
provided token.
setPartitionKeyToken(Token)
should generally be preferred if you
have a single token variable.
If you have multiple token variables, use positional binding (setToken(int, Token)
,
or named bind markers:
PreparedStatement pst = session.prepare("SELECT * FROM my_table WHERE token(k) > :min AND token(k) <= :max");
BoundStatement b = pst.bind().setToken("min", minToken).setToken("max", maxToken);
name
- the name of the variable to set; if multiple variables
name
are prepared, all of them are set.v
- the value to set.IllegalArgumentException
- if name
is not a prepared
variable, that is, if !this.preparedStatement().variables().names().contains(name)
.InvalidTypeException
- if (any occurrence of) name
is
not of the type of the token's value.public BoundStatement setPartitionKeyToken(Token v)
partition key token
"
to the provided token (this is the name generated by Cassandra for markers
corresponding to a token(...)
call).
This method is a shorthand for statements with a single token variable:
Token token = ...
PreparedStatement pst = session.prepare("SELECT * FROM my_table WHERE token(k) = ?");
BoundStatement b = pst.bind().setPartitionKeyToken(token);
If you have multiple token variables, use positional binding (setToken(int, Token)
,
or named bind markers:
PreparedStatement pst = session.prepare("SELECT * FROM my_table WHERE token(k) > :min AND token(k) <= :max");
BoundStatement b = pst.bind().setToken("min", minToken).setToken("max", maxToken);
v
- the value to set.IllegalArgumentException
- if name
is not a prepared
variable, that is, if !this.preparedStatement().variables().names().contains(name)
.InvalidTypeException
- if (any occurrence of) name
is
not of the type of the token's value.public <T> BoundStatement setList(int i, List<T> v)
i
th value to the provided list.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method must perform a runtime inspection of the provided list, in order to guess the best codec to serialize the list elements.
Furthermore, if two or more codecs are available
for the underlying CQL type (list
), which one will be used will depend
on the actual object being serialized.
For these reasons, 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<BoundStatement>
i
- the index of the value to set.v
- the value to set.public <E> BoundStatement setList(int i, List<E> v, Class<E> elementsClass)
i
th value to the provided list, whose elements are of the provided
Java class.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the list elements,
and thus should be used instead of SettableByIndexData.setList(int, List)
whenever possible, because it performs significantly better.
setList
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.elementsClass
- the class for the elements of the list.public <E> BoundStatement setList(int i, List<E> v, com.google.common.reflect.TypeToken<E> elementsType)
i
th value to the provided list, whose elements are of the provided
Java type.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the list elements,
and thus should be used instead of SettableByIndexData.setList(int, List)
whenever possible, because it performs significantly better.
setList
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.elementsType
- the type for the elements of the list.public <T> BoundStatement setList(String name, List<T> v)
name
to the
provided list.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method must perform a runtime inspection of the provided list, in order to guess the best codec to serialize the list elements. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available
for the underlying CQL type (list
), which one will be used will depend
on the actual object being serialized.
For these reasons, it is generally preferable to use the more
deterministic methods SettableByNameData.setList(String, List, Class)
or
SettableByNameData.setList(String, List, TypeToken)
.
setList
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public <E> BoundStatement setList(String name, List<E> v, Class<E> elementsClass)
name
to the provided list,
whose elements are of the provided Java class.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the list elements,
and thus should be used instead of SettableByNameData.setList(String, List)
whenever possible, because it performs significantly better.
setList
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiplev
- the value to set.elementsClass
- the class for the elements of the list.public <E> BoundStatement setList(String name, List<E> v, com.google.common.reflect.TypeToken<E> elementsType)
name
to the provided list,
whose elements are of the provided Java type.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the list elements,
and thus should be used instead of SettableByNameData.setList(String, List)
whenever possible, because it performs significantly better.
setList
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiplev
- the value to set.elementsType
- the type for the elements of the list.public <K,V> BoundStatement setMap(int i, Map<K,V> v)
i
th value to the provided map.
Please note that null
values are not supported inside collection by CQL.
Note about performance: this method must perform a runtime inspection of the provided map, in order to guess the best codec to serialize the map entries. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available
for the underlying CQL type (map
), which one will be used will depend
on the actual object being serialized.
For these reasons, 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<BoundStatement>
i
- the index of the value to set.v
- the value to set.public <K,V> BoundStatement setMap(int i, Map<K,V> v, Class<K> keysClass, Class<V> valuesClass)
i
th value to the provided map, whose keys and values are of the provided
Java classes.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the map entries,
and thus should be used instead of SettableByIndexData.setMap(int, Map)
whenever possible, because it performs significantly better.
setMap
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.keysClass
- the class for the keys of the map.valuesClass
- the class for the values of the map.public <K,V> BoundStatement setMap(int i, Map<K,V> v, com.google.common.reflect.TypeToken<K> keysType, com.google.common.reflect.TypeToken<V> valuesType)
i
th value to the provided map, whose keys and values are of the provided
Java types.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the map entries,
and thus should be used instead of SettableByIndexData.setMap(int, Map)
whenever possible, because it performs significantly better.
setMap
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.keysType
- the type for the keys of the map.valuesType
- the type for the values of the map.public <K,V> BoundStatement setMap(String name, Map<K,V> v)
name
to the
provided map.
Please note that null
values are not supported inside collection by CQL.
Note about performance: this method must perform a runtime inspection of the provided map, in order to guess the best codec to serialize the map entries. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available
for the underlying CQL type (map
), which one will be used will depend
on the actual object being serialized.
For these reasons, it is generally preferable to use the more
deterministic methods SettableByNameData.setMap(String, Map, Class, Class)
or
SettableByNameData.setMap(String, Map, TypeToken, TypeToken)
.
setMap
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public <K,V> BoundStatement setMap(String name, Map<K,V> v, Class<K> keysClass, Class<V> valuesClass)
name
to the provided map,
whose keys and values are of the provided Java classes.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the map entries,
and thus should be used instead of SettableByNameData.setMap(String, Map)
whenever possible, because it performs significantly better.
setMap
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.keysClass
- the class for the keys of the map.valuesClass
- the class for the values of the map.public <K,V> BoundStatement setMap(String name, Map<K,V> v, com.google.common.reflect.TypeToken<K> keysType, com.google.common.reflect.TypeToken<V> valuesType)
name
to the provided map,
whose keys and values are of the provided Java types.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the map entries,
and thus should be used instead of SettableByNameData.setMap(String, Map)
whenever possible, because it performs significantly better.
setMap
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.keysType
- the type for the keys of the map.valuesType
- the type for the values of the map.public <T> BoundStatement setSet(int i, Set<T> v)
i
th value to the provided set.
Please note that null
values are not supported inside collection by CQL.
Note about performance: this method must perform a runtime inspection of the provided set, in order to guess the best codec to serialize the set elements. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available
for the underlying CQL type (set
), which one will be used will depend
on the actual object being serialized.
For these reasons, 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<BoundStatement>
i
- the index of the value to set.v
- the value to set.public <E> BoundStatement setSet(int i, Set<E> v, Class<E> elementsClass)
i
th value to the provided set, whose elements are of the provided
Java class.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the set elements,
and thus should be used instead of SettableByIndexData.setSet(int, Set)
whenever possible, because it performs significantly better.
setSet
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.elementsClass
- the class for the elements of the set.public <E> BoundStatement setSet(int i, Set<E> v, com.google.common.reflect.TypeToken<E> elementsType)
i
th value to the provided set, whose elements are of the provided
Java type.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the set elements,
and thus should be used instead of SettableByIndexData.setSet(int, Set)
whenever possible, because it performs significantly better.
setSet
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.elementsType
- the type for the elements of the set.public <T> BoundStatement setSet(String name, Set<T> v)
name
to the
provided set.
Please note that null
values are not supported inside collection by CQL.
Note about performance: this method must perform a runtime inspection of the provided map, in order to guess the best codec to serialize the set elements. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available
for the underlying CQL type (set
), which one will be used will depend
on the actual object being serialized.
For these reasons, it is generally preferable to use the more
deterministic methods SettableByNameData.setSet(String, Set, Class)
or
SettableByNameData.setSet(String, Set, TypeToken)
.
setSet
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public <E> BoundStatement setSet(String name, Set<E> v, Class<E> elementsClass)
name
to the provided set,
whose elements are of the provided Java class.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the set elements,
and thus should be used instead of SettableByNameData.setSet(String, Set)
whenever possible, because it performs significantly better.
setSet
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiplev
- the value to set.elementsClass
- the class for the elements of the set.public <E> BoundStatement setSet(String name, Set<E> v, com.google.common.reflect.TypeToken<E> elementsType)
name
to the provided set,
whose elements are of the provided Java type.
Please note that null
values inside collections are not supported by CQL.
Note about performance: this method is able to cache codecs used to serialize the set elements,
and thus should be used instead of SettableByNameData.setSet(String, Set)
whenever possible, because it performs significantly better.
setSet
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiplev
- the value to set.elementsType
- the type for the elements of the set.public BoundStatement setUDTValue(int i, UDTValue v)
i
th value to the provided UDT value.setUDTValue
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setUDTValue(String name, UDTValue v)
name
to the
provided UDT value.setUDTValue
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public BoundStatement setTupleValue(int i, TupleValue v)
i
th value to the provided tuple value.setTupleValue
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set.public BoundStatement setTupleValue(String name, TupleValue v)
name
to the
provided tuple value.setTupleValue
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set.public <V> BoundStatement setObject(int i, V v)
i
th value to the provided value.
Note about performance: this method must perform a runtime inspection of the provided object, in order to guess the best codec to serialize it. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available for the underlying CQL type, which one will be used will depend on the actual object being serialized.
For these reasons, it is generally preferable to use the more
deterministic methods #set(int, V, Class)
or #set(int, V, TypeToken)
instead.
setObject
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.v
- the value to set; may be null
.public <V> BoundStatement setObject(String name, V v)
name
to the provided value.
Note about performance: this method must perform a runtime inspection of the provided object, in order to guess the best codec to serialize it. The result of such inspection cannot be cached and thus must be performed for each invocation of this method, which may incur in a performance penalty.
Furthermore, if two or more codecs are available for the underlying CQL type, which one will be used will depend on the actual object being serialized.
For these reasons, it is generally preferable to use the more
deterministic methods #set(String, V, Class)
or #set(String, V, TypeToken)
instead.
setObject
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set; may be null
.public <V> BoundStatement set(int i, V v, Class<V> targetClass)
i
th value to the provided value of the provided Java class.
A suitable TypeCodec
instance for the underlying CQL type and the provided class must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of SettableByIndexData.setObject(int, Object)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
set
in interface SettableByIndexData<BoundStatement>
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> BoundStatement set(String name, V v, Class<V> targetClass)
name
to the provided value of the provided Java class.
A suitable TypeCodec
instance for the underlying CQL type and the provided class must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of SettableByNameData.setObject(String, Object)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
set
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set; may be null
.targetClass
- The Java class to convert to; must not be null
;public <V> BoundStatement set(int i, V v, com.google.common.reflect.TypeToken<V> targetType)
i
th value to the provided value of the provided Java type.
A suitable TypeCodec
instance for the underlying CQL type and the provided class must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of SettableByIndexData.setObject(int, Object)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
set
in interface SettableByIndexData<BoundStatement>
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> BoundStatement set(String name, V v, com.google.common.reflect.TypeToken<V> targetType)
name
to the provided value of the provided Java type.
A suitable TypeCodec
instance for the underlying CQL type and the provided class must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of SettableByNameData.setObject(String, Object)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
set
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set; may be null
.targetType
- The Java type to convert to; must not be null
;public <V> BoundStatement set(int i, V v, TypeCodec<V> codec)
i
th value to the provided value, converted using the given TypeCodec
.
Note that this method allows to entirely bypass the CodecRegistry
currently in use
and forces the driver to use the given codec instead.
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<BoundStatement>
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 <V> BoundStatement set(String name, V v, TypeCodec<V> codec)
name
to the provided value,
converted using the given TypeCodec
.
Note that this method allows to entirely bypass the CodecRegistry
currently in use
and forces the driver to use the given codec instead.
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 SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.v
- the value to set; may be null
.codec
- The TypeCodec
to use to serialize the value; may not be null
.public BoundStatement setToNull(int i)
i
th value to null
.
This is mainly intended for CQL types which map to native Java types.
setToNull
in interface SettableByIndexData<BoundStatement>
i
- the index of the value to set.public BoundStatement setToNull(String name)
name
to null
.
This is mainly intended for CQL types which map to native Java types.
setToNull
in interface SettableByNameData<BoundStatement>
name
- the name of the value to set; if name
is present multiple
times, all its values are set.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 isNull(String name)
name
is NULL.isNull
in interface GettableByNameData
name
- the name to check.name
is NULL.public boolean getBool(int i)
i
th value as a boolean.getBool
in interface GettableByIndexData
i
- the index (0 <= i < size()
) to retrieve.i
th element. If the
value is NULL, false
is returned.public boolean getBool(String name)
name
as a boolean.getBool
in interface GettableByNameData
name
- the name to retrieve.name
. If the value is NULL,
false
is returned.public byte getByte(int i)
i
th value as a byte.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.public byte getByte(String name)
name
as a byte.getByte
in interface GettableByNameData
name
- the name to retrieve.name
as a byte. If the value is NULL,
0
is returned.public short getShort(int i)
i
th value as a short.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.public short getShort(String name)
name
as a short.getShort
in interface GettableByNameData
name
- the name to retrieve.name
as a short. If the value is NULL,
0
is returned.public int getInt(int i)
i
th value as an integer.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.public int getInt(String name)
name
as an integer.getInt
in interface GettableByNameData
name
- the name to retrieve.name
as an integer. If the value is NULL,
0
is returned.public long getLong(int i)
i
th value as a long.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.public long getLong(String name)
name
as a long.getLong
in interface GettableByNameData
name
- the name to retrieve.name
as a long. If the value is NULL,
0L
is returned.public Date getTimestamp(int i)
i
th value as a date.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 Date getTimestamp(String name)
name
as a date.getTimestamp
in interface GettableByNameData
name
- the name to retrieve.name
as a date. If the value is NULL,
null
is returned.public LocalDate getDate(int i)
i
th value as a date (without time).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 LocalDate getDate(String name)
name
as a date (without time).getDate
in interface GettableByNameData
name
- the name to retrieve.name
as a date. If the value is NULL,
null
is returned.public long getTime(int i)
i
th value as a long in nanoseconds since midnight.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 long getTime(String name)
name
as a long in nanoseconds since midnight.getTime
in interface GettableByNameData
name
- the name to retrieve.name
as a long. If the value is NULL,
0L
is returned.public float getFloat(int i)
i
th value as a float.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.public float getFloat(String name)
name
as a float.getFloat
in interface GettableByNameData
name
- the name to retrieve.name
as a float. If the value is NULL,
0.0f
is returned.public double getDouble(int i)
i
th value as a double.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.public double getDouble(String name)
name
as a double.getDouble
in interface GettableByNameData
name
- the name to retrieve.name
as a double. If the value is NULL,
0.0
is returned.public ByteBuffer getBytesUnsafe(int i)
i
th 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.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 getBytesUnsafe(String name)
name
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.getBytesUnsafe
in interface GettableByNameData
name
- the name to retrieve.name
as a ByteBuffer. If the value is NULL,
null
is returned.public ByteBuffer getBytes(int i)
i
th 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 GettableByIndexData.getBytesUnsafe(int)
instead.
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 ByteBuffer getBytes(String name)
name
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 GettableByNameData.getBytesUnsafe(String)
instead.
getBytes
in interface GettableByNameData
name
- the name to retrieve.name
as a byte array. If the value is NULL,
null
is returned.public String getString(int i)
i
th value as a string.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 String getString(String name)
name
as a string.getString
in interface GettableByNameData
name
- the name to retrieve.name
as a string. If the value is NULL,
null
is returned.public BigInteger getVarint(int i)
i
th value as a variable length integer.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 BigInteger getVarint(String name)
name
as a variable length integer.getVarint
in interface GettableByNameData
name
- the name to retrieve.name
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.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 BigDecimal getDecimal(String name)
name
as a variable length decimal.getDecimal
in interface GettableByNameData
name
- the name to retrieve.name
as a variable length decimal.
If the value is NULL, null
is returned.public UUID getUUID(int i)
i
th value as a UUID.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 UUID getUUID(String name)
name
as a UUID.getUUID
in interface GettableByNameData
name
- the name to retrieve.name
as a UUID.
If the value is NULL, null
is returned.public InetAddress getInet(int i)
i
th value as an InetAddress.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 InetAddress getInet(String name)
name
as an InetAddress.getInet
in interface GettableByNameData
name
- the name to retrieve.name
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.
If the type of the elements is generic, use GettableByIndexData.getList(int, TypeToken)
.
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. 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.public <T> List<T> getList(int i, com.google.common.reflect.TypeToken<T> elementsType)
i
th 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>>() {});
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. 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.public <T> List<T> getList(String name, Class<T> elementsClass)
name
as a list.
If the type of the elements is generic, use GettableByNameData.getList(String, TypeToken)
.
getList
in interface GettableByNameData
name
- the name to retrieve.elementsClass
- the class for the elements of the list to retrieve.i
th 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.public <T> List<T> getList(String name, com.google.common.reflect.TypeToken<T> elementsType)
name
as a list.
Use this variant with nested collections, which produce a generic element type:
List<List<String>> l = row.getList("theColumn", new TypeToken<List<String>>() {});
getList
in interface GettableByNameData
name
- the name to retrieve.elementsType
- the type for the elements of the list to retrieve.i
th 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.public <T> Set<T> getSet(int i, Class<T> elementsClass)
i
th value as a set.
If the type of the elements is generic, use GettableByIndexData.getSet(int, TypeToken)
.
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. 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.public <T> Set<T> getSet(int i, com.google.common.reflect.TypeToken<T> elementsType)
i
th 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>>() {});
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. 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.public <T> Set<T> getSet(String name, Class<T> elementsClass)
name
as a set.
If the type of the elements is generic, use GettableByNameData.getSet(String, TypeToken)
.
getSet
in interface GettableByNameData
name
- the name to retrieve.elementsClass
- the class for the elements of the set to retrieve.i
th 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.public <T> Set<T> getSet(String name, com.google.common.reflect.TypeToken<T> elementsType)
name
as a set.
Use this variant with nested collections, which produce a generic element type:
Set<List<String>> l = row.getSet("theColumn", new TypeToken<List<String>>() {});
getSet
in interface GettableByNameData
name
- the name to retrieve.elementsType
- the type for the elements of the set to retrieve.i
th 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.public <K,V> Map<K,V> getMap(int i, Class<K> keysClass, Class<V> valuesClass)
i
th value as a map.
If the type of the keys and/or values is generic, use GettableByIndexData.getMap(int, TypeToken, TypeToken)
.
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. 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.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.
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>>() {});
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. 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.public <K,V> Map<K,V> getMap(String name, Class<K> keysClass, Class<V> valuesClass)
name
as a map.
If the type of the keys and/or values is generic, use GettableByNameData.getMap(String, TypeToken, TypeToken)
.
getMap
in interface GettableByNameData
name
- the name to retrieve.keysClass
- the class for the keys of the map to retrieve.valuesClass
- the class for the values of the map to retrieve.name
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.public <K,V> Map<K,V> getMap(String name, com.google.common.reflect.TypeToken<K> keysType, com.google.common.reflect.TypeToken<V> valuesType)
name
as a map.
Use this variant with nested collections, which produce a generic element type:
Map<Int, List<String>> l = row.getMap("theColumn", TypeToken.of(Integer.class), new TypeToken<List<String>>() {});
getMap
in interface GettableByNameData
name
- the name to retrieve.keysType
- the class for the keys of the map to retrieve.valuesType
- the class for the values of the map to retrieve.name
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.public UDTValue getUDTValue(int i)
i
th value as a UDT value.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 UDTValue getUDTValue(String name)
name
as a UDT value.getUDTValue
in interface GettableByNameData
name
- the name to retrieve.name
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.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 TupleValue getTupleValue(String name)
name
as a tuple value.getTupleValue
in interface GettableByNameData
name
- the name to retrieve.name
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 default codec for the underlying CQL type
to perform deserialization, and is safe to be used
as long as only default codecs are in use.
If a second, custom codec for the same CQL type is registered, which one will
be used is unspecified; in such cases, it is preferable to use
the more deterministic methods GettableByIndexData.get(int, Class)
or GettableByIndexData.get(int, TypeToken)
instead.
getObject
in interface GettableByIndexData
i
- the index to retrieve.i
th 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.public Object getObject(String name)
name
as the Java type matching its CQL type.
This method uses the default codec for the underlying CQL type
to perform deserialization, and is safe to be used
as long as only default codecs are in use.
If a second, custom codec for the same CQL type is registered, which one will
be used is unspecified; in such cases, it is preferable to use
the more deterministic methods GettableByNameData.get(String, Class)
or GettableByNameData.get(String, TypeToken)
instead.
getObject
in interface GettableByNameData
name
- the name to retrieve.i
th 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.public <T> T get(int i, Class<T> targetClass)
i
th value converted to the given Java type.
A suitable TypeCodec
instance for the underlying CQL type and targetClass
must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of GettableByIndexData.getObject(int)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
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.
If the CQL value is NULL
, this method will return null
for a simple type, UDT or tuple, and an empty (immutable) collection for collection types.public <T> T get(String name, Class<T> targetClass)
name
converted to the given Java type.
A suitable TypeCodec
instance for for the underlying CQL type and targetClass
must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of GettableByNameData.getObject(String)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
get
in interface GettableByNameData
name
- the name to retrieve.targetClass
- The Java type the value should be converted to.name
value converted to the given Java type.
If the CQL value is NULL
, then null
is returned.public <T> T get(int i, com.google.common.reflect.TypeToken<T> targetType)
i
th value converted to the given Java type.
A suitable TypeCodec
instance for the underlying CQL type and targetType
must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of GettableByIndexData.getObject(int)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
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.
If the CQL value is NULL
, the default set of codecs will return null
for a simple type, UDT or tuple, and an empty (immutable) collection for collection types.public <T> T get(String name, com.google.common.reflect.TypeToken<T> targetType)
name
converted to the given Java type.
A suitable TypeCodec
instance for for the underlying CQL type and targetType
must
have been previously registered with the CodecRegistry
currently in use.
This method should be used instead of GettableByNameData.getObject(String)
in cases
where more than one codec is registered for the same CQL type; specifying the Java class
allows the CodecRegistry
to narrow down the search and return only an exactly-matching codec (if any),
thus avoiding any risk of ambiguity.
get
in interface GettableByNameData
name
- the name to retrieve.targetType
- The Java type the value should be converted to.name
value converted to the given Java type.
If the CQL value is NULL
, then null
is returned.public <T> T get(int i, TypeCodec<T> codec)
i
th value converted using the given TypeCodec
.
Note that this method allows to entirely bypass the CodecRegistry
currently in use
and forces the driver to use the given codec instead.
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.
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
.public <T> T get(String name, TypeCodec<T> codec)
name
converted using the given TypeCodec
.
Note that this method allows to entirely bypass the CodecRegistry
currently in use
and forces the driver to use the given codec instead.
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.
get
in interface GettableByNameData
name
- the name to retrieve.codec
- The TypeCodec
to use to deserialize the value; may not be null
.i
th value converted using the given TypeCodec
.Copyright © 2012–2015. All rights reserved.