Class BoundStatement
- java.lang.Object
-
- com.datastax.driver.core.Statement
-
- com.datastax.driver.core.BoundStatement
-
- All Implemented Interfaces:
GettableByIndexData,GettableByNameData,GettableData,SettableByIndexData<BoundStatement>,SettableByNameData<BoundStatement>,SettableData<BoundStatement>
public class BoundStatement extends Statement implements SettableData<BoundStatement>, GettableData
A prepared statement with values bound to the bind variables.Once values has been provided for the variables of the
PreparedStatementit has been created from, such BoundStatement can be executed (throughSession.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
ColumnDefinitionsbut with the difference that if multiple bind variables have the same name, setting that name will set all the variables for that name.With native protocol V3 or below, all variables of the statement must be bound. If you don't explicitly set a value for a variable, an
IllegalStateExceptionwill be thrown when submitting the statement. If you want to set a variable tonull, usesetToNull.With native protocol V4 or above, variables can be left unset, in which case they will be ignored server side (no tombstones will be generated). If you're reusing a bound statement, you can
unsetvariables that were previously set.This class is not thread-safe. Do not share instances among requests that will execute concurrently (e.g. requests run from separate application threads, but also separate
executeAsynccalls, even if they're triggered from the same thread).
-
-
Field Summary
-
Fields inherited from class com.datastax.driver.core.Statement
idempotent, NULL_PAYLOAD_VALUE
-
-
Constructor Summary
Constructors Constructor Description BoundStatement(PreparedStatement statement)Creates a newBoundStatementfrom the provided prepared statement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BoundStatementbind(Object... values)Bound values to the variables of this statement.<T> Tget(int i, TypeCodec<T> codec)Returns theith value converted using the givenTypeCodec.<T> Tget(int i, TypeToken<T> targetType)Returns theith value converted to the given Java type.<T> Tget(int i, Class<T> targetClass)Returns theith value converted to the given Java type.<T> Tget(String name, TypeCodec<T> codec)Returns the value fornameconverted using the givenTypeCodec.<T> Tget(String name, TypeToken<T> targetType)Returns the value fornameconverted to the given Java type.<T> Tget(String name, Class<T> targetClass)Returns the value fornameconverted to the given Java type.booleangetBool(int i)Returns theith value as a boolean.booleangetBool(String name)Returns the value fornameas a boolean.bytegetByte(int i)Returns theith value as a byte.bytegetByte(String name)Returns the value fornameas a byte.ByteBuffergetBytes(int i)Returns theith value as a byte array.ByteBuffergetBytes(String name)Returns the value fornameas a byte array.ByteBuffergetBytesUnsafe(int i)Returns theith value as aByteBuffer.ByteBuffergetBytesUnsafe(String name)Returns the value fornameas a ByteBuffer.LocalDategetDate(int i)Returns theith value as a date (without time).LocalDategetDate(String name)Returns the value fornameas a date (without time).BigDecimalgetDecimal(int i)Returns theith value as a variable length decimal.BigDecimalgetDecimal(String name)Returns the value fornameas a variable length decimal.doublegetDouble(int i)Returns theith value as a double.doublegetDouble(String name)Returns the value fornameas a double.floatgetFloat(int i)Returns theith value as a float.floatgetFloat(String name)Returns the value fornameas a float.InetAddressgetInet(int i)Returns theith value as an InetAddress.InetAddressgetInet(String name)Returns the value fornameas an InetAddress.intgetInt(int i)Returns theith value as an integer.intgetInt(String name)Returns the value fornameas an integer.StringgetKeyspace()Returns the keyspace this query operates on.<T> List<T>getList(int i, TypeToken<T> elementsType)Returns theith value as a list.<T> List<T>getList(int i, Class<T> elementsClass)Returns theith value as a list.<T> List<T>getList(String name, TypeToken<T> elementsType)Returns the value fornameas a list.<T> List<T>getList(String name, Class<T> elementsClass)Returns the value fornameas a list.longgetLong(int i)Returns theith value as a long.longgetLong(String name)Returns the value fornameas a long.<K,V>
Map<K,V>getMap(int i, TypeToken<K> keysType, TypeToken<V> valuesType)Returns theith value as a map.<K,V>
Map<K,V>getMap(int i, Class<K> keysClass, Class<V> valuesClass)Returns theith value as a map.<K,V>
Map<K,V>getMap(String name, TypeToken<K> keysType, TypeToken<V> valuesType)Returns the value fornameas a map.<K,V>
Map<K,V>getMap(String name, Class<K> keysClass, Class<V> valuesClass)Returns the value fornameas a map.ObjectgetObject(int i)Returns theith value as the Java type matching its CQL type.ObjectgetObject(String name)Returns the value fornameas the Java type matching its CQL type.com.datastax.driver.core.Token.FactorygetPartitioner()The partitioner for this query.ByteBuffergetRoutingKey(ProtocolVersion protocolVersion, CodecRegistry codecRegistry)The routing key for this bound query.<T> Set<T>getSet(int i, TypeToken<T> elementsType)Returns theith value as a set.<T> Set<T>getSet(int i, Class<T> elementsClass)Returns theith value as a set.<T> Set<T>getSet(String name, TypeToken<T> elementsType)Returns the value fornameas a set.<T> Set<T>getSet(String name, Class<T> elementsClass)Returns the value fornameas a set.shortgetShort(int i)Returns theith value as a short.shortgetShort(String name)Returns the value fornameas a short.StringgetString(int i)Returns theith value as a string.StringgetString(String name)Returns the value fornameas a string.longgetTime(int i)Returns theith value as a long in nanoseconds since midnight.longgetTime(String name)Returns the value fornameas a long in nanoseconds since midnight.DategetTimestamp(int i)Returns theith value as a date.DategetTimestamp(String name)Returns the value fornameas a date.TupleValuegetTupleValue(int i)Return theith value as a tuple value.TupleValuegetTupleValue(String name)Return the value fornameas a tuple value.UDTValuegetUDTValue(int i)Return theith value as a UDT value.UDTValuegetUDTValue(String name)Return the value fornameas a UDT value.UUIDgetUUID(int i)Returns theith value as a UUID.UUIDgetUUID(String name)Returns the value fornameas a UUID.BigIntegergetVarint(int i)Returns theith value as a variable length integer.BigIntegergetVarint(String name)Returns the value fornameas a variable length integer.booleanisLWT()booleanisNull(int i)Returns whether theith value is NULL.booleanisNull(String name)Returns whether the value fornameis NULL.booleanisSet(int i)Returns whether theith variable has been bound.booleanisSet(String name)Returns whether the first occurrence of variablenamehas been bound.PreparedStatementpreparedStatement()Returns the prepared statement on which this BoundStatement is based.intrequestSizeInBytes(ProtocolVersion protocolVersion, CodecRegistry codecRegistry)Returns the number of bytes required to encode this statement.<V> BoundStatementset(int i, V v, TypeCodec<V> codec)Sets theith value to the provided value, converted using the givenTypeCodec.<V> BoundStatementset(int i, V v, TypeToken<V> targetType)Sets theith value to the provided value of the provided Java type.<V> BoundStatementset(int i, V v, Class<V> targetClass)Sets theith value to the provided value of the provided Java class.<V> BoundStatementset(String name, V v, TypeCodec<V> codec)Sets the value for (all occurrences of) variablenameto the provided value, converted using the givenTypeCodec.<V> BoundStatementset(String name, V v, TypeToken<V> targetType)Sets the value for (all occurrences of) variablenameto the provided value of the provided Java type.<V> BoundStatementset(String name, V v, Class<V> targetClass)Sets the value for (all occurrences of) variablenameto the provided value of the provided Java class.BoundStatementsetBool(int i, boolean v)Sets theith value to the provided boolean.BoundStatementsetBool(String name, boolean v)Sets the value for (all occurrences of) variablenameto the provided boolean.BoundStatementsetByte(int i, byte v)Set theith value to the provided byte.BoundStatementsetByte(String name, byte v)Sets the value for (all occurrences of) variablenameto the provided byte.BoundStatementsetBytes(int i, ByteBuffer v)Sets theith value to the provided byte buffer.BoundStatementsetBytes(String name, ByteBuffer v)Sets the value for (all occurrences of) variablenameto the provided byte buffer.BoundStatementsetBytesUnsafe(int i, ByteBuffer v)Sets theith value to the provided byte buffer.BoundStatementsetBytesUnsafe(String name, ByteBuffer v)Sets the value for (all occurrences of) variablenameto the provided byte buffer.BoundStatementsetDate(int i, LocalDate v)Set theith value to the provided date (without time).BoundStatementsetDate(String name, LocalDate v)Sets the value for (all occurrences of) variablenameto the provided date (without time).BoundStatementsetDecimal(int i, BigDecimal v)Sets theith value to the provided big decimal.BoundStatementsetDecimal(String name, BigDecimal v)Sets the value for (all occurrences of) variablenameto the provided big decimal.BoundStatementsetDouble(int i, double v)Sets theith value to the provided double.BoundStatementsetDouble(String name, double v)Sets the value for (all occurrences of) variablenameto the provided double.BoundStatementsetFloat(int i, float v)Sets theith value to the provided float.BoundStatementsetFloat(String name, float v)Sets the value for (all occurrences of) variablenameto the provided float.BoundStatementsetInet(int i, InetAddress v)Sets theith value to the provided inet address.BoundStatementsetInet(String name, InetAddress v)Sets the value for (all occurrences of) variablenameto the provided inet address.BoundStatementsetInt(int i, int v)Set theith value to the provided integer.BoundStatementsetInt(String name, int v)Sets the value for (all occurrences of) variablenameto the provided integer.<E> BoundStatementsetList(int i, List<E> v, TypeToken<E> elementsType)Sets theith value to the provided list, which elements are of the provided Java type.<E> BoundStatementsetList(int i, List<E> v, Class<E> elementsClass)Sets theith value to the provided list, which elements are of the provided Java class.<T> BoundStatementsetList(int i, List<T> v)Sets theith value to the provided list.<E> BoundStatementsetList(String name, List<E> v, TypeToken<E> elementsType)Sets the value for (all occurrences of) variablenameto the provided list, which elements are of the provided Java type.<E> BoundStatementsetList(String name, List<E> v, Class<E> elementsClass)Sets the value for (all occurrences of) variablenameto the provided list, which elements are of the provided Java class.<T> BoundStatementsetList(String name, List<T> v)Sets the value for (all occurrences of) variablenameto the provided list.BoundStatementsetLong(int i, long v)Sets theith value to the provided long.BoundStatementsetLong(String name, long v)Sets the value for (all occurrences of) variablenameto the provided long.<K,V>
BoundStatementsetMap(int i, Map<K,V> v)Sets theith value to the provided map.<K,V>
BoundStatementsetMap(int i, Map<K,V> v, TypeToken<K> keysType, TypeToken<V> valuesType)Sets theith value to the provided map, which keys and values are of the provided Java types.<K,V>
BoundStatementsetMap(int i, Map<K,V> v, Class<K> keysClass, Class<V> valuesClass)Sets theith value to the provided map, which keys and values are of the provided Java classes.<K,V>
BoundStatementsetMap(String name, Map<K,V> v)Sets the value for (all occurrences of) variablenameto the provided map.<K,V>
BoundStatementsetMap(String name, Map<K,V> v, TypeToken<K> keysType, TypeToken<V> valuesType)Sets the value for (all occurrences of) variablenameto the provided map, which keys and values are of the provided Java types.<K,V>
BoundStatementsetMap(String name, Map<K,V> v, Class<K> keysClass, Class<V> valuesClass)Sets the value for (all occurrences of) variablenameto the provided map, which keys and values are of the provided Java classes.BoundStatementsetPartitionKeyToken(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 atoken(...)call).BoundStatementsetRoutingKey(ByteBuffer routingKey)Sets the routing key for this bound statement.BoundStatementsetRoutingKey(ByteBuffer... routingKeyComponents)Sets the routing key for this bound statement, when the query partition key is composite and the routing key must be built from multiple values.<E> BoundStatementsetSet(int i, Set<E> v, TypeToken<E> elementsType)Sets theith value to the provided set, which elements are of the provided Java type.<E> BoundStatementsetSet(int i, Set<E> v, Class<E> elementsClass)Sets theith value to the provided set, which elements are of the provided Java class.<T> BoundStatementsetSet(int i, Set<T> v)Sets theith value to the provided set.<E> BoundStatementsetSet(String name, Set<E> v, TypeToken<E> elementsType)Sets the value for (all occurrences of) variablenameto the provided set, which elements are of the provided Java type.<E> BoundStatementsetSet(String name, Set<E> v, Class<E> elementsClass)Sets the value for (all occurrences of) variablenameto the provided set, which elements are of the provided Java class.<T> BoundStatementsetSet(String name, Set<T> v)Sets the value for (all occurrences of) variablenameto the provided set.BoundStatementsetShort(int i, short v)Set theith value to the provided short.BoundStatementsetShort(String name, short v)Sets the value for (all occurrences of) variablenameto the provided short.BoundStatementsetString(int i, String v)Sets theith value to the provided string.BoundStatementsetString(String name, String v)Sets the value for (all occurrences of) variablenameto the provided string.BoundStatementsetTime(int i, long v)Set theith value to the provided time as a long in nanoseconds since midnight.BoundStatementsetTime(String name, long v)Sets the value for (all occurrences of) variablenameto the provided time as a long in nanoseconds since midnight.BoundStatementsetTimestamp(int i, Date v)Set theith value to the provided date.BoundStatementsetTimestamp(String name, Date v)Sets the value for (all occurrences of) variablenameto the provided date.BoundStatementsetToken(int i, Token v)Sets theith value to the providedToken.BoundStatementsetToken(String name, Token v)Sets the value for (all occurrences of) variablenameto the provided token.BoundStatementsetToNull(int i)Sets theith value tonull.BoundStatementsetToNull(String name)Sets the value for (all occurrences of) variablenametonull.BoundStatementsetTupleValue(int i, TupleValue v)Sets theith value to the provided tuple value.BoundStatementsetTupleValue(String name, TupleValue v)Sets the value for (all occurrences of) variablenameto the provided tuple value.BoundStatementsetUDTValue(int i, UDTValue v)Sets theith value to the provided UDT value.BoundStatementsetUDTValue(String name, UDTValue v)Sets the value for (all occurrences of) variablenameto the provided UDT value.BoundStatementsetUUID(int i, UUID v)Sets theith value to the provided UUID.BoundStatementsetUUID(String name, UUID v)Sets the value for (all occurrences of) variablenameto the provided UUID.BoundStatementsetVarint(int i, BigInteger v)Sets theith value to the provided big integer.BoundStatementsetVarint(String name, BigInteger v)Sets the value for (all occurrences of) variablenameto the provided big integer.voidunset(int i)Unsets theith variable.voidunset(String name)Unsets all occurrences of variablename.-
Methods inherited from class com.datastax.driver.core.Statement
disableTracing, enableTracing, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getHost, getLastHost, getNowInSeconds, getOutgoingPayload, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, isBatchIdempotent, isIdempotent, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setHost, setIdempotent, setLastHost, setNowInSeconds, setOutgoingPayload, setPagingState, setPagingState, setPagingStateUnsafe, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevel
-
-
-
-
Constructor Detail
-
BoundStatement
public BoundStatement(PreparedStatement statement)
Creates a newBoundStatementfrom the provided prepared statement.- Parameters:
statement- the prepared statement from which to create aBoundStatement.
-
-
Method Detail
-
getPartitioner
public com.datastax.driver.core.Token.Factory getPartitioner()
Description copied from class:StatementThe partitioner for this query.- Overrides:
getPartitionerin classStatement- Returns:
- the partitioner for this query, or
nullif no partitioner has been specified. In the latter case, the cluster-wide partitioner will be used.
-
preparedStatement
public PreparedStatement preparedStatement()
Returns the prepared statement on which this BoundStatement is based.- Returns:
- the prepared statement on which this BoundStatement is based.
-
isSet
public boolean isSet(int i)
Returns whether theith variable has been bound.- Parameters:
i- the index of the variable to check.- Returns:
- whether the
ith variable has been bound. - Throws:
IndexOutOfBoundsException- ifi < 0 || i >= this.preparedStatement().variables().size().
-
isSet
public boolean isSet(String name)
Returns whether the first occurrence of variablenamehas been bound.- Parameters:
name- the name of the variable to check.- Returns:
- whether the first occurrence of variable
namehas been bound to a non-null value. - Throws:
IllegalArgumentException- ifnameis not a prepared variable, that is if!this.preparedStatement().variables().names().contains(name).
-
unset
public void unset(int i)
Unsets theith variable. This will leave the statement in the same state as if no setter was ever called for this variable.The treatment of unset variables depends on the native protocol version, see
BoundStatementfor explanations.- Parameters:
i- the index of the variable.- Throws:
IndexOutOfBoundsException- ifi < 0 || i >= this.preparedStatement().variables().size().
-
unset
public void unset(String name)
Unsets all occurrences of variablename. This will leave the statement in the same state as if no setter was ever called for this variable.The treatment of unset variables depends on the native protocol version, see
BoundStatementfor explanations.- Parameters:
name- the name of the variable.- Throws:
IllegalArgumentException- ifnameis not a prepared variable, that is if!this.preparedStatement().variables().names().contains(name).
-
bind
public BoundStatement bind(Object... values)
Bound values to the variables of this statement.This is a convenience method to bind all the variables of the
BoundStatementin one call.- Parameters:
values- the values to bind to the variables of the newly created BoundStatement. The first element ofvalueswill 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.- Returns:
- this bound statement.
- Throws:
IllegalArgumentException- if morevaluesare 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 ofvaluesis a collection (List, Set or Map) containing a null value. Nulls are not supported in collections by CQL.
-
getRoutingKey
public ByteBuffer getRoutingKey(ProtocolVersion protocolVersion, CodecRegistry codecRegistry)
The routing key for this bound query.This method will return a non-
nullvalue if either of the following occur:- The routing key has been set directly through
setRoutingKey(java.nio.ByteBuffer). - The routing key has been set through
PreparedStatement.setRoutingKey(java.nio.ByteBuffer)for thePreparedStatementthis statement has been built from. - All the columns composing the partition key are bound variables of this
BoundStatement. The routing key will then be built using the values provided for these partition key columns.
nullis 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 throughPreparedStatement.setRoutingKey(java.nio.ByteBuffer)then that is used next. If neither of those are set then it is computed.- Specified by:
getRoutingKeyin classStatement- Parameters:
protocolVersion- unused by this implementation (no internal serialization is required to compute the key).codecRegistry- unused by this implementation (no internal serialization is required to compute the key).- Returns:
- the routing key for this statement or
null.
- The routing key has been set directly through
-
setRoutingKey
public BoundStatement setRoutingKey(ByteBuffer routingKey)
Sets the routing key for this bound statement.This is useful when the routing key can neither be set on the
PreparedStatementthis 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.- Parameters:
routingKey- the raw (binary) value to use as routing key.- Returns:
- this
BoundStatementobject. - See Also:
getRoutingKey(com.datastax.driver.core.ProtocolVersion, com.datastax.driver.core.CodecRegistry)
-
setRoutingKey
public BoundStatement setRoutingKey(ByteBuffer... routingKeyComponents)
Sets the routing key for this bound statement, when the query partition key is composite and the routing key must be built from multiple values.This is useful when the routing key can neither be set on the
PreparedStatementthis 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.- Parameters:
routingKeyComponents- the raw (binary) values to compose to obtain the routing key.- Returns:
- this
BoundStatementobject. - See Also:
getRoutingKey(com.datastax.driver.core.ProtocolVersion, com.datastax.driver.core.CodecRegistry)
-
getKeyspace
public String getKeyspace()
Returns the keyspace this query operates on.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,USEqueries, 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 aUSEquery (or through the use ofCluster.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 returnnull(or even a bogus keyspace name) will never cause the query to fail.- Specified by:
getKeyspacein classStatement- Returns:
- the keyspace this query operate on if relevant or
null.
-
requestSizeInBytes
public int requestSizeInBytes(ProtocolVersion protocolVersion, CodecRegistry codecRegistry)
Returns the number of bytes required to encode this statement.The calculated size may be overestimated by a few bytes, but is never underestimated. If the size cannot be calculated, this method returns -1.
Note that the returned value is not cached, but instead recomputed at every method call.
- Overrides:
requestSizeInBytesin classStatement- Returns:
- the number of bytes required to encode this statement.
-
setBool
public BoundStatement setBool(int i, boolean v)
Sets theith value to the provided boolean.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typeboolean, this will be the built-in codec).- Specified by:
setBoolin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. To set the value to NULL, useSettableByIndexData.setToNull(int)orset(i, v, Boolean.class)- Returns:
- this object.
-
setBool
public BoundStatement setBool(String name, boolean v)
Sets the value for (all occurrences of) variablenameto the provided boolean.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typeboolean, this will be the built-in codec).- Specified by:
setBoolin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. To set the value to NULL, useSettableByNameData.setToNull(String)orset(name, v, Boolean.class).- Returns:
- this object.
-
setByte
public BoundStatement setByte(int i, byte v)
Set theith value to the provided byte.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typetinyint, this will be the built-in codec).- Specified by:
setBytein interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. To set the value to NULL, useSettableByIndexData.setToNull(int)orset(i, v, Byte.class)- Returns:
- this object.
-
setByte
public BoundStatement setByte(String name, byte v)
Sets the value for (all occurrences of) variablenameto the provided byte.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typetinyint, this will be the built-in codec).- Specified by:
setBytein interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. To set the value to NULL, useSettableByNameData.setToNull(String)orset(name, v, Byte.class).- Returns:
- this object.
-
setShort
public BoundStatement setShort(int i, short v)
Set theith value to the provided short.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typesmallint, this will be the built-in codec).- Specified by:
setShortin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. To set the value to NULL, useSettableByIndexData.setToNull(int)orset(i, v, Short.class)- Returns:
- this object.
-
setShort
public BoundStatement setShort(String name, short v)
Sets the value for (all occurrences of) variablenameto the provided short.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typesmallint, this will be the built-in codec).- Specified by:
setShortin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. To set the value to NULL, useSettableByNameData.setToNull(String)orset(name, v, Short.class).- Returns:
- this object.
-
setInt
public BoundStatement setInt(int i, int v)
Set theith value to the provided integer.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typeint, this will be the built-in codec).- Specified by:
setIntin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. To set the value to NULL, useSettableByIndexData.setToNull(int)orset(i, v, Integer.class)- Returns:
- this object.
-
setInt
public BoundStatement setInt(String name, int v)
Sets the value for (all occurrences of) variablenameto the provided integer.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typeint, this will be the built-in codec).- Specified by:
setIntin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. To set the value to NULL, useSettableByNameData.setToNull(String)orset(name, v, Integer.class).- Returns:
- this object.
-
setLong
public BoundStatement setLong(int i, long v)
Sets theith value to the provided long.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typebigint, this will be the built-in codec).- Specified by:
setLongin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. To set the value to NULL, useSettableByIndexData.setToNull(int)orset(i, v, Long.class)- Returns:
- this object.
-
setLong
public BoundStatement setLong(String name, long v)
Sets the value for (all occurrences of) variablenameto the provided long.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typebigint, this will be the built-in codec).- Specified by:
setLongin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. To set the value to NULL, useSettableByNameData.setToNull(String)orset(name, v, Long.class).- Returns:
- this object.
-
setTimestamp
public BoundStatement setTimestamp(int i, Date v)
Set theith value to the provided date.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typetimestamp, this will be the built-in codec).- Specified by:
setTimestampin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setTimestamp
public BoundStatement setTimestamp(String name, Date v)
Sets the value for (all occurrences of) variablenameto the provided date.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typetimestamp, this will be the built-in codec).- Specified by:
setTimestampin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setDate
public BoundStatement setDate(int i, LocalDate v)
Set theith value to the provided date (without time).This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typedate, this will be the built-in codec).- Specified by:
setDatein interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setDate
public BoundStatement setDate(String name, LocalDate v)
Sets the value for (all occurrences of) variablenameto the provided date (without time).This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typedate, this will be the built-in codec).- Specified by:
setDatein interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setTime
public BoundStatement setTime(int i, long v)
Set theith value to the provided time as a long in nanoseconds since midnight.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typetime, this will be the built-in codec).- Specified by:
setTimein interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setTime
public BoundStatement setTime(String name, long v)
Sets the value for (all occurrences of) variablenameto the provided time as a long in nanoseconds since midnight.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typetime, this will be the built-in codec).- Specified by:
setTimein interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setFloat
public BoundStatement setFloat(int i, float v)
Sets theith value to the provided float.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typefloat, this will be the built-in codec).- Specified by:
setFloatin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. To set the value to NULL, useSettableByIndexData.setToNull(int)orset(i, v, Float.class)- Returns:
- this object.
-
setFloat
public BoundStatement setFloat(String name, float v)
Sets the value for (all occurrences of) variablenameto the provided float.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typefloat, this will be the built-in codec).- Specified by:
setFloatin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. To set the value to NULL, useSettableByNameData.setToNull(String)orset(name, v, Float.class).- Returns:
- this object.
-
setDouble
public BoundStatement setDouble(int i, double v)
Sets theith value to the provided double.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typedouble, this will be the built-in codec).- Specified by:
setDoublein interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. To set the value to NULL, useSettableByIndexData.setToNull(int)orset(i, v, Double.class).- Returns:
- this object.
-
setDouble
public BoundStatement setDouble(String name, double v)
Sets the value for (all occurrences of) variablenameto the provided double.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typedouble, this will be the built-in codec).- Specified by:
setDoublein interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. To set the value to NULL, useSettableByNameData.setToNull(String)orset(name, v, Double.class).- Returns:
- this object.
-
setString
public BoundStatement setString(int i, String v)
Sets theith value to the provided string.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typestext,varcharandascii, this will be the built-in codec).- Specified by:
setStringin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setString
public BoundStatement setString(String name, String v)
Sets the value for (all occurrences of) variablenameto the provided string.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typestext,varcharandascii, this will be the built-in codec).- Specified by:
setStringin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setBytes
public BoundStatement setBytes(int i, ByteBuffer v)
Sets theith value to the provided byte buffer.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typeblob, this will be the built-in codec).- Specified by:
setBytesin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setBytes
public BoundStatement setBytes(String name, ByteBuffer v)
Sets the value for (all occurrences of) variablenameto the provided byte buffer.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typeblob, this will be the built-in codec).- Specified by:
setBytesin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setBytesUnsafe
public BoundStatement setBytesUnsafe(int i, ByteBuffer v)
Sets theith value to the provided byte buffer.This method does not use any codec; it sets the value in its binary form directly. If you insert data that is not compatible with the underlying CQL type, you will get an
InvalidQueryExceptionat execute time.- Specified by:
setBytesUnsafein interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setBytesUnsafe
public BoundStatement setBytesUnsafe(String name, ByteBuffer v)
Sets the value for (all occurrences of) variablenameto the provided byte buffer.This method does not use any codec; it sets the value in its binary form directly. If you insert data that is not compatible with the underlying CQL type, you will get an
InvalidQueryExceptionat execute time.- Specified by:
setBytesUnsafein interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setVarint
public BoundStatement setVarint(int i, BigInteger v)
Sets theith value to the provided big integer.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typevarint, this will be the built-in codec).- Specified by:
setVarintin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setVarint
public BoundStatement setVarint(String name, BigInteger v)
Sets the value for (all occurrences of) variablenameto the provided big integer.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typevarint, this will be the built-in codec).- Specified by:
setVarintin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setDecimal
public BoundStatement setDecimal(int i, BigDecimal v)
Sets theith value to the provided big decimal.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typedecimal, this will be the built-in codec).- Specified by:
setDecimalin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setDecimal
public BoundStatement setDecimal(String name, BigDecimal v)
Sets the value for (all occurrences of) variablenameto the provided big decimal.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typedecimal, this will be the built-in codec).- Specified by:
setDecimalin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setUUID
public BoundStatement setUUID(int i, UUID v)
Sets theith value to the provided UUID.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typesuuidandtimeuuid, this will be the built-in codec).- Specified by:
setUUIDin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setUUID
public BoundStatement setUUID(String name, UUID v)
Sets the value for (all occurrences of) variablenameto the provided UUID.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typesuuidandtimeuuid, this will be the built-in codec).- Specified by:
setUUIDin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setInet
public BoundStatement setInet(int i, InetAddress v)
Sets theith value to the provided inet address.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typeinet, this will be the built-in codec).- Specified by:
setInetin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setInet
public BoundStatement setInet(String name, InetAddress v)
Sets the value for (all occurrences of) variablenameto the provided inet address.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (for CQL typeinet, this will be the built-in codec).- Specified by:
setInetin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setToken
public BoundStatement setToken(int i, Token v)
Sets theith value to the providedToken.setPartitionKeyToken(Token)should generally be preferred if you have a single token variable.- Parameters:
i- the index of the variable to set.v- the value to set.- Returns:
- this BoundStatement.
- Throws:
IndexOutOfBoundsException- ifi < 0 || i >= this.preparedStatement().variables().size().InvalidTypeException- if columniis not of the type of the token's value.
-
setToken
public BoundStatement setToken(String name, Token v)
Sets the value for (all occurrences of) variablenameto 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);- Parameters:
name- the name of the variable to set; if multiple variablesnameare prepared, all of them are set.v- the value to set.- Returns:
- this BoundStatement.
- Throws:
IllegalArgumentException- ifnameis not a prepared variable, that is, if!this.preparedStatement().variables().names().contains(name).InvalidTypeException- if (any occurrence of)nameis not of the type of the token's value.
-
setPartitionKeyToken
public 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 atoken(...)call).This method is a shorthand for statements with a single token variable:
If you have multiple token variables, use positional binding (Token token = ... PreparedStatement pst = session.prepare("SELECT * FROM my_table WHERE token(k) = ?"); BoundStatement b = pst.bind().setPartitionKeyToken(token);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);- Parameters:
v- the value to set.- Returns:
- this BoundStatement.
- Throws:
IllegalArgumentException- ifnameis not a prepared variable, that is, if!this.preparedStatement().variables().names().contains(name).InvalidTypeException- if (any occurrence of)nameis not of the type of the token's value.
-
setList
public <T> BoundStatement setList(int i, List<T> v)
Sets theith value to the provided list.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (the type of the elements in the Java list is not considered). If two or more codecs target that CQL type, the one that was first registered will be used. For this reason, it is generally preferable to use the more deterministic methodsSettableByIndexData.setList(int, List, Class)orSettableByIndexData.setList(int, List, TypeToken).- Specified by:
setListin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.- Returns:
- this object.
-
setList
public <E> BoundStatement setList(int i, List<E> v, Class<E> elementsClass)
Sets theith value to the provided list, which elements are of the provided Java class.This method uses the
CodecRegistryto find a codec to handle the conversion of lists of the given Java type to the underlying CQL type.If the type of the elements is generic, use
SettableByIndexData.setList(int, List, TypeToken).- Specified by:
setListin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.elementsClass- the class for the elements of the list.- Returns:
- this object.
-
setList
public <E> BoundStatement setList(int i, List<E> v, TypeToken<E> elementsType)
Sets theith value to the provided list, which elements are of the provided Java type.This method uses the
CodecRegistryto find a codec to handle the conversion of lists of the given Java type to the underlying CQL type.- Specified by:
setListin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.elementsType- the type for the elements of the list.- Returns:
- this object.
-
setList
public <T> BoundStatement setList(String name, List<T> v)
Sets the value for (all occurrences of) variablenameto the provided list.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (the type of the elements in the Java list is not considered). If two or more codecs target that CQL type, the one that was first registered will be used. For this reason, it is generally preferable to use the more deterministic methodsSettableByNameData.setList(String, List, Class)orSettableByNameData.setList(String, List, TypeToken).- Specified by:
setListin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.- Returns:
- this object.
-
setList
public <E> BoundStatement setList(String name, List<E> v, Class<E> elementsClass)
Sets the value for (all occurrences of) variablenameto the provided list, which elements are of the provided Java class.This method uses the
CodecRegistryto find a codec to handle the conversion of lists of the given Java type to the underlying CQL type.If the type of the elements is generic, use
SettableByNameData.setList(String, List, TypeToken).- Specified by:
setListin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiplev- the value to set. Note thatnullvalues inside collections are not supported by CQL.elementsClass- the class for the elements of the list.- Returns:
- this object.
-
setList
public <E> BoundStatement setList(String name, List<E> v, TypeToken<E> elementsType)
Sets the value for (all occurrences of) variablenameto the provided list, which elements are of the provided Java type.This method uses the
CodecRegistryto find a codec to handle the conversion of lists of the given Java type to the underlying CQL type.- Specified by:
setListin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiplev- the value to set. Note thatnullvalues inside collections are not supported by CQL.elementsType- the type for the elements of the list.- Returns:
- this object.
-
setMap
public <K,V> BoundStatement setMap(int i, Map<K,V> v)
Sets theith value to the provided map.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (the type of the elements in the Java map is not considered). If two or more codecs target that CQL type, the one that was first registered will be used. For this reason, it is generally preferable to use the more deterministic methodsSettableByIndexData.setMap(int, Map, Class, Class)orSettableByIndexData.setMap(int, Map, TypeToken, TypeToken).- Specified by:
setMapin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.- Returns:
- this object.
-
setMap
public <K,V> BoundStatement setMap(int i, Map<K,V> v, Class<K> keysClass, Class<V> valuesClass)
Sets theith value to the provided map, which keys and values are of the provided Java classes.This method uses the
CodecRegistryto find a codec to handle the conversion of lists of the given Java types to the underlying CQL type.If the type of the keys or values is generic, use
SettableByIndexData.setMap(int, Map, TypeToken, TypeToken).- Specified by:
setMapin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.keysClass- the class for the keys of the map.valuesClass- the class for the values of the map.- Returns:
- this object.
-
setMap
public <K,V> BoundStatement setMap(int i, Map<K,V> v, TypeToken<K> keysType, TypeToken<V> valuesType)
Sets theith value to the provided map, which keys and values are of the provided Java types.This method uses the
CodecRegistryto find a codec to handle the conversion of lists of the given Java types to the underlying CQL type.- Specified by:
setMapin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.keysType- the type for the keys of the map.valuesType- the type for the values of the map.- Returns:
- this object.
-
setMap
public <K,V> BoundStatement setMap(String name, Map<K,V> v)
Sets the value for (all occurrences of) variablenameto the provided map.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (the type of the elements in the Java map is not considered). If two or more codecs target that CQL type, the one that was first registered will be used. For this reason, it is generally preferable to use the more deterministic methodsSettableByNameData.setMap(String, Map, Class, Class)orSettableByNameData.setMap(String, Map, TypeToken, TypeToken).- Specified by:
setMapin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.- Returns:
- this object.
-
setMap
public <K,V> BoundStatement setMap(String name, Map<K,V> v, Class<K> keysClass, Class<V> valuesClass)
Sets the value for (all occurrences of) variablenameto the provided map, which keys and values are of the provided Java classes.This method uses the
CodecRegistryto find a codec to handle the conversion of lists of the given Java types to the underlying CQL type.If the type of the keys or values is generic, use
SettableByNameData.setMap(String, Map, TypeToken, TypeToken).- Specified by:
setMapin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.keysClass- the class for the keys of the map.valuesClass- the class for the values of the map.- Returns:
- this object.
-
setMap
public <K,V> BoundStatement setMap(String name, Map<K,V> v, TypeToken<K> keysType, TypeToken<V> valuesType)
Sets the value for (all occurrences of) variablenameto the provided map, which keys and values are of the provided Java types.This method uses the
CodecRegistryto find a codec to handle the conversion of lists of the given Java types to the underlying CQL type.- Specified by:
setMapin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.keysType- the type for the keys of the map.valuesType- the type for the values of the map.- Returns:
- this object.
-
setSet
public <T> BoundStatement setSet(int i, Set<T> v)
Sets theith value to the provided set.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (the type of the elements in the Java set is not considered). If two or more codecs target that CQL type, the one that was first registered will be used. For this reason, it is generally preferable to use the more deterministic methodsSettableByIndexData.setSet(int, Set, Class)orSettableByIndexData.setSet(int, Set, TypeToken).- Specified by:
setSetin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.- Returns:
- this object.
-
setSet
public <E> BoundStatement setSet(int i, Set<E> v, Class<E> elementsClass)
Sets theith value to the provided set, which elements are of the provided Java class.This method uses the
CodecRegistryto find a codec to handle the conversion of sets of the given Java type to the underlying CQL type.If the type of the elements is generic, use
SettableByIndexData.setSet(int, Set, TypeToken).- Specified by:
setSetin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.elementsClass- the class for the elements of the set.- Returns:
- this object.
-
setSet
public <E> BoundStatement setSet(int i, Set<E> v, TypeToken<E> elementsType)
Sets theith value to the provided set, which elements are of the provided Java type.This method uses the
CodecRegistryto find a codec to handle the conversion of sets of the given Java type to the underlying CQL type.- Specified by:
setSetin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.elementsType- the type for the elements of the set.- Returns:
- this object.
-
setSet
public <T> BoundStatement setSet(String name, Set<T> v)
Sets the value for (all occurrences of) variablenameto the provided set.This method uses the
CodecRegistryto find a codec to handle the conversion to the underlying CQL type (the type of the elements in the Java set is not considered). If two or more codecs target that CQL type, the one that was first registered will be used. For this reason, it is generally preferable to use the more deterministic methodsSettableByNameData.setSet(String, Set, Class)orSettableByNameData.setSet(String, Set, TypeToken).- Specified by:
setSetin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set. Note thatnullvalues inside collections are not supported by CQL.- Returns:
- this object.
-
setSet
public <E> BoundStatement setSet(String name, Set<E> v, Class<E> elementsClass)
Sets the value for (all occurrences of) variablenameto the provided set, which elements are of the provided Java class.This method uses the
CodecRegistryto find a codec to handle the conversion of sets of the given Java type to the underlying CQL type.If the type of the elements is generic, use
SettableByNameData.setSet(String, Set, TypeToken).- Specified by:
setSetin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiplev- the value to set. Note thatnullvalues inside collections are not supported by CQL.elementsClass- the class for the elements of the set.- Returns:
- this object.
-
setSet
public <E> BoundStatement setSet(String name, Set<E> v, TypeToken<E> elementsType)
Sets the value for (all occurrences of) variablenameto the provided set, which elements are of the provided Java type.This method uses the
CodecRegistryto find a codec to handle the conversion of sets of the given Java type to the underlying CQL type.- Specified by:
setSetin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiplev- the value to set. Note thatnullvalues inside collections are not supported by CQL.elementsType- the type for the elements of the set.- Returns:
- this object.
-
setUDTValue
public BoundStatement setUDTValue(int i, UDTValue v)
Sets theith value to the provided UDT value.This method uses the
CodecRegistryto find a codec to handle the conversion ofUDTValueto the underlying CQL type.- Specified by:
setUDTValuein interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setUDTValue
public BoundStatement setUDTValue(String name, UDTValue v)
Sets the value for (all occurrences of) variablenameto the provided UDT value.This method uses the
CodecRegistryto find a codec to handle the conversion ofUDTValueto the underlying CQL type.- Specified by:
setUDTValuein interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
setTupleValue
public BoundStatement setTupleValue(int i, TupleValue v)
Sets theith value to the provided tuple value.This method uses the
CodecRegistryto find a codec to handle the conversion ofTupleValueto the underlying CQL type.- Specified by:
setTupleValuein interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set.- Returns:
- this object.
-
setTupleValue
public BoundStatement setTupleValue(String name, TupleValue v)
Sets the value for (all occurrences of) variablenameto the provided tuple value.This method uses the
CodecRegistryto find a codec to handle the conversion ofTupleValueto the underlying CQL type.- Specified by:
setTupleValuein interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set.- Returns:
- this object.
-
set
public <V> BoundStatement set(int i, V v, Class<V> targetClass)
Sets theith value to the provided value of the provided Java class.This method uses the
CodecRegistryto find a codec to handle the conversion of the provided Java class to the underlying CQL type.If the Java type is generic, use
SettableByIndexData.set(int, Object, TypeToken)instead.- Specified by:
setin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set; may benull.targetClass- The Java class to convert to; must not benull;- Returns:
- this object.
-
set
public <V> BoundStatement set(String name, V v, Class<V> targetClass)
Sets the value for (all occurrences of) variablenameto the provided value of the provided Java class.This method uses the
CodecRegistryto find a codec to handle the conversion of the provided Java class to the underlying CQL type.If the Java type is generic, use
SettableByNameData.set(String, Object, TypeToken)instead.- Specified by:
setin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set; may benull.targetClass- The Java class to convert to; must not benull;- Returns:
- this object.
-
set
public <V> BoundStatement set(int i, V v, TypeToken<V> targetType)
Sets theith value to the provided value of the provided Java type.This method uses the
CodecRegistryto find a codec to handle the conversion of the provided Java type to the underlying CQL type.- Specified by:
setin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set; may benull.targetType- The Java type to convert to; must not benull;- Returns:
- this object.
-
set
public <V> BoundStatement set(String name, V v, TypeToken<V> targetType)
Sets the value for (all occurrences of) variablenameto the provided value of the provided Java type.This method uses the
CodecRegistryto find a codec to handle the conversion of the provided Java type to the underlying CQL type.- Specified by:
setin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set; may benull.targetType- The Java type to convert to; must not benull;- Returns:
- this object.
-
set
public <V> BoundStatement set(int i, V v, TypeCodec<V> codec)
Sets theith value to the provided value, converted using the givenTypeCodec.This method entirely bypasses the
CodecRegistryand forces the driver to use the given codec instead. This can be useful if the codec would collide with a previously registered one, or if you want to use the codec just once without registering it.It is the caller's responsibility to ensure that the given codec
acceptsthe underlying CQL type; failing to do so may result inInvalidTypeExceptions being thrown.- Specified by:
setin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.v- the value to set; may benull.codec- TheTypeCodecto use to serialize the value; may not benull.- Returns:
- this object.
-
set
public <V> BoundStatement set(String name, V v, TypeCodec<V> codec)
Sets the value for (all occurrences of) variablenameto the provided value, converted using the givenTypeCodec.This method entirely bypasses the
CodecRegistryand forces the driver to use the given codec instead. This can be useful if the codec would collide with a previously registered one, or if you want to use the codec just once without registering it.It is the caller's responsibility to ensure that the given codec
acceptsthe underlying CQL type; failing to do so may result inInvalidTypeExceptions being thrown.- Specified by:
setin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.v- the value to set; may benull.codec- TheTypeCodecto use to serialize the value; may not benull.- Returns:
- this object.
-
setToNull
public BoundStatement setToNull(int i)
Sets theith value tonull.This is mainly intended for CQL types which map to native Java types.
- Specified by:
setToNullin interfaceSettableByIndexData<BoundStatement>- Parameters:
i- the index of the value to set.- Returns:
- this object.
-
setToNull
public BoundStatement setToNull(String name)
Sets the value for (all occurrences of) variablenametonull.This is mainly intended for CQL types which map to native Java types.
- Specified by:
setToNullin interfaceSettableByNameData<BoundStatement>- Parameters:
name- the name of the value to set; ifnameis present multiple times, all its values are set.- Returns:
- this object.
-
isNull
public boolean isNull(int i)
Returns whether theith value is NULL.- Specified by:
isNullin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) of the value to check.- Returns:
- whether the
ith value is NULL.
-
isNull
public boolean isNull(String name)
Returns whether the value fornameis NULL.- Specified by:
isNullin interfaceGettableByNameData- Parameters:
name- the name to check.- Returns:
- whether the value for
nameis NULL.
-
getBool
public boolean getBool(int i)
Returns theith value as a boolean.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javaboolean(for CQL typeboolean, this will be the built-in codec).- Specified by:
getBoolin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the boolean value of the
ith element. If the value is NULL,falseis returned. If you need to distinguish NULL and false values, check first withGettableByIndexData.isNull(int)or useget(i, Boolean.class).
-
getBool
public boolean getBool(String name)
Returns the value fornameas a boolean.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javaboolean(for CQL typeboolean, this will be the built-in codec).- Specified by:
getBoolin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the boolean value for
name. If the value is NULL,falseis returned. If you need to distinguish NULL and false values, check first withGettableByNameData.isNull(String)or useget(name, Boolean.class).
-
getByte
public byte getByte(int i)
Returns theith value as a byte.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javabyte(for CQL typetinyint, this will be the built-in codec).- Specified by:
getBytein interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a byte. If the value is NULL,0is returned. If you need to distinguish NULL and 0, check first withGettableByIndexData.isNull(int)or useget(i, Byte.class).
-
getByte
public byte getByte(String name)
Returns the value fornameas a byte.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javabyte(for CQL typetinyint, this will be the built-in codec).- Specified by:
getBytein interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a byte. If the value is NULL,0is returned. If you need to distinguish NULL and 0, check first withGettableByNameData.isNull(String)or useget(name, Byte.class).0is returned.
-
getShort
public short getShort(int i)
Returns theith value as a short.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javashort(for CQL typesmallint, this will be the built-in codec).- Specified by:
getShortin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a short. If the value is NULL,0is returned. If you need to distinguish NULL and 0, check first withGettableByIndexData.isNull(int)or useget(i, Short.class).
-
getShort
public short getShort(String name)
Returns the value fornameas a short.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javashort(for CQL typesmallint, this will be the built-in codec).- Specified by:
getShortin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a short. If the value is NULL,0is returned. If you need to distinguish NULL and 0, check first withGettableByNameData.isNull(String)or useget(name, Short.class).0is returned.
-
getInt
public int getInt(int i)
Returns theith value as an integer.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javaint(for CQL typeint, this will be the built-in codec).- Specified by:
getIntin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as an integer. If the value is NULL,0is returned. If you need to distinguish NULL and 0, check first withGettableByIndexData.isNull(int)or useget(i, Integer.class).
-
getInt
public int getInt(String name)
Returns the value fornameas an integer.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javaint(for CQL typeint, this will be the built-in codec).- Specified by:
getIntin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas an integer. If the value is NULL,0is returned. If you need to distinguish NULL and 0, check first withGettableByNameData.isNull(String)or useget(name, Integer.class).0is returned.
-
getLong
public long getLong(int i)
Returns theith value as a long.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javabyte(for CQL typesbigintandcounter, this will be the built-in codec).- Specified by:
getLongin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a long. If the value is NULL,0Lis returned. If you need to distinguish NULL and 0L, check first withGettableByIndexData.isNull(int)or useget(i, Long.class).
-
getLong
public long getLong(String name)
Returns the value fornameas a long.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javabyte(for CQL typesbigintandcounter, this will be the built-in codec).- Specified by:
getLongin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a long. If the value is NULL,0Lis returned. If you need to distinguish NULL and 0L, check first withGettableByNameData.isNull(String)or useget(name, Long.class).
-
getTimestamp
public Date getTimestamp(int i)
Returns theith value as a date.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aDate(for CQL typetimestamp, this will be the built-in codec).- Specified by:
getTimestampin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a data. If the value is NULL,nullis returned.
-
getTimestamp
public Date getTimestamp(String name)
Returns the value fornameas a date.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aDate(for CQL typetimestamp, this will be the built-in codec).- Specified by:
getTimestampin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a date. If the value is NULL,nullis returned.
-
getDate
public LocalDate getDate(int i)
Returns theith value as a date (without time).This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aLocalDate(for CQL typedate, this will be the built-in codec).- Specified by:
getDatein interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as an date. If the value is NULL,nullis returned.
-
getDate
public LocalDate getDate(String name)
Returns the value fornameas a date (without time).This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aLocalDate(for CQL typedate, this will be the built-in codec).- Specified by:
getDatein interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a date. If the value is NULL,nullis returned.
-
getTime
public long getTime(int i)
Returns theith value as a long in nanoseconds since midnight.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javalong(for CQL typetime, this will be the built-in codec).- Specified by:
getTimein interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a long. If the value is NULL,0Lis returned.
-
getTime
public long getTime(String name)
Returns the value fornameas a long in nanoseconds since midnight.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javalong(for CQL typetime, this will be the built-in codec).- Specified by:
getTimein interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a long. If the value is NULL,0Lis returned.
-
getFloat
public float getFloat(int i)
Returns theith value as a float.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javafloat(for CQL typefloat, this will be the built-in codec).- Specified by:
getFloatin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a float. If the value is NULL,0.0fis returned. If you need to distinguish NULL and 0.0f, check first withGettableByIndexData.isNull(int)or useget(i, Float.class).
-
getFloat
public float getFloat(String name)
Returns the value fornameas a float.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javafloat(for CQL typefloat, this will be the built-in codec).- Specified by:
getFloatin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a float. If the value is NULL,0.0fis returned. If you need to distinguish NULL and 0.0f, check first withGettableByNameData.isNull(String)or useget(name, Float.class).
-
getDouble
public double getDouble(int i)
Returns theith value as a double.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javadouble(for CQL typedouble, this will be the built-in codec).- Specified by:
getDoublein interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a double. If the value is NULL,0.0is returned. If you need to distinguish NULL and 0.0, check first withGettableByIndexData.isNull(int)or useget(i, Double.class).
-
getDouble
public double getDouble(String name)
Returns the value fornameas a double.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Javadouble(for CQL typedouble, this will be the built-in codec).- Specified by:
getDoublein interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a double. If the value is NULL,0.0is returned. If you need to distinguish NULL and 0.0, check first withGettableByNameData.isNull(String)or useget(name, Double.class).
-
getBytesUnsafe
public ByteBuffer getBytesUnsafe(int i)
Returns theith value as aByteBuffer.This method does not use any codec; it returns a copy of the binary representation of the value. It is up to the caller to convert the returned value appropriately.
- Specified by:
getBytesUnsafein interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a ByteBuffer. If the value is NULL,nullis returned.
-
getBytesUnsafe
public ByteBuffer getBytesUnsafe(String name)
Returns the value fornameas a ByteBuffer.This method does not use any codec; it returns a copy of the binary representation of the value. It is up to the caller to convert the returned value appropriately.
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.
- Specified by:
getBytesUnsafein interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a ByteBuffer. If the value is NULL,nullis returned.
-
getBytes
public ByteBuffer getBytes(int i)
Returns theith value as a byte array.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a JavaByteBuffer(for CQL typeblob, this will be the built-in codec).- Specified by:
getBytesin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a byte array. If the value is NULL,nullis returned.
-
getBytes
public ByteBuffer getBytes(String name)
Returns the value fornameas a byte array.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a JavaByteBuffer(for CQL typeblob, this will be the built-in codec).- Specified by:
getBytesin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a byte array. If the value is NULL,nullis returned.
-
getString
public String getString(int i)
Returns theith value as a string.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Java string (for CQL typestext,varcharandascii, this will be the built-in codec).- Specified by:
getStringin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a string. If the value is NULL,nullis returned.
-
getString
public String getString(String name)
Returns the value fornameas a string.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a Java string (for CQL typestext,varcharandascii, this will be the built-in codec).- Specified by:
getStringin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a string. If the value is NULL,nullis returned.
-
getVarint
public BigInteger getVarint(int i)
Returns theith value as a variable length integer.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aBigInteger(for CQL typevarint, this will be the built-in codec).- Specified by:
getVarintin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a variable length integer. If the value is NULL,nullis returned.
-
getVarint
public BigInteger getVarint(String name)
Returns the value fornameas a variable length integer.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aBigInteger(for CQL typevarint, this will be the built-in codec).- Specified by:
getVarintin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a variable length integer. If the value is NULL,nullis returned.
-
getDecimal
public BigDecimal getDecimal(int i)
Returns theith value as a variable length decimal.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aBigDecimal(for CQL typedecimal, this will be the built-in codec).- Specified by:
getDecimalin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a variable length decimal. If the value is NULL,nullis returned.
-
getDecimal
public BigDecimal getDecimal(String name)
Returns the value fornameas a variable length decimal.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aBigDecimal(for CQL typedecimal, this will be the built-in codec).- Specified by:
getDecimalin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a variable length decimal. If the value is NULL,nullis returned.
-
getUUID
public UUID getUUID(int i)
Returns theith value as a UUID.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aUUID(for CQL typesuuidandtimeuuid, this will be the built-in codec).- Specified by:
getUUIDin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a UUID. If the value is NULL,nullis returned.
-
getUUID
public UUID getUUID(String name)
Returns the value fornameas a UUID.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aUUID(for CQL typesuuidandtimeuuid, this will be the built-in codec).- Specified by:
getUUIDin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a UUID. If the value is NULL,nullis returned.
-
getInet
public InetAddress getInet(int i)
Returns theith value as an InetAddress.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to anInetAddress(for CQL typeinet, this will be the built-in codec).- Specified by:
getInetin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as an InetAddress. If the value is NULL,nullis returned.
-
getInet
public InetAddress getInet(String name)
Returns the value fornameas an InetAddress.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to anInetAddress(for CQL typeinet, this will be the built-in codec).- Specified by:
getInetin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas an InetAddress. If the value is NULL,nullis returned.
-
getList
public <T> List<T> getList(int i, Class<T> elementsClass)
Returns theith value as a list.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a list of the specified type.If the type of the elements is generic, use
GettableByIndexData.getList(int, TypeToken).Implementation note: the actual
Listimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill be mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getListin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.elementsClass- the class for the elements of the list to retrieve.- Returns:
- the value of the
ith element as a list ofTobjects.
-
getList
public <T> List<T> getList(int i, TypeToken<T> elementsType)
Returns theith value as a list.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a list of the specified type.Use this variant with nested collections, which produce a generic element type:
List<List<String>> l = row.getList(1, new TypeToken<List<String>>() {});Implementation note: the actual
Listimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getListin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.elementsType- the type of the elements of the list to retrieve.- Returns:
- the value of the
ith element as a list ofTobjects.
-
getList
public <T> List<T> getList(String name, Class<T> elementsClass)
Returns the value fornameas a list.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a list of the specified type.If the type of the elements is generic, use
GettableByNameData.getList(String, TypeToken).Implementation note: the actual
Listimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getListin interfaceGettableByNameData- Parameters:
name- the name to retrieve.elementsClass- the class for the elements of the list to retrieve.- Returns:
- the value of the
ith element as a list ofTobjects.
-
getList
public <T> List<T> getList(String name, TypeToken<T> elementsType)
Returns the value fornameas a list.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a list of the specified type.Use this variant with nested collections, which produce a generic element type:
List<List<String>> l = row.getList("theColumn", new TypeToken<List<String>>() {});Implementation note: the actual
Listimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getListin interfaceGettableByNameData- Parameters:
name- the name to retrieve.elementsType- the type for the elements of the list to retrieve.- Returns:
- the value of the
ith element as a list ofTobjects.
-
getSet
public <T> Set<T> getSet(int i, Class<T> elementsClass)
Returns theith value as a set.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a set of the specified type.If the type of the elements is generic, use
GettableByIndexData.getSet(int, TypeToken).Implementation note: the actual
Setimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getSetin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.elementsClass- the class for the elements of the set to retrieve.- Returns:
- the value of the
ith element as a set ofTobjects.
-
getSet
public <T> Set<T> getSet(int i, TypeToken<T> elementsType)
Returns theith value as a set.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a set of the specified type.Use this variant with nested collections, which produce a generic element type:
Set<List<String>> l = row.getSet(1, new TypeToken<List<String>>() {});Implementation note: the actual
Setimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getSetin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.elementsType- the type for the elements of the set to retrieve.- Returns:
- the value of the
ith element as a set ofTobjects.
-
getSet
public <T> Set<T> getSet(String name, Class<T> elementsClass)
Returns the value fornameas a set.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a set of the specified type.If the type of the elements is generic, use
GettableByNameData.getSet(String, TypeToken).Implementation note: the actual
Setimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getSetin interfaceGettableByNameData- Parameters:
name- the name to retrieve.elementsClass- the class for the elements of the set to retrieve.- Returns:
- the value of the
ith element as a set ofTobjects.
-
getSet
public <T> Set<T> getSet(String name, TypeToken<T> elementsType)
Returns the value fornameas a set.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a set of the specified type.Use this variant with nested collections, which produce a generic element type:
Set<List<String>> l = row.getSet("theColumn", new TypeToken<List<String>>() {});Implementation note: the actual
Setimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getSetin interfaceGettableByNameData- Parameters:
name- the name to retrieve.elementsType- the type for the elements of the set to retrieve.- Returns:
- the value of the
ith element as a set ofTobjects.
-
getMap
public <K,V> Map<K,V> getMap(int i, Class<K> keysClass, Class<V> valuesClass)
Returns theith value as a map.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a map of the specified types.If the type of the keys and/or values is generic, use
GettableByIndexData.getMap(int, TypeToken, TypeToken).Implementation note: the actual
Mapimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getMapin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.keysClass- the class for the keys of the map to retrieve.valuesClass- the class for the values of the map to retrieve.- Returns:
- the value of the
ith element as a map ofKtoVobjects.
-
getMap
public <K,V> Map<K,V> getMap(int i, TypeToken<K> keysType, TypeToken<V> valuesType)
Returns theith value as a map.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a map of the specified types.Use this variant with nested collections, which produce a generic element type:
Map<Int, List<String>> l = row.getMap(1, TypeToken.of(Integer.class), new TypeToken<List<String>>() {});Implementation note: the actual
Mapimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getMapin interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.keysType- the type for the keys of the map to retrieve.valuesType- the type for the values of the map to retrieve.- Returns:
- the value of the
ith element as a map ofKtoVobjects.
-
getMap
public <K,V> Map<K,V> getMap(String name, Class<K> keysClass, Class<V> valuesClass)
Returns the value fornameas a map.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a map of the specified types.If the type of the keys and/or values is generic, use
GettableByNameData.getMap(String, TypeToken, TypeToken).Implementation note: the actual
Mapimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getMapin interfaceGettableByNameData- Parameters:
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.- Returns:
- the value of
nameas a map ofKtoVobjects.
-
getMap
public <K,V> Map<K,V> getMap(String name, TypeToken<K> keysType, TypeToken<V> valuesType)
Returns the value fornameas a map.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a map of the specified types.Use this variant with nested collections, which produce a generic element type:
Map<Int, List<String>> l = row.getMap("theColumn", TypeToken.of(Integer.class), new TypeToken<List<String>>() {});Implementation note: the actual
Mapimplementation will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent. By default, the driver will return mutable instances, and a CQLNULLwill mapped to an empty collection (note that Cassandra makes no distinction betweenNULLand an empty collection).- Specified by:
getMapin interfaceGettableByNameData- Parameters:
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.- Returns:
- the value of
nameas a map ofKtoVobjects.
-
getUDTValue
public UDTValue getUDTValue(int i)
Return theith value as a UDT value.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aUDTValue(if the CQL type is a UDT, the registry will generate a codec automatically).- Specified by:
getUDTValuein interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a UDT value. If the value is NULL, thennullwill be returned.
-
getUDTValue
public UDTValue getUDTValue(String name)
Return the value fornameas a UDT value.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aUDTValue(if the CQL type is a UDT, the registry will generate a codec automatically).- Specified by:
getUDTValuein interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value of
nameas a UDT value. If the value is NULL, thennullwill be returned.
-
getTupleValue
public TupleValue getTupleValue(int i)
Return theith value as a tuple value.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aTupleValue(if the CQL type is a tuple, the registry will generate a codec automatically).- Specified by:
getTupleValuein interfaceGettableByIndexData- Parameters:
i- the index (0 <= i < size()) to retrieve.- Returns:
- the value of the
ith element as a tuple value. If the value is NULL, thennullwill be returned.
-
getTupleValue
public TupleValue getTupleValue(String name)
Return the value fornameas a tuple value.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to aTupleValue(if the CQL type is a tuple, the registry will generate a codec automatically).- Specified by:
getTupleValuein interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value of
nameas a tuple value. If the value is NULL, thennullwill be returned.
-
getObject
public Object getObject(int i)
Returns theith value as the Java type matching its CQL type.This method uses the
CodecRegistryto find the first codec that handles the underlying CQL type. The Java type of the returned object will be determined by the codec that was selected.Use this method to dynamically inspect elements when types aren't known in advance, for instance if you're writing a generic row logger. If you know the target Java type, it is generally preferable to use typed getters, such as the ones for built-in types (
GettableByIndexData.getBool(int),GettableByIndexData.getInt(int), etc.), orGettableByIndexData.get(int, Class)andGettableByIndexData.get(int, TypeToken)for custom types.- Specified by:
getObjectin interfaceGettableByIndexData- Parameters:
i- the index to retrieve.- Returns:
- the value of the
ith value as the Java type matching its CQL type. - See Also:
CodecRegistry.codecFor(DataType)
-
getObject
public Object getObject(String name)
Returns the value fornameas the Java type matching its CQL type.This method uses the
CodecRegistryto find the first codec that handles the underlying CQL type. The Java type of the returned object will be determined by the codec that was selected.Use this method to dynamically inspect elements when types aren't known in advance, for instance if you're writing a generic row logger. If you know the target Java type, it is generally preferable to use typed getters, such as the ones for built-in types (
GettableByNameData.getBool(String),GettableByNameData.getInt(String), etc.), orGettableByNameData.get(String, Class)andGettableByNameData.get(String, TypeToken)for custom types.- Specified by:
getObjectin interfaceGettableByNameData- Parameters:
name- the name to retrieve.- Returns:
- the value of
nameas the Java type matching its CQL type. If the value is NULL and is a simple type, UDT or tuple,nullis returned. If it is NULL and is a collection type, an empty (immutable) collection is returned. - See Also:
CodecRegistry.codecFor(DataType)
-
get
public <T> T get(int i, Class<T> targetClass)Returns theith value converted to the given Java type.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to the given Java type.If the target type is generic, use
GettableByIndexData.get(int, TypeToken).Implementation note: the actual object returned by this method will depend on the
codecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent; by default, a CQLNULLvalue translates tonullfor simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types.- Specified by:
getin interfaceGettableByIndexData- Parameters:
i- the index to retrieve.targetClass- The Java type the value should be converted to.- Returns:
- the value of the
ith value converted to the given Java type.
-
get
public <T> T get(String name, Class<T> targetClass)
Returns the value fornameconverted to the given Java type.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to the given Java type.If the target type is generic, use
GettableByNameData.get(String, TypeToken).Implementation note: the actual object returned by this method will depend on the
codecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent; by default, a CQLNULLvalue translates tonullfor simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types.- Specified by:
getin interfaceGettableByNameData- Parameters:
name- the name to retrieve.targetClass- The Java type the value should be converted to.- Returns:
- the value for
namevalue converted to the given Java type.
-
get
public <T> T get(int i, TypeToken<T> targetType)Returns theith value converted to the given Java type.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to the given Java type.Implementation note: the actual object returned by this method will depend on the
codecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent; by default, a CQLNULLvalue translates tonullfor simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types.- Specified by:
getin interfaceGettableByIndexData- Parameters:
i- the index to retrieve.targetType- The Java type the value should be converted to.- Returns:
- the value of the
ith value converted to the given Java type.
-
get
public <T> T get(String name, TypeToken<T> targetType)
Returns the value fornameconverted to the given Java type.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to the given Java type.Implementation note: the actual object returned by this method will depend on the
codecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent; by default, a CQLNULLvalue translates tonullfor simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types.- Specified by:
getin interfaceGettableByNameData- Parameters:
name- the name to retrieve.targetType- The Java type the value should be converted to.- Returns:
- the value for
namevalue converted to the given Java type.
-
get
public <T> T get(int i, TypeCodec<T> codec)Returns theith value converted using the givenTypeCodec.This method entirely bypasses the
CodecRegistryand forces the driver to use the given codec instead. This can be useful if the codec would collide with a previously registered one, or if you want to use the codec just once without registering it.It is the caller's responsibility to ensure that the given codec
acceptsthe underlying CQL type; failing to do so may result inInvalidTypeExceptions being thrown.Implementation note: the actual object returned by this method will depend on the
codecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent; by default, a CQLNULLvalue translates tonullfor simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types.- Specified by:
getin interfaceGettableByIndexData- Parameters:
i- the index to retrieve.codec- TheTypeCodecto use to deserialize the value; may not benull.- Returns:
- the value of the
ith value converted using the givenTypeCodec.
-
get
public <T> T get(String name, TypeCodec<T> codec)
Returns the value fornameconverted using the givenTypeCodec.This method entirely bypasses the
CodecRegistryand forces the driver to use the given codec instead. This can be useful if the codec would collide with a previously registered one, or if you want to use the codec just once without registering it.It is the caller's responsibility to ensure that the given codec
acceptsthe underlying CQL type; failing to do so may result inInvalidTypeExceptions being thrown.Implementation note: the actual object returned by this method will depend on the
codecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety. Furthermore, the behavior of this method in respect to CQLNULLvalues is also codec-dependent; by default, a CQLNULLvalue translates tonullfor simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types.- Specified by:
getin interfaceGettableByNameData- Parameters:
name- the name to retrieve.codec- TheTypeCodecto use to deserialize the value; may not benull.- Returns:
- the value of the
ith value converted using the givenTypeCodec.
-
-