return LongType.instance.decompose(Long.parseLong(value.toString()));
public int compareCustom(ByteBuffer o1, ByteBuffer o2) { return LongType.compareLongs(o1, o2); }
protected Long compose(ByteBuffer bb) { return LongType.instance.compose(bb); } }
public long getTimestamp(long now, QueryOptions options) throws InvalidRequestException { if (timestamp == null) return now; ByteBuffer tval = timestamp.bindAndGet(options); if (tval == null) throw new InvalidRequestException("Invalid null value of timestamp"); try { LongType.instance.validate(tval); } catch (MarshalException e) { throw new InvalidRequestException("Invalid timestamp value"); } return LongType.instance.compose(tval); }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { if (parsed instanceof String) return new Constants.Value(fromString((String) parsed)); Number parsedNumber = (Number) parsed; if (!(parsedNumber instanceof Integer || parsedNumber instanceof Long)) throw new MarshalException(String.format("Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); return new Constants.Value(getSerializer().serialize(parsedNumber.longValue())); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
@Override public boolean isValueCompatibleWithInternal(AbstractType<?> otherType) { return this == otherType || Int32Type.instance.isValueCompatibleWith(otherType) || LongType.instance.isValueCompatibleWith(otherType); }
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException { if (validator instanceof ReversedType<?>) validator = ((ReversedType<?>) validator).baseType; try { // BytesType doesn't want it's input prefixed by '0x'. if (type == Type.HEX && validator instanceof BytesType) return validator.fromString(text.substring(2)); if (validator instanceof CounterColumnType) return LongType.instance.fromString(text); return validator.fromString(text); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } }
@Override public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) { return getSerializer().deserialize(buffer).toString(); }
public long getTimestamp(long now, QueryOptions options) throws InvalidRequestException { if (timestamp == null) return now; ByteBuffer tval = timestamp.bindAndGet(options); if (tval == null) throw new InvalidRequestException("Invalid null value of timestamp"); if (tval == ByteBufferUtil.UNSET_BYTE_BUFFER) return now; try { LongType.instance.validate(tval); } catch (MarshalException e) { throw new InvalidRequestException("Invalid timestamp value: " + tval); } return LongType.instance.compose(tval); }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { if (parsed instanceof String) return new Constants.Value(fromString((String) parsed)); Number parsedNumber = (Number) parsed; if (!(parsedNumber instanceof Integer || parsedNumber instanceof Long)) throw new MarshalException(String.format("Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); return new Constants.Value(getSerializer().serialize(parsedNumber.longValue())); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
@Override public boolean isValueCompatibleWithInternal(AbstractType<?> otherType) { return this == otherType || Int32Type.instance.isValueCompatibleWith(otherType) || LongType.instance.isValueCompatibleWith(otherType); }
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException { if (validator instanceof ReversedType<?>) validator = ((ReversedType<?>) validator).baseType; try { if (type == Type.HEX) // Note that validator could be BytesType, but it could also be a custom type, so // we hardcode BytesType (rather than using 'validator') in the call below. // Further note that BytesType doesn't want it's input prefixed by '0x', hence the substring. return BytesType.instance.fromString(text.substring(2)); if (validator instanceof CounterColumnType) return LongType.instance.fromString(text); return validator.fromString(text); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } }
@Override public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) { return getSerializer().deserialize(buffer).toString(); }
public ByteBuffer compute(ProtocolVersion protocolVersion) { return LongType.instance.decompose(sum); }
public long getTimestamp(long now, QueryOptions options) throws InvalidRequestException { if (timestamp == null) return now; ByteBuffer tval = timestamp.bindAndGet(options); if (tval == null) throw new InvalidRequestException("Invalid null value of timestamp"); if (tval == ByteBufferUtil.UNSET_BYTE_BUFFER) return now; try { LongType.instance.validate(tval); } catch (MarshalException e) { throw new InvalidRequestException("Invalid timestamp value: " + tval); } return LongType.instance.compose(tval); }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { if (parsed instanceof String) return new Constants.Value(fromString((String) parsed)); Number parsedNumber = (Number) parsed; if (!(parsedNumber instanceof Integer || parsedNumber instanceof Long)) throw new MarshalException(String.format("Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); return new Constants.Value(getSerializer().serialize(parsedNumber.longValue())); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
protected Long compose(ByteBuffer bb) { return LongType.instance.compose(bb); } }
public int compare(ByteBuffer o1, ByteBuffer o2) { return compareLongs(o1, o2); }
@Override public boolean isValueCompatibleWithInternal(AbstractType<?> otherType) { return this == otherType || Int32Type.instance.isValueCompatibleWith(otherType) || LongType.instance.isValueCompatibleWith(otherType); }
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException { if (validator instanceof ReversedType<?>) validator = ((ReversedType<?>) validator).baseType; try { if (type == Type.HEX) // Note that validator could be BytesType, but it could also be a custom type, so // we hardcode BytesType (rather than using 'validator') in the call below. // Further note that BytesType doesn't want it's input prefixed by '0x', hence the substring. return BytesType.instance.fromString(text.substring(2)); if (validator instanceof CounterColumnType) return LongType.instance.fromString(text); return validator.fromString(text); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } }