V - the type of data being decodedpublic abstract class DataDecoder<V> extends Object
DataDecoder abstract class defines the decoding functionality
for a column.
Supported conversions are:
- "ascii" to Enum, Class, Locale, ZoneId, or String
- "bigint" to Long
- "blob" to byte[] or ByteBuffer
- "boolean" to Boolean
- "counter" to AtomicLong or Long
- "decimal" to BigDecimal
- "double" to Double
- "float" to Float
- "inet" to InetAddress
- "int" to Integer
- "text" to String
- "timestamp" to Date, Instant, or Long
- "uuid" to UUID
- "varchar" to String
- "varint" to BigInteger
- "timeuuid" to UUID
- "list<ctype>" to List of the corresponding element type
- "map<ctype, ctype>" to Map of the corresponding element types
- "set<ctype>" to Set of the corresponding element type
- "frozen<udt>" to an object of the user-defined type
| Modifier and Type | Field and Description |
|---|---|
static DataDecoder<Class> |
asciiToClass
Holds the "ascii" to
Class decoder. |
static DataDecoder<Enum> |
asciiToEnum
Holds the "ascii" to
Enum decoder. |
static DataDecoder<Locale> |
asciiToLocale
Holds the "ascii" to
Locale decoder. |
static DataDecoder<String> |
asciiToString
Holds the "ascii" to
String decoder. |
static DataDecoder<java.time.ZoneId> |
asciiToZoneId
Holds the "ascii" to
ZoneId decoder. |
static DataDecoder<Long> |
bigintToLong
Holds the "bigint" to
Long decoder. |
static DataDecoder<byte[]> |
blobToByteArray
Holds the "blob" to
byte[] decoder. |
static DataDecoder<ByteBuffer> |
blobToByteBuffer
Holds the "blob" to
ByteBuffer decoder. |
static DataDecoder<Boolean> |
booleanToBoolean
Holds the "boolean" to
Boolean decoder. |
static DataDecoder<AtomicLong> |
counterToAtomicLong
Holds the "counter" to
AtomicLong decoder. |
static DataDecoder<Long> |
counterToLong
Holds the "counter" to
Long decoder. |
static DataDecoder<BigDecimal> |
decimalToBigDecimal
Holds the "decimal" to
BigDecimal decoder. |
static DataDecoder<Double> |
doubleToDouble
Holds the "double" to
Double decoder. |
static DataDecoder<Float> |
floatToFloat
Holds the "float" to
Float decoder. |
static DataDecoder<InetAddress> |
inetToInetAddress
Holds the "inet" to
InetAddress decoder. |
static DataDecoder<Integer> |
intToInteger
Holds the "int" to
Integer decoder. |
static DataDecoder<String> |
textToString
Holds the "text" to
String decoder. |
static DataDecoder<Date> |
timestampToDate
Holds the "timestamp" to
Date decoder. |
static DataDecoder<java.time.Instant> |
timestampToInstant
Holds the "timestamp" to
Instant decoder. |
static DataDecoder<Long> |
timestampToLong
Holds the "timestamp" to
Long decoder. |
static DataDecoder<UUID> |
timeuuidToUUID
Holds the "timeuuid" to
UUID decoder. |
static DataDecoder<UUID> |
uuidToUUID
Holds the "uuid" to
UUID decoder. |
static DataDecoder<String> |
varcharToString
Holds the "varchar" to
String decoder. |
static DataDecoder<BigInteger> |
varintToBigInteger
Holds the "varint" to
BigInteger decoder. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canDecodeTo(Class<?> clazz)
Checks if this decoder can decode to the specified class.
|
V |
decode(com.datastax.driver.core.Row row,
String name,
Class<V> clazz)
Decodes the specified column from the given row and return the value that
matches the decoder's defined class.
|
V |
decode(com.datastax.driver.core.UDTValue uval,
String name,
Class<V> clazz)
Decodes the specified column from the given UDT value and return the value
that matches the decoder's defined class.
|
protected abstract V |
decodeImpl(com.datastax.driver.core.Row row,
String name,
Class<V> clazz)
Decodes the specified column from the given row and return the value that
matches the decoder's defined class.
|
protected abstract V |
decodeImpl(com.datastax.driver.core.UDTValue uval,
String name,
Class<V> clazz)
Decodes the specified column from the given UDT value and return the value
that matches the decoder's defined class.
|
static Class<?> |
findClass(String name)
Finds and loads the specified class.
|
static DataDecoder<List> |
list(Class<?> eclazz,
boolean mandatory)
Gets a "list" to
List decoder based on the given element class. |
static DataDecoder<Map> |
map(Class<?> ekclazz,
Class<?> evclazz,
boolean mandatory)
Gets a "map" to
Map decoder based on the given key and value classes. |
static DataDecoder<LinkedHashSet> |
orderedSet(Class<?> eclazz,
boolean mandatory)
Gets a "list" to
Set decoder based on the given element class. |
static DataDecoder<Set> |
set(Class<?> eclazz,
boolean mandatory)
Gets a "set" to
Set decoder based on the given element class. |
static DataDecoder<SortedMap> |
sortedMap(Class<?> ekclazz,
Class<?> evclazz,
boolean mandatory)
Gets a "map" to
SortedMap decoder based on the given key and value classes. |
static DataDecoder<Object> |
udt(UDTClassInfoImpl<?> cinfo)
Gets a "udt" to
Object decoder based on the given UDT class info. |
public static final DataDecoder<String> asciiToString
String decoder.public static final DataDecoder<Enum> asciiToEnum
Enum decoder.public static final DataDecoder<Class> asciiToClass
Class decoder.public static final DataDecoder<Locale> asciiToLocale
Locale decoder.public static final DataDecoder<java.time.ZoneId> asciiToZoneId
ZoneId decoder.public static final DataDecoder<Long> bigintToLong
Long decoder.public static final DataDecoder<byte[]> blobToByteArray
byte[] decoder.public static final DataDecoder<ByteBuffer> blobToByteBuffer
ByteBuffer decoder.public static final DataDecoder<Boolean> booleanToBoolean
Boolean decoder.public static final DataDecoder<Long> counterToLong
Long decoder.public static final DataDecoder<AtomicLong> counterToAtomicLong
AtomicLong decoder.public static final DataDecoder<BigDecimal> decimalToBigDecimal
BigDecimal decoder.public static final DataDecoder<Double> doubleToDouble
Double decoder.public static final DataDecoder<Float> floatToFloat
Float decoder.public static final DataDecoder<InetAddress> inetToInetAddress
InetAddress decoder.public static final DataDecoder<Integer> intToInteger
Integer decoder.public static final DataDecoder<String> textToString
String decoder.public static final DataDecoder<Date> timestampToDate
Date decoder.public static final DataDecoder<java.time.Instant> timestampToInstant
Instant decoder.public static final DataDecoder<Long> timestampToLong
Long decoder.public static final DataDecoder<UUID> uuidToUUID
UUID decoder.public static final DataDecoder<String> varcharToString
String decoder.public static final DataDecoder<BigInteger> varintToBigInteger
BigInteger decoder.public static final DataDecoder<UUID> timeuuidToUUID
UUID decoder.public static Class<?> findClass(String name) throws ClassNotFoundException
Note: This method is designed to use the thread context class loader if set; otherwise it falls back to the primordial class loader.
name - the name of the class to find and loadnull classLinkageError - if the linkage failsExceptionInInitializerError - if the initialization provoked by this
method failsClassNotFoundException - if the class cannot be locatedpublic static final DataDecoder<List> list(Class<?> eclazz, boolean mandatory)
List decoder based on the given element class.eclazz - the non-null class of elementsmandatory - if the field associated with the decoder is mandatory or
represents a primary keynull decoder for lists of the specified element
classpublic static final DataDecoder<Set> set(Class<?> eclazz, boolean mandatory)
Set decoder based on the given element class.eclazz - the non-null class of elementsmandatory - if the field associated with the decoder is mandatory or
represents a primary keynull decoder for sets of the specified element
classpublic static final DataDecoder<LinkedHashSet> orderedSet(Class<?> eclazz, boolean mandatory)
Set decoder based on the given element class.eclazz - the non-null class of elementsmandatory - if the field associated with the decoder is mandatory or
represents a primary keynull decoder for sets of the specified element
classpublic static final DataDecoder<Map> map(Class<?> ekclazz, Class<?> evclazz, boolean mandatory)
Map decoder based on the given key and value classes.ekclazz - the non-null class of keysevclazz - the non-null class of valuesmandatory - if the field associated with the decoder is mandatory or
represents a primary keynull decoder for maps of the specified key and
value classespublic static final DataDecoder<SortedMap> sortedMap(Class<?> ekclazz, Class<?> evclazz, boolean mandatory)
SortedMap decoder based on the given key and value classes.ekclazz - the non-null class of keysevclazz - the non-null class of valuesmandatory - if the field associated with the decoder is mandatory or
represents a primary keynull decoder for sorted maps of the specified key and
value classespublic static final DataDecoder<Object> udt(UDTClassInfoImpl<?> cinfo)
Object decoder based on the given UDT class info.cinfo - the user-defined class infonull decoder for user-defined types represented
by the given class infoprotected abstract V decodeImpl(com.datastax.driver.core.Row row, String name, Class<V> clazz)
row - the non-null row where the column value is definedname - the non-null name of the column to decodeclazz - the non-null class to decode toIllegalArgumentException - if decoding to clazz is not
supported or if name is not part of the
result set this row is part ofcom.datastax.driver.core.exceptions.InvalidTypeException - if column name type is not the
expected oneprotected abstract V decodeImpl(com.datastax.driver.core.UDTValue uval, String name, Class<V> clazz)
uval - the non-null UDT value where the column value is
definedname - the non-null name of the column to decodeclazz - the non-null class to decode toIllegalArgumentException - if decoding to clazz is not
supported or if name is not part of the
UDT valuecom.datastax.driver.core.exceptions.InvalidTypeException - if column name type is not the
expected onepublic boolean canDecodeTo(Class<?> clazz)
clazz - the class to check if the decoder can decode totrue if this decoder can decode to the specified class;
false otherwisepublic V decode(com.datastax.driver.core.Row row, String name, Class<V> clazz)
row - the non-null row where the column value is definedname - the non-null name of the column to decodeclazz - the class to decode tonull if the specified column
doesn't exist in the rowsNullPointerException - if row, name, or
clazz is nullIllegalArgumentException - if decoding to clazz is not
supported or if name is not part of the
result set this row is part ofcom.datastax.driver.core.exceptions.InvalidTypeException - if column name type is not the
expected onepublic V decode(com.datastax.driver.core.UDTValue uval, String name, Class<V> clazz)
uval - the non-null UDT value where the column value is
definedname - the non-null name of the column to decodeclazz - the class to decode tonull if the specified column
doesn't exist in the UDT valueNullPointerException - if uval, name, or
clazz is nullIllegalArgumentException - if decoding to clazz is not
supported or if name is not part of the UDT valuecom.datastax.driver.core.exceptions.InvalidTypeException - if column name type is not the
expected oneCopyright (C) 2015-2015 The Helenus Driver Project Authors.