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
Modifier and Type | Field and Description |
---|---|
static String |
CLASS_NAME
The name of the server-side type handled by this codec.
|
static DataType.CustomType |
DATA_TYPE
The datatype handled by this codec.
|
static PointCodec |
INSTANCE
The unique (stateless and thread-safe) instance of this codec.
|
Modifier and Type | Method and Description |
---|---|
T |
deserialize(ByteBuffer bb,
ProtocolVersion protocolVersion)
Deserialize the given
ByteBuffer instance according to the CQL type
handled by this codec. |
String |
format(T geometry)
Format the given value as a valid CQL literal according
to the CQL type handled by this codec.
|
protected Point |
fromWellKnownBinary(ByteBuffer source)
Creates an instance of a geospatial type from
its Well-known Binary (WKB)
representation.
|
protected Point |
fromWellKnownText(String source)
Creates an instance of this codec's geospatial type from
its Well-known Text (WKT)
representation.
|
T |
parse(String s)
Parse the given CQL literal into an instance of the Java type
handled by this codec.
|
ByteBuffer |
serialize(T geometry,
ProtocolVersion protocolVersion)
Serialize the given value according to the CQL type
handled by this codec.
|
protected ByteBuffer |
toWellKnownBinary(Point geometry)
Returns a Well-known Binary (WKB)
representation of the given geospatial object.
|
protected String |
toWellKnownText(Point geometry)
Returns a Well-known Text (WKT)
representation of the given geospatial object.
|
accepts, accepts, accepts, accepts, ascii, bigint, blob, cboolean, cdouble, cfloat, cint, counter, custom, date, decimal, getCqlType, getJavaType, inet, list, map, set, smallInt, time, timestamp, timeUUID, tinyInt, toString, tuple, userType, uuid, varchar, varint
public static final String CLASS_NAME
public static final DataType.CustomType DATA_TYPE
public static final PointCodec INSTANCE
protected String toWellKnownText(Point geometry)
geometry
- the geospatial object to convert. Cannot be null.protected ByteBuffer toWellKnownBinary(Point geometry)
geometry
- the geospatial object to convert. Cannot be null.protected Point fromWellKnownText(String source)
source
- the Well-known Text representation to parse. Cannot be null.protected Point fromWellKnownBinary(ByteBuffer source)
source
- the Well-known Binary representation to parse. Cannot be null.public T deserialize(ByteBuffer bb, ProtocolVersion protocolVersion) throws InvalidTypeException
TypeCodec
ByteBuffer
instance according to the CQL type
handled by this codec.
Implementation notes:
null
or a default value for the corresponding Java type, if applicable;null
;
they should return empty collections instead (the driver's default collection codecs all comply with this rule).ByteBuffer
should never be consumed by read operations that
modify its current position; if necessary,
ByteBuffer.duplicate()
duplicate} it before consuming.deserialize
in class TypeCodec<T extends Geometry>
bb
- A ByteBuffer
instance containing the serialized form of T;
may be null
or empty.protocolVersion
- the protocol version to use when serializing
bytes
. In most cases, the proper value to provide for this argument
is the value returned by ProtocolOptions.getProtocolVersion()
(which
is the protocol version in use by the driver).InvalidTypeException
- if the given ByteBuffer
instance cannot be deserializedpublic ByteBuffer serialize(T geometry, ProtocolVersion protocolVersion) throws InvalidTypeException
TypeCodec
null
input as
the equivalent of an empty collection.serialize
in class TypeCodec<T extends Geometry>
geometry
- An instance of T; may be null
.protocolVersion
- the protocol version to use when serializing
bytes
. In most cases, the proper value to provide for this argument
is the value returned by ProtocolOptions.getProtocolVersion()
(which
is the protocol version in use by the driver).ByteBuffer
instance containing the serialized form of TInvalidTypeException
- if the given value does not have the expected typepublic T parse(String s) 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 extends Geometry>
s
- 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 typepublic String format(T geometry) 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 extends Geometry>
geometry
- An instance of T; may be null
.InvalidTypeException
- if the given value does not have the expected type