List of usage examples for org.apache.cassandra.db.marshal BooleanType instance
BooleanType instance
To view the source code for org.apache.cassandra.db.marshal BooleanType instance.
Click Source Link
From source file:clojurewerkz.cassaforte.Codec.java
License:Apache License
private static AbstractType getCodecInternal(DataType type) { switch (type.getName()) { case ASCII:/*from w w w.j ava 2 s. c o m*/ return AsciiType.instance; case BIGINT: return LongType.instance; case BLOB: return BytesType.instance; case BOOLEAN: return BooleanType.instance; case COUNTER: return CounterColumnType.instance; case DECIMAL: return DecimalType.instance; case DOUBLE: return DoubleType.instance; case FLOAT: return FloatType.instance; case INET: return InetAddressType.instance; case INT: return Int32Type.instance; case TEXT: return UTF8Type.instance; case TIMESTAMP: return DateType.instance; case UUID: return UUIDType.instance; case VARCHAR: return UTF8Type.instance; case VARINT: return IntegerType.instance; case TIMEUUID: return TimeUUIDType.instance; case LIST: return ListType.getInstance(getCodec(type.getTypeArguments().get(0))); case SET: return SetType.getInstance(getCodec(type.getTypeArguments().get(0))); case MAP: return MapType.getInstance(getCodec(type.getTypeArguments().get(0)), getCodec(type.getTypeArguments().get(1))); default: throw new RuntimeException("Unknown type"); } }
From source file:com.datastax.driver.core.ArrayBackedRow.java
License:Apache License
public boolean getBool(int i) { metadata.checkType(i, DataType.Name.BOOLEAN); ByteBuffer value = data.get(i); if (value == null || value.remaining() == 0) return false; return BooleanType.instance.compose(value); }
From source file:com.datastax.driver.core.BoundStatement.java
License:Apache License
/** * Set the {@code i}th value to the provided boolean. * * @param i the index of the variable to set. * @param v the value to set.// w ww . j a va 2s. c o m * @return this BoundStatement. * * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.preparedStatement().variables().size()}. * @throws InvalidTypeException if column {@code i} is not of type BOOLEAN. */ public BoundStatement setBool(int i, boolean v) { metadata().checkType(i, DataType.Name.BOOLEAN); return setValue(i, BooleanType.instance.decompose(v)); }
From source file:com.datastax.driver.core.Codec.java
License:Apache License
private static AbstractType<?> getCodecInternal(DataType type) { switch (type.getName()) { case ASCII:// ww w .java 2 s . c o m return AsciiType.instance; case BIGINT: return LongType.instance; case BLOB: return BytesType.instance; case BOOLEAN: return BooleanType.instance; case COUNTER: return CounterColumnType.instance; case DECIMAL: return DecimalType.instance; case DOUBLE: return DoubleType.instance; case FLOAT: return FloatType.instance; case INET: return InetAddressType.instance; case INT: return Int32Type.instance; case TEXT: return UTF8Type.instance; case TIMESTAMP: return DateType.instance; case UUID: return UUIDType.instance; case VARCHAR: return UTF8Type.instance; case VARINT: return IntegerType.instance; case TIMEUUID: return TimeUUIDType.instance; case LIST: return ListType.getInstance(getCodec(type.getTypeArguments().get(0))); case SET: return SetType.getInstance(getCodec(type.getTypeArguments().get(0))); case MAP: return MapType.getInstance(getCodec(type.getTypeArguments().get(0)), getCodec(type.getTypeArguments().get(1))); // We don't interpret custom values in any way case CUSTOM: return BytesType.instance; default: throw new RuntimeException("Unknown type"); } }
From source file:com.datastax.driver.core.Row.java
License:Apache License
/** * Returns the {@code i}th value of this row as a boolean. * * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. * @return the boolean value of the {@code i}th column in this row. If the * value is NULL, {@code false} is returned. * * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. * @throws InvalidTypeException if column {@code i} is not of type BOOLEAN. *//*from ww w . j a v a 2s .c om*/ public boolean getBool(int i) { metadata.checkType(i, DataType.Name.BOOLEAN); ByteBuffer value = data.get(i); if (value == null || value.remaining() == 0) return false; return BooleanType.instance.compose(value); }
From source file:com.impetus.client.cassandra.common.CassandraUtilities.java
License:Apache License
/** * @param value/*from w w w . ja va2 s .co m*/ * @param f * @return */ public static ByteBuffer toBytes(Object value, Class<?> clazz) { if (clazz.isAssignableFrom(String.class)) { return UTF8Type.instance.decompose((String) value); } else if (clazz.equals(int.class) || clazz.isAssignableFrom(Integer.class)) { return Int32Type.instance.decompose(Integer.parseInt(value.toString())); } else if (clazz.equals(long.class) || clazz.isAssignableFrom(Long.class)) { return LongType.instance.decompose(Long.parseLong(value.toString())); } else if (clazz.equals(boolean.class) || clazz.isAssignableFrom(Boolean.class)) { return BooleanType.instance.decompose(Boolean.valueOf(value.toString())); } else if (clazz.equals(double.class) || clazz.isAssignableFrom(Double.class)) { return DoubleType.instance.decompose(Double.valueOf(value.toString())); } else if (clazz.isAssignableFrom(java.util.UUID.class)) { return UUIDType.instance.decompose(UUID.fromString(value.toString())); } else if (clazz.equals(float.class) || clazz.isAssignableFrom(Float.class)) { return FloatType.instance.decompose(Float.valueOf(value.toString())); } else if (clazz.isAssignableFrom(Date.class)) { DateAccessor dateAccessor = new DateAccessor(); return DateType.instance.decompose((Date) value); } else { if (value.getClass().isAssignableFrom(String.class)) { value = PropertyAccessorFactory.getPropertyAccessor(clazz).fromString(clazz, value.toString()); } return BytesType.instance .decompose(ByteBuffer.wrap(PropertyAccessorFactory.getPropertyAccessor(clazz).toBytes(value))); } }
From source file:com.stratio.cassandra.index.schema.ColumnMapperBoolean.java
License:Apache License
/** * Builds a new {@link ColumnMapperBlob}. */// w w w . j a v a 2 s. c om @JsonCreator public ColumnMapperBoolean() { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, BooleanType.instance }, new AbstractType[] {}); }
From source file:com.stratio.cassandra.index.schema.ColumnMapperString.java
License:Apache License
/** * Builds a new {@link ColumnMapperString}. *///ww w. j av a2 s.c om @JsonCreator public ColumnMapperString() { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, Int32Type.instance, LongType.instance, IntegerType.instance, FloatType.instance, DoubleType.instance, BooleanType.instance, UUIDType.instance, TimeUUIDType.instance, TimestampType.instance, BytesType.instance, InetAddressType.instance }, new AbstractType[] { UTF8Type.instance }); }
From source file:com.stratio.cassandra.index.schema.ColumnMapperText.java
License:Apache License
/** * Builds a new {@link ColumnMapperText} using the specified Lucene {@link Analyzer}. * @param analyzerClassName The Lucene {@link Analyzer} to be used. *//*from w w w .j a va2 s . c om*/ @JsonCreator public ColumnMapperText(@JsonProperty("analyzer") String analyzerClassName) { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, Int32Type.instance, LongType.instance, IntegerType.instance, FloatType.instance, DoubleType.instance, BooleanType.instance, UUIDType.instance, TimeUUIDType.instance, TimestampType.instance, BytesType.instance, InetAddressType.instance }, new AbstractType[] {}); if (analyzerClassName != null) { this.analyzer = AnalyzerFactory.getAnalyzer(analyzerClassName); } else { this.analyzer = Schema.DEFAULT_ANALYZER; } }
From source file:com.stratio.cassandra.lucene.schema.mapping.BooleanMapper.java
License:Apache License
/** * Builds a new {@link BlobMapper}.//from w w w. j ava 2 s.c o m * * @param name The name of the mapper. * @param indexed If the field supports searching. * @param sorted If the field supports sorting. */ public BooleanMapper(String name, Boolean indexed, Boolean sorted) { super(name, indexed, sorted, AsciiType.instance, UTF8Type.instance, BooleanType.instance); }