Interface GettableByNameData
- All Known Subinterfaces:
GettableData
- All Known Implementing Classes:
AbstractGettableData,UDTValue
-
Method Summary
Modifier and TypeMethodDescription<T> TReturns the value fornameconverted to the given Java type.<T> TReturns the value fornameconverted to the given Java type.<T> TReturns the value fornameconverted using the givenTypeCodec.booleanReturns the value fornameas a boolean.byteReturns the value fornameas a byte.Returns the value fornameas a byte array.getBytesUnsafe(String name) Returns the value fornameas a ByteBuffer.Returns the value fornameas a date (without time).getDecimal(String name) Returns the value fornameas a variable length decimal.doubleReturns the value fornameas a double.floatReturns the value fornameas a float.Returns the value fornameas an InetAddress.intReturns the value fornameas an integer.<T> List<T>Returns the value fornameas a list.<T> List<T>Returns the value fornameas a list.longReturns the value fornameas a long.<K,V> Map<K, V> getMap(String name, com.google.common.reflect.TypeToken<K> keysType, com.google.common.reflect.TypeToken<V> valuesType) Returns the value fornameas a map.<K,V> Map<K, V> Returns the value fornameas a map.Returns the value fornameas the Java type matching its CQL type.<T> Set<T>Returns the value fornameas a set.<T> Set<T>Returns the value fornameas a set.shortReturns the value fornameas a short.Returns the value fornameas a string.longReturns the value fornameas a long in nanoseconds since midnight.getTimestamp(String name) Returns the value fornameas a date.getTupleValue(String name) Return the value fornameas a tuple value.getUDTValue(String name) Return the value fornameas a UDT value.Returns the value fornameas a UUID.Returns the value fornameas a variable length integer.<T> List<T>Returns the value fornameas a vector, represented as a Java list.<T> List<T>Returns the value fornameas a vector, represented as a Java list.booleanReturns whether the value fornameis NULL.
-
Method Details
-
isNull
Returns whether the value fornameis NULL.- Parameters:
name- the name to check.- Returns:
- whether the value for
nameis NULL. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.
-
getBool
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).- 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 withisNull(String)or useget(name, Boolean.class). - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a boolean.
-
getByte
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).- 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 withisNull(String)or useget(name, Byte.class).0is returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a byte.
-
getShort
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).- 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 withisNull(String)or useget(name, Short.class).0is returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a short.
-
getInt
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).- 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 withisNull(String)or useget(name, Integer.class).0is returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to an int.
-
getLong
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).- 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 withisNull(String)or useget(name, Long.class). - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a long.
-
getTimestamp
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).- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a date. If the value is NULL,nullis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to aDate.
-
getDate
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).- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a date. If the value is NULL,nullis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to aLocalDate.
-
getTime
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).- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a long. If the value is NULL,0Lis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a long.
-
getFloat
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).- 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 withisNull(String)or useget(name, Float.class). - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a float.
-
getDouble
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).- 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 withisNull(String)or useget(name, Double.class). - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a double.
-
getBytesUnsafe
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.
- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a ByteBuffer. If the value is NULL,nullis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.
-
getBytes
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).- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a byte array. If the value is NULL,nullis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to aByteBuffer.
-
getString
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).- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a string. If the value is NULL,nullis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a string.
-
getVarint
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).- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a variable length integer. If the value is NULL,nullis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to aBigInteger.
-
getDecimal
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).- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a variable length decimal. If the value is NULL,nullis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to aBigDecimal.
-
getUUID
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).- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas a UUID. If the value is NULL,nullis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to aUUID.
-
getInet
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).- Parameters:
name- the name to retrieve.- Returns:
- the value for
nameas an InetAddress. If the value is NULL,nullis returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to aInetAddress.
-
getList
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
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).- 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. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a list.
-
getList
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).- 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. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a list.
-
getSet
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
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).- 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. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a set.
-
getSet
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).- 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. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a set.
-
getMap
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
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).- 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. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a map.
-
getMap
<K,V> Map<K,V> getMap(String name, com.google.common.reflect.TypeToken<K> keysType, com.google.common.reflect.TypeToken<V> valuesType) Returns the value 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).- 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. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a map.
-
getVector
Returns the value fornameas a vector, represented as a Java list.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a vector of the specified type.If the type of the elements is generic, use
getVector(String, TypeToken).Implementation note: the actual
Listimplementation representing the vector will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety.- Parameters:
name- the name to retrieve.elementsClass- the class for the elements of the vector to retrieve.- Returns:
- the value of the
ith element as a vector ofTobjects. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a vector.
-
getVector
Returns the value fornameas a vector, represented as a Java list.This method uses the
CodecRegistryto find a codec to convert the underlying CQL type to a vector of the specified type.Use this variant with nested types, which produce a generic element type:
List<List<String>> l = row.getVector("theColumn", new TypeToken<List<String>>() {});Implementation note: the actual
Listimplementation representing the vector will depend on thecodecbeing used; therefore, callers should make no assumptions concerning its mutability nor its thread-safety.- Parameters:
name- the name to retrieve.elementsType- the type for the elements of the vector to retrieve.- Returns:
- the value of the
ith element as a vector ofTobjects. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to a vector.
-
getUDTValue
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).- Parameters:
name- the name to retrieve.- Returns:
- the value of
nameas a UDT value. If the value is NULL, thennullwill be returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to aUDTValue.
-
getTupleValue
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).- Parameters:
name- the name to retrieve.- Returns:
- the value of
nameas a tuple value. If the value is NULL, thennullwill be returned. - Throws:
IllegalArgumentException- ifnameis not valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type to aTupleValue.
-
getObject
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 (
getBool(String),getInt(String), etc.), orget(String, Class)andget(String, TypeToken)for custom types.- 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. - Throws:
IllegalArgumentException- ifnameis not a valid name for this object.- See Also:
-
get
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
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.- 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. - Throws:
IllegalArgumentException- ifnameis not a valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type totargetClass.
-
get
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.- 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. - Throws:
IllegalArgumentException- ifnameis not a valid name for this object.CodecNotFoundException- if there is no registered codec to convert the underlying CQL type totargetType.
-
get
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.- 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. - Throws:
InvalidTypeException- if the given codec does notacceptthe underlying CQL type.IndexOutOfBoundsException- ifiis not a valid index for this object.
-