private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!checkIfTupleType(receiver.type)) throw new InvalidRequestException(String.format("Invalid tuple type literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); TupleType tt = getTupleType(receiver.type); for (int i = 0; i < elements.size(); i++) { if (i >= tt.size()) { throw new InvalidRequestException(String.format("Invalid tuple literal for %s: too many elements. Type %s expects %d but got %d", receiver.name, tt.asCQL3Type(), tt.size(), elements.size())); } Term.Raw value = elements.get(i); ColumnSpecification spec = componentSpecOf(receiver, i); if (!value.testAssignment(keyspace, spec).isAssignable()) throw new InvalidRequestException(String.format("Invalid tuple literal for %s: component %d is not of type %s", receiver.name, i, spec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!checkIfTupleType(receiver.type)) throw new InvalidRequestException(String.format("Invalid tuple type literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); TupleType tt = getTupleType(receiver.type); for (int i = 0; i < elements.size(); i++) { if (i >= tt.size()) { throw new InvalidRequestException(String.format("Invalid tuple literal for %s: too many elements. Type %s expects %d but got %d", receiver.name, tt.asCQL3Type(), tt.size(), elements.size())); } Term.Raw value = elements.get(i); ColumnSpecification spec = componentSpecOf(receiver, i); if (!value.testAssignment(keyspace, spec).isAssignable()) throw new InvalidRequestException(String.format("Invalid tuple literal for %s: component %d is not of type %s", receiver.name, i, spec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof SetType)) { // We've parsed empty maps as a set literal to break the ambiguity so // handle that case now if ((receiver.type instanceof MapType) && elements.isEmpty()) return; throw new InvalidRequestException(String.format("Invalid set literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); } ColumnSpecification valueSpec = Sets.valueSpecOf(receiver); for (Term.Raw rt : elements) { if (!rt.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid set literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof SetType)) { // We've parsed empty maps as a set literal to break the ambiguity so // handle that case now if ((receiver.type instanceof MapType) && elements.isEmpty()) return; throw new InvalidRequestException(String.format("Invalid set literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); } ColumnSpecification valueSpec = Sets.valueSpecOf(receiver); for (Term.Raw rt : elements) { if (!rt.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid set literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof SetType)) { // We've parsed empty maps as a set literal to break the ambiguity so // handle that case now if ((receiver.type instanceof MapType) && elements.isEmpty()) return; throw new InvalidRequestException(String.format("Invalid set literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); } ColumnSpecification valueSpec = Sets.valueSpecOf(receiver); for (Term.Raw rt : elements) { if (!rt.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid set literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!receiver.type.isUDT()) throw new InvalidRequestException(String.format("Invalid user type literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); UserType ut = (UserType)receiver.type; for (int i = 0; i < ut.size(); i++) { FieldIdentifier field = ut.fieldName(i); Term.Raw value = entries.get(field); if (value == null) continue; ColumnSpecification fieldSpec = fieldSpecOf(receiver, i); if (!value.testAssignment(keyspace, fieldSpec).isAssignable()) { throw new InvalidRequestException(String.format("Invalid user type literal for %s: field %s is not of type %s", receiver.name, field, fieldSpec.type.asCQL3Type())); } } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof MapType)) throw new InvalidRequestException(String.format("Invalid map literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); ColumnSpecification keySpec = Maps.keySpecOf(receiver); ColumnSpecification valueSpec = Maps.valueSpecOf(receiver); for (Pair<Term.Raw, Term.Raw> entry : entries) { if (!entry.left.testAssignment(keyspace, keySpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid map literal for %s: key %s is not of type %s", receiver.name, entry.left, keySpec.type.asCQL3Type())); if (!entry.right.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid map literal for %s: value %s is not of type %s", receiver.name, entry.right, valueSpec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof MapType)) throw new InvalidRequestException(String.format("Invalid map literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); ColumnSpecification keySpec = Maps.keySpecOf(receiver); ColumnSpecification valueSpec = Maps.valueSpecOf(receiver); for (Pair<Term.Raw, Term.Raw> entry : entries) { if (!entry.left.testAssignment(keyspace, keySpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid map literal for %s: key %s is not of type %s", receiver.name, entry.left, keySpec.type.asCQL3Type())); if (!entry.right.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid map literal for %s: value %s is not of type %s", receiver.name, entry.right, valueSpec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof MapType)) throw new InvalidRequestException(String.format("Invalid map literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); ColumnSpecification keySpec = Maps.keySpecOf(receiver); ColumnSpecification valueSpec = Maps.valueSpecOf(receiver); for (Pair<Term.Raw, Term.Raw> entry : entries) { if (!entry.left.testAssignment(keyspace, keySpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid map literal for %s: key %s is not of type %s", receiver.name, entry.left, keySpec.type.asCQL3Type())); if (!entry.right.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid map literal for %s: value %s is not of type %s", receiver.name, entry.right, valueSpec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof MapType)) throw new InvalidRequestException(String.format("Invalid map literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); ColumnSpecification keySpec = Maps.keySpecOf(receiver); ColumnSpecification valueSpec = Maps.valueSpecOf(receiver); for (Pair<Term.Raw, Term.Raw> entry : entries) { if (!entry.left.testAssignment(keyspace, keySpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid map literal for %s: key %s is not of type %s", receiver.name, entry.left, keySpec.type.asCQL3Type())); if (!entry.right.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid map literal for %s: value %s is not of type %s", receiver.name, entry.right, valueSpec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof ListType)) throw new InvalidRequestException(String.format("Invalid list literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); ColumnSpecification valueSpec = Lists.valueSpecOf(receiver); for (Term.Raw rt : elements) { if (!rt.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid list literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type())); } }
public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!term.testAssignment(keyspace, castedSpecOf(keyspace, receiver)).isAssignable()) throw new InvalidRequestException(String.format("Cannot cast value %s to type %s", term, type)); if (!testAssignment(keyspace, receiver).isAssignable()) throw new InvalidRequestException(String.format("Cannot assign value %s to %s of type %s", this, receiver.name, receiver.type.asCQL3Type())); return term.prepare(keyspace, receiver); }
@Override public TestResult testAssignment(String keyspace, ColumnSpecification receiver) { return rawTerm.testAssignment(keyspace, receiver); }
public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!term.testAssignment(keyspace, castedSpecOf(keyspace, receiver)).isAssignable()) throw new InvalidRequestException(String.format("Cannot cast value %s to type %s", term, type)); if (!testAssignment(keyspace, receiver).isAssignable()) throw new InvalidRequestException(String.format("Cannot assign value %s to %s of type %s", this, receiver.name, receiver.type.asCQL3Type())); return term.prepare(keyspace, receiver); }
public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!term.testAssignment(keyspace, castedSpecOf(keyspace, receiver)).isAssignable()) throw new InvalidRequestException(String.format("Cannot cast value %s to type %s", term, type)); if (!testAssignment(keyspace, receiver).isAssignable()) throw new InvalidRequestException(String.format("Cannot assign value %s to %s of type %s", this, receiver.name, receiver.type.asCQL3Type())); return term.prepare(keyspace, receiver); }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof ListType)) throw new InvalidRequestException(String.format("Invalid list literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); ColumnSpecification valueSpec = Lists.valueSpecOf(receiver); for (Term.Raw rt : elements) { if (!rt.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid list literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type())); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof ListType)) throw new InvalidRequestException(String.format("Invalid list literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); ColumnSpecification valueSpec = Lists.valueSpecOf(receiver); for (Term.Raw rt : elements) { if (!rt.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid list literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type())); } }
@Override public TestResult testAssignment(String keyspace, ColumnSpecification receiver) { return rawTerm.testAssignment(keyspace, receiver); }
@Override public TestResult testAssignment(String keyspace, ColumnSpecification receiver) { return rawTerm.testAssignment(keyspace, receiver); }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof ListType)) throw new InvalidRequestException(String.format("Invalid list literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); ColumnSpecification valueSpec = Lists.valueSpecOf(receiver); for (Term.Raw rt : elements) { if (!rt.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid list literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type())); } }