Interface AccessibleByName

  • All Superinterfaces:
    AccessibleByIndex, Data
    All Known Subinterfaces:
    Bindable<SelfT>, BoundStatement, GettableByName, ReactiveRow, Row, SettableByName<SelfT>, UdtValue
    All Known Implementing Classes:
    BoundStatementBuilder

    public interface AccessibleByName
    extends AccessibleByIndex
    A data structure where the values are accessible via a name string.

    This is an optimized version of AccessibleById, in case the overhead of having to create a CqlIdentifier for each value is too much.

    By default, case is ignored when matching names. If multiple names only differ by their case, then the first one is chosen. You can force an exact match by double-quoting the name.

    For example, if the data structure contains three values named Foo, foo and fOO, then:

    • getString("foo") retrieves the first value (ignore case, first occurrence).
    • getString("\"foo\"") retrieves the second value (exact case).
    • getString("\"fOO\"") retrieves the third value (exact case).
    • getString("\"FOO\"") fails (exact case, no match).

    In the driver, these data structures are always accessible by index as well.

    • Method Detail

      • allIndicesOf

        @NonNull
        default List<Integer> allIndicesOf​(@NonNull
                                           String name)
        Returns all the indices where a given identifier appears.
        Throws:
        IllegalArgumentException - if the name is invalid.
        API note:
        the default implementation only exists for backward compatibility. It wraps the result of firstIndexOf(String) in a singleton list, which is not entirely correct, as it will only return the first occurrence. Therefore it also logs a warning.

        Implementors should always override this method (all built-in driver implementations do).

      • firstIndexOf

        int firstIndexOf​(@NonNull
                         String name)
        Returns the first index where a given identifier appears (depending on the implementation, identifiers may appear multiple times).
        Throws:
        IllegalArgumentException - if the name is invalid.
      • getType

        @NonNull
        DataType getType​(@NonNull
                         String name)
        Returns the CQL type of the value for the first occurrence of name.

        This method deals with case sensitivity in the way explained in the documentation of GettableByName.

        Throws:
        IllegalArgumentException - if the name is invalid.