當前位置: 首頁>>代碼示例>>Java>>正文


Java DataType.Name方法代碼示例

本文整理匯總了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);
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:27,代碼來源:PojoField.java

示例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);
}
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:17,代碼來源:DataTypeHelper.java

示例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;
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:14,代碼來源:PojoField.java

示例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);
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:17,代碼來源:CassandraHelper.java

示例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();
}
 
開發者ID:adejanovski,項目名稱:cassandra-jdbc-wrapper,代碼行數:8,代碼來源:ColumnDefinitions.java

示例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");
    }
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:9,代碼來源:DatastaxGenericByteGetter.java

示例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");
    }
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:10,代碼來源:DatastaxGenericIntegerGetter.java

示例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;
}
 
開發者ID:Stratio,項目名稱:deep-spark,代碼行數:11,代碼來源:CellValidator.java

示例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);

}
 
開發者ID:brianmhess,項目名稱:cassandra-loader,代碼行數:43,代碼來源:CqlDelimParser.java

示例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;
}
 
開發者ID:wso2,項目名稱:carbon-data,代碼行數:55,代碼來源:CassandraDataHandler.java

示例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;
}
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:56,代碼來源:DataTypeHelper.java

示例12: getCollectionType

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/**
 * @return the collectionType
 */
public DataType.Name getCollectionType() {
	return collectionType;
}
 
開發者ID:joef551,項目名稱:camel-cql,代碼行數:7,代碼來源:CqlToken.java

示例13: isSmallInt

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static boolean isSmallInt(DataType.Name name) {
    return name.ordinal() == SMALLINT_ORDINAL;
}
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:4,代碼來源:DataTypeHelper.java

示例14: isTime

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static boolean isTime(DataType.Name name) {
    return name.ordinal() == TIME_ORDINAL;
}
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:4,代碼來源:DataTypeHelper.java

示例15: isDate

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static boolean isDate(DataType.Name name) {
    return name.ordinal() == DATE_ORDINAL;
}
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:4,代碼來源:DataTypeHelper.java


注:本文中的com.datastax.driver.core.DataType.Name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。