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 aCqlIdentifierfor 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,fooandfOO, 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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default List<Integer>allIndicesOf(String name)Returns all the indices where a given identifier appears.intfirstIndexOf(String name)Returns the first index where a given identifier appears (depending on the implementation, identifiers may appear multiple times).DataTypegetType(String name)Returns the CQL type of the value for the first occurrence ofname.-
Methods inherited from interface com.datastax.oss.driver.api.core.data.AccessibleByIndex
getType, size
-
Methods inherited from interface com.datastax.oss.driver.api.core.data.Data
codecRegistry, protocolVersion
-
-
-
-
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 ofname.This method deals with case sensitivity in the way explained in the documentation of
GettableByName.- Throws:
IllegalArgumentException- if the name is invalid.
-
-