T
- The Java array type this codec handlespublic abstract class AbstractArrayCodec<T> extends TypeCodec<T>
TypeCodec.AbstractCollectionCodec<E,C extends Collection<E>>, TypeCodec.AbstractMapCodec<K,V>, TypeCodec.AbstractTupleCodec<T>, TypeCodec.AbstractUDTCodec<T>, TypeCodec.PrimitiveBooleanCodec, TypeCodec.PrimitiveByteCodec, TypeCodec.PrimitiveDoubleCodec, TypeCodec.PrimitiveFloatCodec, TypeCodec.PrimitiveIntCodec, TypeCodec.PrimitiveLongCodec, TypeCodec.PrimitiveShortCodec
Constructor and Description |
---|
AbstractArrayCodec(DataType.CollectionType cqlType,
Class<T> javaClass) |
Modifier and Type | Method and Description |
---|---|
String |
format(T array)
Format the given value as a valid CQL literal according
to the CQL type handled by this codec.
|
protected abstract void |
formatElement(StringBuilder output,
T array,
int index)
Format the
index th element of array to output . |
protected abstract T |
newInstance(int size)
Create a new array instance with the given size.
|
T |
parse(String value)
Parse the given CQL literal into an instance of the Java type
handled by this codec.
|
protected abstract void |
parseElement(String input,
T array,
int index)
Parse the
index th element of array from input . |
accepts, accepts, accepts, accepts, ascii, bigint, blob, cboolean, cdouble, cfloat, cint, counter, custom, date, decimal, deserialize, duration, getCqlType, getJavaType, inet, list, map, serialize, set, smallInt, time, timestamp, timeUUID, tinyInt, toString, tuple, userType, uuid, varchar, varint
public AbstractArrayCodec(DataType.CollectionType cqlType, Class<T> javaClass)
cqlType
- The CQL type. Must be a list type.javaClass
- The Java type. Must be an array class.public String format(T array) throws InvalidTypeException
TypeCodec
"NULL"
for null
inputs.
Implementing this method is not strictly mandatory. It is used:
BuiltStatement
for a detailed
explanation of when this happens);QueryLogger
, if parameter logging is enabled;AggregateMetadata.asCQLQuery(boolean)
;toString()
implementation of some objects (UDTValue
,
TupleValue
, and the internal representation of a ROWS
response),
which may appear in driver logs.format
in class TypeCodec<T>
array
- An instance of T; may be null
.InvalidTypeException
- if the given value does not have the expected typepublic T parse(String value) throws InvalidTypeException
TypeCodec
"NULL"
;
in most cases, implementations should interpret these inputs has equivalent to a null
reference.
Implementing this method is not strictly mandatory: internally, the driver only uses it to
parse the INITCOND when building the metadata of an aggregate function (and in most cases it
will use a built-in codec, unless the INITCOND has a custom type).parse
in class TypeCodec<T>
value
- The CQL string to parse, may be null
or empty.null
on a null input
.InvalidTypeException
- if the given value cannot be parsed into the expected typeprotected abstract T newInstance(int size)
size
- The size of the array to instantiate.protected abstract void formatElement(StringBuilder output, T array, int index)
index
th element of array
to output
.output
- The StringBuilder to write to.array
- The array to read from.index
- The element index.Copyright © 2012–2018. All rights reserved.