Interface GettableByIndex

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      default <ValueT> ValueT get​(int i, TypeCodec<ValueT> codec)
      Returns the ith value, using the given codec for the conversion.
      default <ValueT> ValueT get​(int i, GenericType<ValueT> targetType)
      Returns the ith value, converting it to the given Java type.
      default <ValueT> ValueT get​(int i, Class<ValueT> targetClass)
      Returns the ith value, converting it to the given Java type.
      default BigDecimal getBigDecimal​(int i)
      Returns the ith value as a Java big decimal.
      default BigInteger getBigInteger​(int i)
      Returns the ith value as a Java big integer.
      default boolean getBool​(int i)
      Deprecated.
      this method only exists to ease the transition from driver 3, it is an alias for getBoolean(int).
      default boolean getBoolean​(int i)
      Returns the ith value as a Java primitive boolean.
      default byte getByte​(int i)
      Returns the ith value as a Java primitive byte.
      default ByteBuffer getByteBuffer​(int i)
      Returns the ith value as a Java byte buffer.
      ByteBuffer getBytesUnsafe​(int i)
      Returns the raw binary representation of the ith value.
      default CqlDuration getCqlDuration​(int i)
      Returns the ith value as a duration.
      default double getDouble​(int i)
      Returns the ith value as a Java primitive double.
      default float getFloat​(int i)
      Returns the ith value as a Java primitive float.
      default InetAddress getInetAddress​(int i)
      Returns the ith value as a Java IP address.
      default Instant getInstant​(int i)
      Returns the ith value as a Java instant.
      default int getInt​(int i)
      Returns the ith value as a Java primitive integer.
      default <ElementT> List<ElementT> getList​(int i, Class<ElementT> elementsClass)
      Returns the ith value as a Java list.
      default LocalDate getLocalDate​(int i)
      Returns the ith value as a Java local date.
      default LocalTime getLocalTime​(int i)
      Returns the ith value as a Java local time.
      default long getLong​(int i)
      Returns the ith value as a Java primitive long.
      default <KeyT,​ValueT>
      Map<KeyT,​ValueT>
      getMap​(int i, Class<KeyT> keyClass, Class<ValueT> valueClass)
      Returns the ith value as a Java map.
      default Object getObject​(int i)
      Returns the ith value, converting it to the most appropriate Java type.
      default <ElementT> Set<ElementT> getSet​(int i, Class<ElementT> elementsClass)
      Returns the ith value as a Java set.
      default short getShort​(int i)
      Returns the ith value as a Java primitive short.
      default String getString​(int i)
      Returns the ith value as a Java string.
      default Token getToken​(int i)
      Returns the ith value as a token.
      default TupleValue getTupleValue​(int i)
      Returns the ith value as a tuple value.
      default UdtValue getUdtValue​(int i)
      Returns the ith value as a user defined type value.
      default UUID getUuid​(int i)
      Returns the ith value as a Java UUID.
      default <ElementT> CqlVector<ElementT> getVector​(int i, Class<ElementT> elementsClass)
      Returns the ith value as a vector.
      default boolean isNull​(int i)
      Indicates whether the ith value is a CQL NULL.
    • Method Detail

      • getBytesUnsafe

        @Nullable
        ByteBuffer getBytesUnsafe​(int i)
        Returns the raw binary representation of the ith value.

        This is primarily for internal use; you'll likely want to use one of the typed getters instead, to get a higher-level Java representation.

        Returns:
        the raw value, or null if the CQL value is NULL. For performance reasons, this is the actual instance used internally. If you read data from the buffer, make sure to duplicate it beforehand, or only use relative methods. If you change the buffer's index or its contents in any way, any other getter invocation for this value will have unpredictable results.
        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • isNull

        default boolean isNull​(int i)
        Indicates whether the ith value is a CQL NULL.
        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • get

        @Nullable
        default <ValueT> ValueT get​(int i,
                                    TypeCodec<ValueT> codec)
        Returns the ith value, using the given codec for the conversion.

        This method completely bypasses the Data.codecRegistry(), and forces the driver to use the given codec instead. This can be useful if the codec would collide with a previously registered one, or if you want to use the codec just once without registering it.

        It is the caller's responsibility to ensure that the given codec is appropriate for the conversion. Failing to do so will result in errors at runtime.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • get

        @Nullable
        default <ValueT> ValueT get​(int i,
                                    GenericType<ValueT> targetType)
        Returns the ith value, converting it to the given Java type.

        The Data.codecRegistry() will be used to look up a codec to handle the conversion.

        This variant is for generic Java types. If the target type is not generic, use get(int, Class) instead, which may perform slightly better.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
        CodecNotFoundException - if no codec can perform the conversion.
      • getObject

        @Nullable
        default Object getObject​(int i)
        Returns the ith value, converting it to the most appropriate Java type.

        The Data.codecRegistry() will be used to look up a codec to handle the conversion.

        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 variants, such as the ones for built-in types (getBoolean(int), getInt(int), etc.), or get(int, Class) and get(int, GenericType) for custom types.

        The definition of "most appropriate" is unspecified, and left to the appreciation of the Data.codecRegistry() implementation. By default, the driver uses the mapping described in the other getXxx() methods (for example String for text, varchar and ascii, etc).

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
        CodecNotFoundException - if no codec can perform the conversion.
      • getBoolean

        default boolean getBoolean​(int i)
        Returns the ith value as a Java primitive boolean.

        By default, this works with CQL type boolean.

        Note that, due to its signature, this method cannot return null. If the CQL value is NULL, it will return false. If this doesn't work for you, either call isNull(int) before calling this method, or use get(i, Boolean.class) instead.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getBool

        @Deprecated
        default boolean getBool​(int i)
        Deprecated.
        this method only exists to ease the transition from driver 3, it is an alias for getBoolean(int).
      • getByte

        default byte getByte​(int i)
        Returns the ith value as a Java primitive byte.

        By default, this works with CQL type tinyint.

        Note that, due to its signature, this method cannot return null. If the CQL value is NULL, it will return 0. If this doesn't work for you, either call isNull(int) before calling this method, or use get(i, Byte.class) instead.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getDouble

        default double getDouble​(int i)
        Returns the ith value as a Java primitive double.

        By default, this works with CQL type double.

        Note that, due to its signature, this method cannot return null. If the CQL value is NULL, it will return 0.0. If this doesn't work for you, either call isNull(int) before calling this method, or use get(i, Double.class) instead.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getFloat

        default float getFloat​(int i)
        Returns the ith value as a Java primitive float.

        By default, this works with CQL type float.

        Note that, due to its signature, this method cannot return null. If the CQL value is NULL, it will return 0.0. If this doesn't work for you, either call isNull(int) before calling this method, or use get(i, Float.class) instead.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getInt

        default int getInt​(int i)
        Returns the ith value as a Java primitive integer.

        By default, this works with CQL type int.

        Note that, due to its signature, this method cannot return null. If the CQL value is NULL, it will return 0. If this doesn't work for you, either call isNull(int) before calling this method, or use get(i, Integer.class) instead.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getLong

        default long getLong​(int i)
        Returns the ith value as a Java primitive long.

        By default, this works with CQL types bigint and counter.

        Note that, due to its signature, this method cannot return null. If the CQL value is NULL, it will return 0. If this doesn't work for you, either call isNull(int) before calling this method, or use get(i, Long.class) instead.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getShort

        default short getShort​(int i)
        Returns the ith value as a Java primitive short.

        By default, this works with CQL type smallint.

        Note that, due to its signature, this method cannot return null. If the CQL value is NULL, it will return 0. If this doesn't work for you, either call isNull(int) before calling this method, or use get(i, Short.class) instead.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getInstant

        @Nullable
        default Instant getInstant​(int i)
        Returns the ith value as a Java instant.

        By default, this works with CQL type timestamp.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getLocalDate

        @Nullable
        default LocalDate getLocalDate​(int i)
        Returns the ith value as a Java local date.

        By default, this works with CQL type date.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getLocalTime

        @Nullable
        default LocalTime getLocalTime​(int i)
        Returns the ith value as a Java local time.

        By default, this works with CQL type time.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getByteBuffer

        @Nullable
        default ByteBuffer getByteBuffer​(int i)
        Returns the ith value as a Java byte buffer.

        By default, this works with CQL type blob.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getString

        @Nullable
        default String getString​(int i)
        Returns the ith value as a Java string.

        By default, this works with CQL types text, varchar and ascii.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getBigInteger

        @Nullable
        default BigInteger getBigInteger​(int i)
        Returns the ith value as a Java big integer.

        By default, this works with CQL type varint.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getBigDecimal

        @Nullable
        default BigDecimal getBigDecimal​(int i)
        Returns the ith value as a Java big decimal.

        By default, this works with CQL type decimal.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getUuid

        @Nullable
        default UUID getUuid​(int i)
        Returns the ith value as a Java UUID.

        By default, this works with CQL types uuid and timeuuid.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getInetAddress

        @Nullable
        default InetAddress getInetAddress​(int i)
        Returns the ith value as a Java IP address.

        By default, this works with CQL type inet.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getCqlDuration

        @Nullable
        default CqlDuration getCqlDuration​(int i)
        Returns the ith value as a duration.

        By default, this works with CQL type duration.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getVector

        @Nullable
        default <ElementT> CqlVector<ElementT> getVector​(int i,
                                                         @NonNull
                                                         Class<ElementT> elementsClass)
        Returns the ith value as a vector.

        By default, this works with CQL type vector.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getToken

        @Nullable
        default Token getToken​(int i)
        Returns the ith value as a token.

        Note that, for simplicity, this method relies on the CQL type of the column to pick the correct token implementation. Therefore it must only be called on columns of the type that matches the partitioner in use for this cluster: bigint for Murmur3Partitioner, blob for ByteOrderedPartitioner, and varint for RandomPartitioner. Calling it for the wrong type will produce corrupt tokens that are unusable with this driver instance.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
        IllegalArgumentException - if the column type can not be converted to a known token type.
      • getList

        @Nullable
        default <ElementT> List<ElementT> getList​(int i,
                                                  @NonNull
                                                  Class<ElementT> elementsClass)
        Returns the ith value as a Java list.

        By default, this works with CQL type list.

        This method is provided for convenience when the element type is a non-generic type. For more complex list types, use get(int, GenericType).

        Apache Cassandra does not make any distinction between an empty collection and null. Whether this method will return an empty collection or null will depend on the codec used; by default, the driver's built-in codecs all return empty collections.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getSet

        @Nullable
        default <ElementT> Set<ElementT> getSet​(int i,
                                                @NonNull
                                                Class<ElementT> elementsClass)
        Returns the ith value as a Java set.

        By default, this works with CQL type set.

        This method is provided for convenience when the element type is a non-generic type. For more complex set types, use get(int, GenericType).

        Apache Cassandra does not make any distinction between an empty collection and null. Whether this method will return an empty collection or null will depend on the codec used; by default, the driver's built-in codecs all return empty collections.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getMap

        @Nullable
        default <KeyT,​ValueT> Map<KeyT,​ValueT> getMap​(int i,
                                                                  @NonNull
                                                                  Class<KeyT> keyClass,
                                                                  @NonNull
                                                                  Class<ValueT> valueClass)
        Returns the ith value as a Java map.

        By default, this works with CQL type map.

        This method is provided for convenience when the element type is a non-generic type. For more complex map types, use get(int, GenericType).

        Apache Cassandra does not make any distinction between an empty collection and null. Whether this method will return an empty collection or null will depend on the codec used; by default, the driver's built-in codecs all return empty collections.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getUdtValue

        @Nullable
        default UdtValue getUdtValue​(int i)
        Returns the ith value as a user defined type value.

        By default, this works with CQL user-defined types.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • getTupleValue

        @Nullable
        default TupleValue getTupleValue​(int i)
        Returns the ith value as a tuple value.

        By default, this works with CQL tuples.

        Throws:
        IndexOutOfBoundsException - if the index is invalid.