public class BoundStatement extends Statement implements SettableData<BoundStatement>, GettableData
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| 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.
|
boolean |
getBool(int i)
Returns the
ith value as a boolean. |
boolean |
getBool(String name)
Returns the value for
name as a boolean. |
ByteBuffer |
getBytes(int i)
Returns the
ith value as a byte array. |
ByteBuffer |
getBytes(String name)
Returns the value for
name as a byte array. |
ByteBuffer |
getBytesUnsafe(int i)
Returns the
ith value as a ByteBuffer. |
ByteBuffer |
getBytesUnsafe(String name)
Returns the value for
name as a ByteBuffer. |
Date |
getDate(int i)
Returns the
ith value as a date. |
Date |
getDate(String name)
Returns the value for
name as a date. |
BigDecimal |
getDecimal(int i)
Returns the
ith 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
ith value as a double. |
double |
getDouble(String name)
Returns the value for
name as a double. |
float |
getFloat(int i)
Returns the
ith value as a float. |
float |
getFloat(String name)
Returns the value for
name as a float. |
InetAddress |
getInet(int i)
Returns the
ith value as an InetAddress. |
InetAddress |
getInet(String name)
Returns the value for
name as an InetAddress. |
int |
getInt(int i)
Returns the
ith 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
ith value as a list. |
<T> List<T> |
getList(int i,
TypeToken<T> elementsType)
Returns the
ith 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,
TypeToken<T> elementsType)
Returns the value for
name as a list. |
long |
getLong(int i)
Returns the
ith 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
ith value as a map. |
<K,V> Map<K,V> |
getMap(int i,
TypeToken<K> keysType,
TypeToken<V> valuesType)
Returns the
ith value as a map. |
<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,
TypeToken<K> keysType,
TypeToken<V> valuesType)
Returns the value for
name as a map. |
Object |
getObject(int i)
Returns the
ith 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
ith value as a set. |
<T> Set<T> |
getSet(int i,
TypeToken<T> elementsType)
Returns the
ith 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,
TypeToken<T> elementsType)
Returns the value for
name as a set. |
String |
getString(int i)
Returns the
ith value as a string. |
String |
getString(String name)
Returns the value for
name as a string. |
TupleValue |
getTupleValue(int i)
Return the
ith value as a tuple value. |
TupleValue |
getTupleValue(String name)
Return the value for
name as a tuple value. |
UDTValue |
getUDTValue(int i)
Return the
ith value as a UDT value. |
UDTValue |
getUDTValue(String name)
Return the value for
name as a UDT value. |
UUID |
getUUID(int i)
Returns the
ith value as a UUID. |
UUID |
getUUID(String name)
Returns the value for
name as a UUID. |
BigInteger |
getVarint(int i)
Returns the
ith 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
ith value is NULL. |
boolean |
isNull(String name)
Returns whether the value for
name is NULL. |
boolean |
isSet(int i)
Returns whether the
ith 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.
|
BoundStatement |
setBool(int i,
boolean v)
Sets the
ith 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 |
setBytes(int i,
ByteBuffer v)
Sets the
ith 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
ith 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)
Set the
ith value to the provided date. |
BoundStatement |
setDate(String name,
Date v)
Sets the value for (all occurrences of) variable
name to the
provided date. |
BoundStatement |
setDecimal(int i,
BigDecimal v)
Sets the
ith 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
ith 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
ith 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
ith 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
ith value to the provided integer. |
BoundStatement |
setInt(String name,
int v)
Sets the value for (all occurrences of) variable
name to the
provided integer. |
<T> BoundStatement |
setList(int i,
List<T> v)
Sets the
ith value to the provided list. |
<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
ith 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
ith value to the provided map. |
<K,V> BoundStatement |
setMap(String name,
Map<K,V> v)
Sets the value for (all occurrences of) variable
name to the
provided map. |
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.
|
<T> BoundStatement |
setSet(int i,
Set<T> v)
Sets the
ith value to the provided set. |
<T> BoundStatement |
setSet(String name,
Set<T> v)
Sets the value for (all occurrences of) variable
name to the
provided set. |
BoundStatement |
setString(int i,
String v)
Sets the
ith 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 |
setToken(int i,
Token v)
Sets the
ith 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
ith 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
ith 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
ith 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
ith 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
ith 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, setPagingState, setPagingStateUnsafe, setRetryPolicy, setSerialConsistencyLevelpublic 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)
ith variable has been bound.i - the index of the variable to check.ith 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 BoundStatement setRoutingKey(ByteBuffer routingKey)
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 ByteBuffer getRoutingKey()
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 Statementnull.public String getKeyspace()
null value (unless the statement
has no variables, but you should avoid prepared statement in the first in that
case). The keyspace returned will be the one corresponding to the first
variable prepared in this statement (which in almost all case will be the
keyspace for the operation, though it's possible in CQL to build a batch
statement that acts on multiple keyspace).getKeyspace in class Statementnull if the
statement has no variables.public BoundStatement setBool(int i, boolean v)
ith value to the provided boolean.setBool in interface SettableByIndexData<BoundStatement>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 BOOLEAN.public BoundStatement setBool(String name, boolean v)
name to the
provided boolean.setBool in interface SettableByNameData<BoundStatement>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 one occurrence of) name is not of type BOOLEAN.public BoundStatement setInt(int i, int v)
ith value to the provided integer.setInt in interface SettableByIndexData<BoundStatement>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 INT.public BoundStatement setInt(String name, int v)
name to the
provided integer.setInt in interface SettableByNameData<BoundStatement>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 one occurrence of) name is not of type INT.public BoundStatement setLong(int i, long v)
ith value to the provided long.setLong in interface SettableByIndexData<BoundStatement>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 BIGINT or COUNTER.public BoundStatement setLong(String name, long v)
name to the
provided long.setLong in interface SettableByNameData<BoundStatement>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 BIGINT or COUNTER.public BoundStatement setDate(int i, Date v)
ith value to the provided date.setDate in interface SettableByIndexData<BoundStatement>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.public BoundStatement setDate(String name, Date v)
name to the
provided date.setDate in interface SettableByNameData<BoundStatement>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 setFloat(int i, float v)
ith value to the provided float.setFloat in interface SettableByIndexData<BoundStatement>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 FLOAT.public BoundStatement setFloat(String name, float v)
name to the
provided float.setFloat in interface SettableByNameData<BoundStatement>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 FLOAT.public BoundStatement setDouble(int i, double v)
ith value to the provided double.setDouble in interface SettableByIndexData<BoundStatement>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 DOUBLE.public BoundStatement setDouble(String name, double v)
name to the
provided double.setDouble in interface SettableByNameData<BoundStatement>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 DOUBLE.public BoundStatement setString(int i, String v)
ith value to the provided string.setString in interface SettableByIndexData<BoundStatement>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 of neither of the
following types: VARCHAR, TEXT or ASCII.public BoundStatement setString(String name, String v)
name to the
provided string.setString in interface SettableByNameData<BoundStatement>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
of neither of the following types: VARCHAR, TEXT or ASCII.public BoundStatement setBytes(int i, ByteBuffer v)
ith 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 setBytesUnsafe(int, java.nio.ByteBuffer) instead.setBytes in interface SettableByIndexData<BoundStatement>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 BLOB.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 setBytesUnsafe(int, java.nio.ByteBuffer) instead.setBytes in interface SettableByNameData<BoundStatement>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 BLOB.public BoundStatement setBytesUnsafe(int i, ByteBuffer v)
ith value to the provided byte buffer.
Contrary to 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 variable to set.v - the value to set.IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().public BoundStatement setBytesUnsafe(String name, ByteBuffer v)
name to the
provided byte buffer.
Contrary to 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 SettableByNameData<BoundStatement>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).public BoundStatement setVarint(int i, BigInteger v)
ith value to the provided big integer.setVarint in interface SettableByIndexData<BoundStatement>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 VARINT.public BoundStatement setVarint(String name, BigInteger v)
name to the
provided big integer.setVarint in interface SettableByNameData<BoundStatement>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 VARINT.public BoundStatement setDecimal(int i, BigDecimal v)
ith value to the provided big decimal.setDecimal in interface SettableByIndexData<BoundStatement>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 DECIMAL.public BoundStatement setDecimal(String name, BigDecimal v)
name to the
provided big decimal.setDecimal in interface SettableByNameData<BoundStatement>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 DECIMAL.public BoundStatement setUUID(int i, UUID v)
ith value to the provided UUID.setUUID in interface SettableByIndexData<BoundStatement>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 UUID or
TIMEUUID, or if column i is of type TIMEUUID but v is
not a type 1 UUID.public BoundStatement setUUID(String name, UUID v)
name to the
provided UUID.setUUID in interface SettableByNameData<BoundStatement>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 UUID or TIMEUUID, or if column name is of type
TIMEUUID but v is not a type 1 UUID.public BoundStatement setInet(int i, InetAddress v)
ith value to the provided inet address.setInet in interface SettableByIndexData<BoundStatement>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 INET.public BoundStatement setInet(String name, InetAddress v)
name to the
provided inet address.setInet in interface SettableByNameData<BoundStatement>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 INET.public BoundStatement setToken(int i, Token v)
ith 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)
ith value to the provided list.
Please note that null values are not supported inside collection by CQL.setList in interface SettableByIndexData<BoundStatement>T - the type of the elements of the list to set.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 a list type or
if the elements of v are not of the type of the elements of
column i.NullPointerException - if v contains null values. Nulls are not supported in collections
by CQL.public <T> BoundStatement setList(String name, List<T> v)
name to the
provided list.
Please note that null values are not supported inside collection by CQL.setList in interface SettableByNameData<BoundStatement>T - the type of the elements of the list to set.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 a list type or if the elements of v are not of the type of
the elements of column name.NullPointerException - if v contains null values. Nulls are not supported in collections
by CQL.public <K,V> BoundStatement setMap(int i, Map<K,V> v)
ith value to the provided map.
Please note that null values are not supported inside collection by CQL.setMap in interface SettableByIndexData<BoundStatement>K - the type of the keys for the map to set.V - the type of the values for the map to set.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 a map type or
if the elements (keys or values) of v are not of the type of the
elements of column i.NullPointerException - if v contains null values. Nulls are not supported in collections
by CQL.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.setMap in interface SettableByNameData<BoundStatement>K - the type of the keys for the map to set.V - the type of the values for the map to set.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 a map type or if the elements (keys or values) of v are not of
the type of the elements of column name.NullPointerException - if v contains null values. Nulls are not supported in collections
by CQL.public <T> BoundStatement setSet(int i, Set<T> v)
ith value to the provided set.
Please note that null values are not supported inside collection by CQL.setSet in interface SettableByIndexData<BoundStatement>T - the type of the elements of the set to set.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 a set type or
if the elements of v are not of the type of the elements of
column i.NullPointerException - if v contains null values. Nulls are not supported in collections
by CQL.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.setSet in interface SettableByNameData<BoundStatement>T - the type of the elements of the set to set.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 a map type or if the elements of v are not of the type of
the elements of column name.NullPointerException - if v contains null values. Nulls are not supported in collections
by CQL.public BoundStatement setUDTValue(int i, UDTValue v)
ith value to the provided UDT value.setUDTValue in interface SettableByIndexData<BoundStatement>i - the index of the value to set.v - the value to set.IndexOutOfBoundsException - if i is not a valid index for this BoundStatement.InvalidTypeException - if value i is not a UDT value or if its definition
does not correspond to the one of v.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.IllegalArgumentException - if name is not a valid name for this BoundStatement.InvalidTypeException - if (any occurrence of) name is
not a UDT value or if the definition of column name does not correspond to
the one of v.public BoundStatement setTupleValue(int i, TupleValue v)
ith value to the provided tuple value.setTupleValue in interface SettableByIndexData<BoundStatement>i - the index of the value to set.v - the value to set.IndexOutOfBoundsException - if i is not a valid index for this BoundStatement.InvalidTypeException - if value i is not a tuple value or if its types
do not correspond to the ones of v.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.IllegalArgumentException - if name is not a valid name for this BoundStatement.InvalidTypeException - if (any occurrence of) name is
not a tuple value or if the types of column name do not correspond to
the ones of v.public BoundStatement setToNull(int i)
ith 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.IndexOutOfBoundsException - if i is not a valid index for this object.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.IllegalArgumentException - if name is not a valid name for this object.public boolean isNull(int i)
ith value is NULL.isNull in interface GettableByIndexDatai - the index (0 <= i < size()) of the value to check.ith value is NULL.public boolean isNull(String name)
name is NULL.isNull in interface GettableByNameDataname - the name to check.name is NULL.public boolean getBool(int i)
ith value as a boolean.getBool in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith element. If the
value is NULL, false is returned.public boolean getBool(String name)
name as a boolean.getBool in interface GettableByNameDataname - the name to retrieve.name. If the value is NULL,
false is returned.public int getInt(int i)
ith value as an integer.getInt in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith element as an integer. If the
value is NULL, 0 is returned.public int getInt(String name)
name as an integer.getInt in interface GettableByNameDataname - the name to retrieve.name as an integer. If the value is NULL,
0 is returned.public long getLong(int i)
ith value as a long.getLong in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith element as a long. If the
value is NULL, 0L is returned.public long getLong(String name)
name as a long.getLong in interface GettableByNameDataname - the name to retrieve.name as a long. If the value is NULL,
0L is returned.public Date getDate(int i)
ith value as a date.getDate in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith element as a data. If the
value is NULL, null is returned.public Date getDate(String name)
name as a date.getDate in interface GettableByNameDataname - the name to retrieve.name as a date. If the value is NULL,
null is returned.public float getFloat(int i)
ith value as a float.getFloat in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith 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 GettableByNameDataname - the name to retrieve.name as a float. If the value is NULL,
0.0f is returned.public double getDouble(int i)
ith value as a double.getDouble in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith 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 GettableByNameDataname - the name to retrieve.name as a double. If the value is NULL,
0.0 is returned.public ByteBuffer getBytesUnsafe(int i)
ith value as a ByteBuffer.
Note: this method always return the bytes composing the value, even if
the column is not of type BLOB. That is, this method never throw an
InvalidTypeException. However, if the type is not BLOB, it is up to the
caller to handle the returned value correctly.getBytesUnsafe in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith 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 GettableByNameDataname - the name to retrieve.name as a ByteBuffer. If the value is NULL,
null is returned.public ByteBuffer getBytes(int i)
ith value as a byte array.
Note that this method validate that the column is of type BLOB. If you want to retrieve
the bytes for any type, use GettableByIndexData.getBytesUnsafe(int) instead.getBytes in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith 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 GettableByNameDataname - the name to retrieve.name as a byte array. If the value is NULL,
null is returned.public String getString(int i)
ith value as a string.getString in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith element as a string. If the
value is NULL, null is returned.public String getString(String name)
name as a string.getString in interface GettableByNameDataname - the name to retrieve.name as a string. If the value is NULL,
null is returned.public BigInteger getVarint(int i)
ith value as a variable length integer.getVarint in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith 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 GettableByNameDataname - the name to retrieve.name as a variable length integer.
If the value is NULL, null is returned.public BigDecimal getDecimal(int i)
ith value as a variable length decimal.getDecimal in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith 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 GettableByNameDataname - the name to retrieve.name as a variable length decimal.
If the value is NULL, null is returned.public UUID getUUID(int i)
ith value as a UUID.getUUID in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith element as a UUID.
If the value is NULL, null is returned.public UUID getUUID(String name)
name as a UUID.getUUID in interface GettableByNameDataname - the name to retrieve.name as a UUID.
If the value is NULL, null is returned.public InetAddress getInet(int i)
ith value as an InetAddress.getInet in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith element as an InetAddress.
If the value is NULL, null is returned.public InetAddress getInet(String name)
name as an InetAddress.getInet in interface GettableByNameDataname - 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)
ith value as a list.
If the type of the elements is generic, use GettableByIndexData.getList(int, TypeToken).getList in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.elementsClass - the class for the elements of the list to retrieve.ith element as a list of
T objects. If the value is NULL, an empty list is
returned (note that Cassandra makes no difference between an empty list
and column of type list that is not set). The returned list is immutable.public <T> List<T> getList(int i, TypeToken<T> elementsType)
ith value as a list.
Use this variant with nested collections, which produce a generic element type:
List<List<String>> l = row.getList(1, new TypeToken<List<String>>() {});
getList in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.elementsType - the type of the elements of the list to retrieve.ith element as a list of
T objects. If the value is NULL, an empty list is
returned (note that Cassandra makes no difference between an empty list
and column of type list that is not set). The returned list is immutable.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 GettableByNameDataname - the name to retrieve.elementsClass - the class for the elements of the list to retrieve.ith element as a list of
T objects. If the value is NULL, an empty list is
returned (note that Cassandra makes no difference between an empty list
and column of type list that is not set). The returned list is immutable.public <T> List<T> getList(String name, 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 GettableByNameDataname - the name to retrieve.elementsType - the type for the elements of the list to retrieve.ith element as a list of
T objects. If the value is NULL, an empty list is
returned (note that Cassandra makes no difference between an empty list
and column of type list that is not set). The returned list is immutable.public <T> Set<T> getSet(int i, Class<T> elementsClass)
ith value as a set.
If the type of the elements is generic, use GettableByIndexData.getSet(int, TypeToken).getSet in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.elementsClass - the class for the elements of the set to retrieve.ith element as a set of
T objects. If the value is NULL, an empty set is
returned (note that Cassandra makes no difference between an empty set
and column of type set that is not set). The returned set is immutable.public <T> Set<T> getSet(int i, TypeToken<T> elementsType)
ith value as a set.
Use this variant with nested collections, which produce a generic element type:
Set<List<String>> l = row.getSet(1, new TypeToken<List<String>>() {});
getSet in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.elementsType - the type for the elements of the set to retrieve.ith element as a set of
T objects. If the value is NULL, an empty set is
returned (note that Cassandra makes no difference between an empty set
and column of type set that is not set). The returned set is immutable.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 GettableByNameDataname - the name to retrieve.elementsClass - the class for the elements of the set to retrieve.ith element as a set of
T objects. If the value is NULL, an empty set is
returned (note that Cassandra makes no difference between an empty set
and column of type set that is not set). The returned set is immutable.public <T> Set<T> getSet(String name, 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 GettableByNameDataname - the name to retrieve.elementsType - the type for the elements of the set to retrieve.ith element as a set of
T objects. If the value is NULL, an empty set is
returned (note that Cassandra makes no difference between an empty set
and column of type set that is not set). The returned set is immutable.public <K,V> Map<K,V> getMap(int i, Class<K> keysClass, Class<V> valuesClass)
ith value as a map.
If the type of the keys and/or values is generic, use GettableByIndexData.getMap(int, TypeToken, TypeToken).getMap in interface GettableByIndexDatai - 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.ith element as a map of
K to V objects. If the value is NULL,
an empty map is returned (note that Cassandra makes no difference
between an empty map and column of type map that is not set). The
returned map is immutable.public <K,V> Map<K,V> getMap(int i, TypeToken<K> keysType, TypeToken<V> valuesType)
ith value as a map.
Use this variant with nested collections, which produce a generic element type:
Map<Int, List<String>> l = row.getMap(1, TypeToken.of(Integer.class), new TypeToken<List<String>>() {});
getMap in interface GettableByIndexDatai - 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.ith element as a map of
K to V objects. If the value is NULL,
an empty map is returned (note that Cassandra makes no difference
between an empty map and column of type map that is not set). The
returned map is immutable.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 GettableByNameDataname - 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, TypeToken<K> keysType, 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 GettableByNameDataname - 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)
ith value as a UDT value.getUDTValue in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith 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 GettableByNameDataname - the name to retrieve.name as a UDT value. If the value is NULL,
then null will be returned.public TupleValue getTupleValue(int i)
ith value as a tuple value.getTupleValue in interface GettableByIndexDatai - the index (0 <= i < size()) to retrieve.ith 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 GettableByNameDataname - the name to retrieve.name as a tuple value. If the value is NULL,
then null will be returned.public Object getObject(int i)
ith value as the Java type matching its CQL type.getObject in interface GettableByIndexDatai - the index to retrieve.ith value as the Java type matching its CQL type.
If the value is NULL and is a simple type, UDT or tuple, null is returned.
If it is NULL and is a collection type, an empty (immutable) collection is returned.public Object getObject(String name)
name as the Java type matching its CQL type.getObject in interface GettableByNameDataname - the name to retrieve.ith value as the Java type matching its CQL type.
If the value is NULL and is a simple type, UDT or tuple, null is returned.
If it is NULL and is a collection type, an empty (immutable) collection is returned.