本文整理匯總了Java中com.datastax.driver.core.DataType.Name方法的典型用法代碼示例。如果您正苦於以下問題:Java DataType.Name方法的具體用法?Java DataType.Name怎麽用?Java DataType.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.datastax.driver.core.DataType
的用法示例。
在下文中一共展示了DataType.Name方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getValueFromObject
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/**
* Gets field value as an object having Cassandra compatible type.
* This it could be stored directly into Cassandra without any conversions.
*
* @param obj Object instance.
* @param serializer {@link org.apache.ignite.cache.store.cassandra.serializer.Serializer} to use.
* @return Object to store in Cassandra table column.
*/
public Object getValueFromObject(Object obj, Serializer serializer) {
Object val = accessor.getValue(obj);
if (val == null)
return null;
DataType.Name cassandraType = PropertyMappingHelper.getCassandraType(val.getClass());
if (cassandraType != null)
return val;
if (serializer == null) {
throw new IllegalStateException("Can't serialize value from object '" +
val.getClass().getName() + "' field '" + name + "', cause there is no BLOB serializer specified");
}
return serializer.serialize(val);
}
示例2: isNumber
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static boolean isNumber(DataType.Name name) {
switch (name) {
case BIGINT:
case VARINT:
case INT:
case DECIMAL:
case FLOAT:
case DOUBLE:
case COUNTER:
return true;
}
return DataTypeHelper.isSmallInt(name)
|| DataTypeHelper.isTinyInt(name)
|| DataTypeHelper.isTime(name);
}
示例3: init
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/**
* Initializes field info from property descriptor.
*
* @param accessor {@link PojoFieldAccessor} accessor.
*/
private void init(PojoFieldAccessor accessor) {
DataType.Name cassandraType = PropertyMappingHelper.getCassandraType(accessor.getFieldType());
cassandraType = cassandraType == null ? DataType.Name.BLOB : cassandraType;
this.colDDL = "\"" + col + "\" " + cassandraType.toString();
this.accessor = accessor;
}
示例4: isCassandraCompatibleTypes
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/**
* Checks if two Java classes are Cassandra compatible - mapped to the same Cassandra type.
*
* @param type1 First type.
* @param type2 Second type.
* @return {@code true} if classes are compatible and {@code false} if not.
*/
public static boolean isCassandraCompatibleTypes(Class type1, Class type2) {
if (type1 == null || type2 == null)
return false;
DataType.Name t1 = PropertyMappingHelper.getCassandraType(type1);
DataType.Name t2 = PropertyMappingHelper.getCassandraType(type2);
return t1 != null && t2 != null && t1.equals(t2);
}
示例5: checkType
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
DataType.Name checkType(int i, DataType.Name name1, DataType.Name name2) {
DataType defined = getType(i);
if (name1 != defined.getName() && name2 != defined.getName())
throw new InvalidTypeException(String.format("Column %s is of type %s", getName(i), defined));
return defined.getName();
}
示例6: validateName
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private DataType.Name validateName(DataType dataType) {
final DataType.Name name = dataType.getName();
if (DataTypeHelper.isNumber(name)) {
return name;
}
throw new IllegalArgumentException("Datatype " + dataType + " not a number");
}
示例7: validateName
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private DataType.Name validateName(DataType dataType) {
final DataType.Name name = dataType.getName();
if (DataTypeHelper.isNumber(name)) {
return name;
}
throw new IllegalArgumentException("Datatype " + dataType + " not a number");
}
示例8: CellValidator
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/**
* private constructor.
*/
private CellValidator(String validatorClassName, Kind validatorKind, Collection<String> validatorTypes,
DataType.Name cqlTypeName) {
this.validatorClassName = validatorClassName != null ? validatorClassName : DEFAULT_VALIDATOR_CLASSNAME;
this.validatorKind = validatorKind;
this.validatorTypes = validatorTypes;
this.cqlTypeName = cqlTypeName;
}
示例9: initPmap
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private void initPmap(String dateFormatString, String localDateFormatString,
BooleanParser.BoolStyle inBoolStyle,
Locale inLocale, boolean bLoader) {
pmap = new HashMap<DataType.Name, Parser>();
Parser byteParser = new ByteParser(inLocale, bLoader);
Parser shortParser = new ShortParser(inLocale, bLoader);
Parser integerParser = new IntegerParser(inLocale, bLoader);
Parser longParser = new LongParser(inLocale, bLoader);
Parser floatParser = new FloatParser(inLocale, bLoader);
Parser doubleParser = new DoubleParser(inLocale, bLoader);
Parser stringParser = new StringParser();
Parser booleanParser = new BooleanParser(inBoolStyle);
Parser uuidParser = new UUIDParser();
Parser bigDecimalParser = new BigDecimalParser();
Parser bigIntegerParser = new BigIntegerParser();
Parser byteBufferParser = new ByteBufferParser();
Parser inetAddressParser = new InetAddressParser();
Parser dateParser = new DateParser(dateFormatString);
Parser localDateParser = new LocalDateParser(localDateFormatString);
pmap.put(DataType.Name.ASCII, stringParser);
pmap.put(DataType.Name.BIGINT, longParser);
pmap.put(DataType.Name.BLOB, byteBufferParser);
pmap.put(DataType.Name.BOOLEAN, booleanParser);
pmap.put(DataType.Name.COUNTER, longParser);
pmap.put(DataType.Name.DATE , localDateParser);
pmap.put(DataType.Name.DECIMAL, bigDecimalParser);
pmap.put(DataType.Name.DOUBLE, doubleParser);
pmap.put(DataType.Name.FLOAT, floatParser);
pmap.put(DataType.Name.INET, inetAddressParser);
pmap.put(DataType.Name.INT, integerParser);
pmap.put(DataType.Name.SMALLINT , shortParser);
pmap.put(DataType.Name.TEXT, stringParser);
pmap.put(DataType.Name.TIME , longParser);
pmap.put(DataType.Name.TIMESTAMP, dateParser);
pmap.put(DataType.Name.TIMEUUID, uuidParser);
pmap.put(DataType.Name.TINYINT , byteParser);
pmap.put(DataType.Name.UUID, uuidParser);
pmap.put(DataType.Name.VARCHAR, stringParser);
pmap.put(DataType.Name.VARINT, bigIntegerParser);
}
示例10: getDataType
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private ODataDataType getDataType(DataType.Name dataTypeName) {
ODataDataType dataType;
switch (dataTypeName) {
case ASCII:
/* fall through */
case TEXT:
/* fall through */
case VARCHAR:
/* fall through */
case TIMEUUID:
dataType = ODataDataType.STRING;
break;
case UUID:
dataType = ODataDataType.GUID;
break;
case BIGINT:
/* fall through */
case VARINT:
/* fall through */
case COUNTER:
dataType = ODataDataType.INT64;
break;
case BLOB:
dataType = ODataDataType.BINARY;
break;
case BOOLEAN:
dataType = ODataDataType.BOOLEAN;
break;
case DECIMAL:
/* fall through */
case FLOAT:
dataType = ODataDataType.DECIMAL;
break;
case DOUBLE:
dataType = ODataDataType.DOUBLE;
break;
case INT:
dataType = ODataDataType.INT32;
break;
case TIMESTAMP:
dataType = ODataDataType.DATE_TIMEOFFSET;
break;
case TIME:
dataType = ODataDataType.TIMEOFDAY;
break;
case DATE:
dataType = ODataDataType.DATE;
break;
default:
dataType = ODataDataType.STRING;
break;
}
return dataType;
}
示例11: asJavaClass
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static Class<?> asJavaClass(DataType.Name name) {
if (name == null) return null;
switch (name) {
case ASCII:
return String.class;
case BIGINT:
return Long.class;
case BLOB:
return ByteBuffer.class;
case BOOLEAN:
return Boolean.class;
case COUNTER:
return Long.class;
case DECIMAL:
return BigDecimal.class;
case DOUBLE:
return Double.class;
case FLOAT:
return Float.class;
case INET:
return InetAddress.class;
case INT:
return Integer.class;
case LIST:
return List.class;
case MAP:
return Map.class;
case SET:
return Set.class;
case TEXT:
return String.class;
case TIMESTAMP:
return Date.class;
case TIMEUUID:
return UUID.class;
case UUID:
return UUID.class;
case VARCHAR:
return String.class;
case VARINT:
return BigInteger.class;
case UDT:
return UDTValue.class;
case TUPLE:
return TupleValue.class;
case CUSTOM:
return ByteBuffer.class;
}
if (isDate(name)) return localDateClass;
if (isTime(name)) return Long.class;
if (isSmallInt(name)) return Short.class;
if (isTinyInt(name)) return Byte.class;
return null;
}
示例12: getCollectionType
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/**
* @return the collectionType
*/
public DataType.Name getCollectionType() {
return collectionType;
}
示例13: isSmallInt
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static boolean isSmallInt(DataType.Name name) {
return name.ordinal() == SMALLINT_ORDINAL;
}
示例14: isTime
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static boolean isTime(DataType.Name name) {
return name.ordinal() == TIME_ORDINAL;
}
示例15: isDate
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static boolean isDate(DataType.Name name) {
return name.ordinal() == DATE_ORDINAL;
}