T
- The Java type this codec serializes from and deserializes to.public abstract static class TypeCodec.StringParsingCodec<T> extends TypeCodec<T>
TypeCodec.AbstractUUIDCodec, TypeCodec.AsciiCodec, TypeCodec.BigintCodec, TypeCodec.BlobCodec, TypeCodec.BooleanCodec, TypeCodec.CollectionCodec<E,C extends Collection<E>>, TypeCodec.CounterCodec, TypeCodec.CustomCodec, TypeCodec.DateCodec, TypeCodec.DecimalCodec, TypeCodec.DoubleCodec, TypeCodec.EnumIntCodec<E extends Enum<E>>, TypeCodec.EnumStringCodec<E extends Enum<E>>, TypeCodec.FloatCodec, TypeCodec.InetCodec, TypeCodec.IntCodec, TypeCodec.ListCodec<T>, TypeCodec.LongCodec, TypeCodec.MapCodec<K,V>, TypeCodec.MappingCodec<T,U>, TypeCodec.PrimitiveBooleanCodec, TypeCodec.PrimitiveByteCodec, TypeCodec.PrimitiveDoubleCodec, TypeCodec.PrimitiveFloatCodec, TypeCodec.PrimitiveIntCodec, TypeCodec.PrimitiveLongCodec, TypeCodec.PrimitiveShortCodec, TypeCodec.SetCodec<T>, TypeCodec.SmallIntCodec, TypeCodec.StringCodec, TypeCodec.StringParsingCodec<T>, TypeCodec.TimeCodec, TypeCodec.TimestampCodec, TypeCodec.TimeUUIDCodec, TypeCodec.TinyIntCodec, TypeCodec.TupleCodec, TypeCodec.UDTCodec, TypeCodec.UUIDCodec, TypeCodec.VarcharCodec, TypeCodec.VarintCodec
Constructor and Description |
---|
StringParsingCodec(Class<T> javaType) |
StringParsingCodec(TypeCodec<String> innerCodec,
Class<T> javaType) |
StringParsingCodec(TypeCodec<String> innerCodec,
com.google.common.reflect.TypeToken<T> javaType) |
StringParsingCodec(com.google.common.reflect.TypeToken<T> javaType) |
Modifier and Type | Method and Description |
---|---|
T |
deserialize(ByteBuffer bytes,
ProtocolVersion protocolVersion)
Deserialize the given
ByteBuffer instance according to the CQL type
handled by this codec. |
String |
format(T value)
Format the given value as a valid CQL literal according
to the CQL type handled by this codec.
|
protected abstract T |
fromString(String value)
Parse the given string into an object;
no special CQL unquoting should be applied here.
|
T |
parse(String value)
Parse the given CQL literal into an instance of the Java type
handled by this codec.
|
ByteBuffer |
serialize(T value,
ProtocolVersion protocolVersion)
Serialize the given value according to the CQL type
handled by this codec.
|
protected abstract String |
toString(T value)
Return the String representation of the given object;
no special CQL quoting should be applied here.
|
accepts, accepts, accepts, equals, getCqlType, getJavaType, hashCode, toString
public StringParsingCodec(com.google.common.reflect.TypeToken<T> javaType)
public ByteBuffer serialize(T value, ProtocolVersion protocolVersion) throws InvalidTypeException
TypeCodec
Implementation notes:
null
input as
the equivalent of an empty collection.serialize
in class TypeCodec<T>
value
- 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 deserialize(ByteBuffer bytes, 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.deserialize
in class TypeCodec<T>
bytes
- 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 String format(T value) throws InvalidTypeException
TypeCodec
"NULL"
for null
inputs.format
in class TypeCodec<T>
value
- 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.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 String toString(T value)
value
- the value to convert into a stringprotected abstract T fromString(String value)
value
- the string to parseCopyright © 2012–2015. All rights reserved.