com.datastax.driver.core
Class DataType

java.lang.Object
  extended by com.datastax.driver.core.DataType

public class DataType
extends Object

Data types supported by cassandra.


Nested Class Summary
static class DataType.Name
          The CQL type name.
 
Method Summary
static Set<DataType> allPrimitiveTypes()
          Returns a set of all the primitive types, where primitive types are defined as the types that don't have type arguments (i.e.
static DataType ascii()
          The ASCII type.
 Class<?> asJavaClass()
          The java Class corresponding to this type.
static DataType bigint()
          The BIGINT type.
static DataType blob()
          The BLOB type.
static DataType cboolean()
          The BOOLEAN type.
static DataType cdouble()
          The DOUBLE type.
static DataType cfloat()
          The FLOAT type.
static DataType cint()
          The INT type.
static DataType counter()
          The COUNTER type.
static DataType decimal()
          The DECIMAL type.
 boolean equals(Object o)
           
 DataType.Name getName()
          The name of that type.
 List<DataType> getTypeArguments()
          The type arguments of this type.
 int hashCode()
           
static DataType inet()
          The INET type.
 boolean isCollection()
          Returns whether this type is a collection one, i.e.
static DataType list(DataType elementType)
          The type of lists of elementType elements.
static DataType map(DataType keyType, DataType valueType)
          The type of maps of keyType to valueType elements.
 ByteBuffer parse(String value)
          Parse a string value for the type this object represent, returning its Cassandra binary representation.
static DataType set(DataType elementType)
          The type of sets of elementType elements.
static DataType text()
          The TEXT type.
static DataType timestamp()
          The TIMESTAMP type.
static DataType timeuuid()
          The TIMEUUID type.
 String toString()
           
static DataType uuid()
          The UUID type.
static DataType varchar()
          The VARCHAR type.
static DataType varint()
          The VARINT type.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

ascii

public static DataType ascii()
The ASCII type.

Returns:
The ASCII type.

bigint

public static DataType bigint()
The BIGINT type.

Returns:
The BIGINT type.

blob

public static DataType blob()
The BLOB type.

Returns:
The BLOB type.

cboolean

public static DataType cboolean()
The BOOLEAN type.

Returns:
The BOOLEAN type.

counter

public static DataType counter()
The COUNTER type.

Returns:
The COUNTER type.

decimal

public static DataType decimal()
The DECIMAL type.

Returns:
The DECIMAL type.

cdouble

public static DataType cdouble()
The DOUBLE type.

Returns:
The DOUBLE type.

cfloat

public static DataType cfloat()
The FLOAT type.

Returns:
The FLOAT type.

inet

public static DataType inet()
The INET type.

Returns:
The INET type.

cint

public static DataType cint()
The INT type.

Returns:
The INT type.

text

public static DataType text()
The TEXT type.

Returns:
The TEXT type.

timestamp

public static DataType timestamp()
The TIMESTAMP type.

Returns:
The TIMESTAMP type.

uuid

public static DataType uuid()
The UUID type.

Returns:
The UUID type.

varchar

public static DataType varchar()
The VARCHAR type.

Returns:
The VARCHAR type.

varint

public static DataType varint()
The VARINT type.

Returns:
The VARINT type.

timeuuid

public static DataType timeuuid()
The TIMEUUID type.

Returns:
The TIMEUUID type.

list

public static DataType list(DataType elementType)
The type of lists of elementType elements.

Parameters:
elementType - the type of the list elements.
Returns:
the type of lists of elementType elements.

set

public static DataType set(DataType elementType)
The type of sets of elementType elements.

Parameters:
elementType - the type of the set elements.
Returns:
the type of sets of elementType elements.

map

public static DataType map(DataType keyType,
                           DataType valueType)
The type of maps of keyType to valueType elements.

Parameters:
keyType - the type of the map keys.
valueType - the type of the map values.
Returns:
the type of map of keyType to valueType elements.

getName

public DataType.Name getName()
The name of that type.

Returns:
the name of that type.

getTypeArguments

public List<DataType> getTypeArguments()
The type arguments of this type.

Note that only the collection types (LIST, MAP, SET) have type arguments. For the other types, this will return an empty list.

For the collection types:


parse

public ByteBuffer parse(String value)
Parse a string value for the type this object represent, returning its Cassandra binary representation.

Parameters:
value - the value to parse.
Returns:
the binary representation of value.
Throws:
InvalidTypeException - if value is not a valid string representation for this type.

isCollection

public boolean isCollection()
Returns whether this type is a collection one, i.e. a list, set or map type.

Returns:
whether this type is a collection one.

asJavaClass

public Class<?> asJavaClass()
The java Class corresponding to this type. This is a shortcut for getName().asJavaClass().

Returns:
the java Class corresponding to this type.
See Also:
DataType.Name.asJavaClass()

allPrimitiveTypes

public static Set<DataType> allPrimitiveTypes()
Returns a set of all the primitive types, where primitive types are defined as the types that don't have type arguments (i.e. excluding lists, sets and maps).

Returns:
returns a set of all the primitive types.

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

equals

public final boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.