@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { String parsedString = (String) parsed; if (!parsedString.startsWith("0x")) throw new MarshalException(String.format("String representation of blob is missing 0x prefix: %s", parsedString)); return new Constants.Value(BytesType.instance.fromString(parsedString.substring(2))); } catch (ClassCastException | MarshalException exc) { throw new MarshalException(String.format("Value '%s' is not a valid blob representation: %s", parsed, exc.getMessage())); } }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { String parsedString = (String) parsed; if (!parsedString.startsWith("0x")) throw new MarshalException(String.format("String representation of blob is missing 0x prefix: %s", parsedString)); return new Constants.Value(BytesType.instance.fromString(parsedString.substring(2))); } catch (ClassCastException | MarshalException exc) { throw new MarshalException(String.format("Value '%s' is not a valid blob representation: %s", parsed, exc.getMessage())); } }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { String parsedString = (String) parsed; if (!parsedString.startsWith("0x")) throw new MarshalException(String.format("String representation of blob is missing 0x prefix: %s", parsedString)); return new Constants.Value(BytesType.instance.fromString(parsedString.substring(2))); } catch (ClassCastException | MarshalException exc) { throw new MarshalException(String.format("Value '%s' is not a valid blob representation: %s", parsed, exc.getMessage())); } }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { String parsedString = (String) parsed; if (!parsedString.startsWith("0x")) throw new MarshalException(String.format("String representation of blob is missing 0x prefix: %s", parsedString)); return new Constants.Value(BytesType.instance.fromString(parsedString.substring(2))); } catch (ClassCastException | MarshalException exc) { throw new MarshalException(String.format("Value '%s' is not a valid blob representation: %s", parsed, exc.getMessage())); } }
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()); } }
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()); } }
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()); } }
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()); } }