T - The Java type this codec serializes from and deserializes to.public abstract class ParsingCodec<T>
extends com.datastax.driver.core.TypeCodec<T>
TypeCodec that stores JAVA objects as serialized strings.
This can serve as a base for codecs dealing with XML or JSON formats.
This codec can be seen as a convenience base class to help
implementing Java-to-XML or Java-to-JSON mappings, but it comes
with a performance penalty: each Java object is serialized
in two steps: first to a String, and then to a ByteBuffer,
which means that each serialization actually incurs in two potentially
expensive operations being carried.
If you are using an XML or JSON library that supports writing Java objects
directly to ByteBuffers, consider writing your own codec instead of
using this one.com.datastax.driver.core.TypeCodec.AbstractCollectionCodec<E,C extends Collection<E>>, com.datastax.driver.core.TypeCodec.AbstractMapCodec<K,V>, com.datastax.driver.core.TypeCodec.AbstractTupleCodec<T>, com.datastax.driver.core.TypeCodec.AbstractUDTCodec<T>, com.datastax.driver.core.TypeCodec.PrimitiveBooleanCodec, com.datastax.driver.core.TypeCodec.PrimitiveByteCodec, com.datastax.driver.core.TypeCodec.PrimitiveDoubleCodec, com.datastax.driver.core.TypeCodec.PrimitiveFloatCodec, com.datastax.driver.core.TypeCodec.PrimitiveIntCodec, com.datastax.driver.core.TypeCodec.PrimitiveLongCodec, com.datastax.driver.core.TypeCodec.PrimitiveShortCodec| Constructor and Description |
|---|
ParsingCodec(Class<T> javaType) |
ParsingCodec(com.datastax.driver.core.TypeCodec<String> innerCodec,
Class<T> javaType) |
ParsingCodec(com.datastax.driver.core.TypeCodec<String> innerCodec,
TypeToken<T> javaType) |
ParsingCodec(TypeToken<T> javaType) |
| Modifier and Type | Method and Description |
|---|---|
T |
deserialize(ByteBuffer bytes,
com.datastax.driver.core.ProtocolVersion protocolVersion) |
String |
format(T value) |
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) |
ByteBuffer |
serialize(T value,
com.datastax.driver.core.ProtocolVersion protocolVersion) |
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, 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, varintpublic ParsingCodec(com.datastax.driver.core.TypeCodec<String> innerCodec, Class<T> javaType)
public ByteBuffer serialize(T value, com.datastax.driver.core.ProtocolVersion protocolVersion) throws com.datastax.driver.core.exceptions.InvalidTypeException
serialize in class com.datastax.driver.core.TypeCodec<T>com.datastax.driver.core.exceptions.InvalidTypeExceptionpublic T deserialize(ByteBuffer bytes, com.datastax.driver.core.ProtocolVersion protocolVersion) throws com.datastax.driver.core.exceptions.InvalidTypeException
deserialize in class com.datastax.driver.core.TypeCodec<T>com.datastax.driver.core.exceptions.InvalidTypeExceptionpublic String format(T value) throws com.datastax.driver.core.exceptions.InvalidTypeException
format in class com.datastax.driver.core.TypeCodec<T>com.datastax.driver.core.exceptions.InvalidTypeExceptionpublic T parse(String value) throws com.datastax.driver.core.exceptions.InvalidTypeException
parse in class com.datastax.driver.core.TypeCodec<T>com.datastax.driver.core.exceptions.InvalidTypeExceptionprotected abstract String toString(T value)
value - the value to convert into a stringprotected abstract T fromString(String value)
value - the string to parseCopyright © 2012–2018. All rights reserved.