/** * Decompose. * * @param value * the value * @param clazz * the clazz * @return the object */ private static Object decompose(Object value, Class clazz) { ByteBuffer buf = ByteBuffer.wrap((byte[]) value, 0, ((byte[]) value).length); return DecimalType.instance.compose(buf); } }
/** * Compose. * * @param value * the value * @param clazz * the clazz * @return the byte[] */ private static byte[] compose(Object value, Class clazz) { return DecimalType.instance.decompose((BigDecimal) value).array(); }
@Override public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) { return getSerializer().deserialize(buffer).toString(); }
@Override public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) { return getSerializer().deserialize(buffer).toString(); }
private static byte[] compose(Object value, Class clazz) { return DecimalType.instance.decompose((BigDecimal) value).array(); }
private static Object decompose(Object value, Class clazz) { ByteBuffer buf = ByteBuffer.wrap((byte[]) value, 0, ((byte[]) value).length); return DecimalType.instance.compose(buf); } }
@Override public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) { return getSerializer().deserialize(buffer).toString(); }
public ByteBuffer fromString(String source) throws MarshalException { // Return an empty ByteBuffer for an empty string. if (source.isEmpty()) return ByteBufferUtil.EMPTY_BYTE_BUFFER; BigDecimal decimal; try { decimal = new BigDecimal(source); } catch (Exception e) { throw new MarshalException(String.format("unable to make BigDecimal from '%s'", source), e); } return decompose(decimal); }
@Override public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) { return getSerializer().deserialize(buffer).toString(); }
public ByteBuffer fromString(String source) throws MarshalException { // Return an empty ByteBuffer for an empty string. if (source.isEmpty()) return ByteBufferUtil.EMPTY_BYTE_BUFFER; BigDecimal decimal; try { decimal = new BigDecimal(source); } catch (Exception e) { throw new MarshalException(String.format("unable to make BigDecimal from '%s'", source), e); } return decompose(decimal); }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { return new Constants.Value(getSerializer().serialize(new BigDecimal(parsed.toString()))); } catch (NumberFormatException exc) { throw new MarshalException(String.format("Value '%s' is not a valid representation of a decimal value", parsed)); } }
public ByteBuffer fromString(String source) throws MarshalException { // Return an empty ByteBuffer for an empty string. if (source.isEmpty()) return ByteBufferUtil.EMPTY_BYTE_BUFFER; BigDecimal decimal; try { decimal = new BigDecimal(source); } catch (Exception e) { throw new MarshalException(String.format("unable to make BigDecimal from '%s'", source), e); } return decompose(decimal); }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { return new Constants.Value(getSerializer().serialize(new BigDecimal(parsed.toString()))); } catch (NumberFormatException exc) { throw new MarshalException(String.format("Value '%s' is not a valid representation of a decimal value", parsed)); } }
public ByteBuffer fromString(String source) throws MarshalException { // Return an empty ByteBuffer for an empty string. if (source.isEmpty()) return ByteBufferUtil.EMPTY_BYTE_BUFFER; BigDecimal decimal; try { decimal = new BigDecimal(source); } catch (Exception e) { throw new MarshalException(String.format("unable to make BigDecimal from '%s'", source), e); } return decompose(decimal); }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { return new Constants.Value(getSerializer().serialize(new BigDecimal(parsed.toString()))); } catch (NumberFormatException exc) { throw new MarshalException(String.format("Value '%s' is not a valid representation of a decimal value", parsed)); } }
public ByteBuffer fromString(String source) throws MarshalException { // Return an empty ByteBuffer for an empty string. if (source.isEmpty()) return ByteBufferUtil.EMPTY_BYTE_BUFFER; BigDecimal decimal; try { decimal = new BigDecimal(source); } catch (Exception e) { throw new MarshalException(String.format("unable to make BigDecimal from '%s'", source), e); } return decompose(decimal); }