/** * Parses an ArrayContainsExpression from a JSON object node. */ public static ArrayContainsExpression fromJson(ObjectNode node) { JsonNode x = node.get("array"); if (x != null) { Path field = new Path(x.asText()); x = node.get("contains"); if (x != null) { ContainsOperator op = ContainsOperator.fromString(x.asText()); if (op != null) { x = node.get("values"); if (x instanceof ArrayNode) { ArrayList<Value> values = new ArrayList<>(((ArrayNode) x).size()); for (Iterator<JsonNode> itr = ((ArrayNode) x).elements(); itr.hasNext();) { values.add(Value.fromJson(itr.next())); } return new ArrayContainsExpression(field, op, values); } } } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses an ArrayContainsExpression from a JSON object node. */ public static ArrayContainsExpression fromJson(ObjectNode node) { JsonNode x = node.get("array"); if (x != null) { Path field = new Path(x.asText()); x = node.get("contains"); if (x != null) { ContainsOperator op = ContainsOperator.fromString(x.asText()); if (op != null) { x = node.get("values"); if (x instanceof ArrayNode) { ArrayList<Value> values = new ArrayList<>(((ArrayNode) x).size()); for (Iterator<JsonNode> itr = ((ArrayNode) x).elements(); itr.hasNext();) { values.add(Value.fromJson(itr.next())); } return new ArrayContainsExpression(field, op, values); } } } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses an n-ary relational expression from the given json object */ public static NaryValueRelationalExpression fromJson(ObjectNode node) { if (node.size() == 3) { JsonNode x = node.get("op"); if (x != null) { NaryRelationalOperator op = NaryRelationalOperator.fromString(x.asText()); if (op != null) { x = node.get("field"); if (x != null) { Path field = new Path(x.asText()); x = node.get("values"); if (x instanceof ArrayNode) { ArrayList<Value> values = new ArrayList<>(((ArrayNode) x).size()); for (Iterator<JsonNode> itr = ((ArrayNode) x).elements(); itr.hasNext();) { values.add(Value.fromJson(itr.next())); } return new NaryValueRelationalExpression(field, op, values); } } } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses an n-ary relational expression from the given json object */ public static NaryValueRelationalExpression fromJson(ObjectNode node) { if (node.size() == 3) { JsonNode x = node.get("op"); if (x != null) { NaryRelationalOperator op = NaryRelationalOperator.fromString(x.asText()); if (op != null) { x = node.get("field"); if (x != null) { Path field = new Path(x.asText()); x = node.get("values"); if (x instanceof ArrayNode) { ArrayList<Value> values = new ArrayList<>(((ArrayNode) x).size()); for (Iterator<JsonNode> itr = ((ArrayNode) x).elements(); itr.hasNext();) { values.add(Value.fromJson(itr.next())); } return new NaryValueRelationalExpression(field, op, values); } } } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses a field comparison or value comparison expression from the given * json object */ public static BinaryRelationalExpression fromJson(ObjectNode node) { if (node.size() == 3) { JsonNode x = node.get("op"); if (x != null) { BinaryComparisonOperator op = BinaryComparisonOperator.fromString(x.asText()); if (op != null) { x = node.get("field"); if (x != null) { Path field = new Path(x.asText()); x = node.get("rfield"); if (x != null) { return new FieldComparisonExpression(field, op, new Path(x.asText())); } else { x = node.get("rvalue"); if (x != null) { return new ValueComparisonExpression(field, op, Value.fromJson(x)); } } } } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses a field comparison or value comparison expression from the given * json object */ public static BinaryRelationalExpression fromJson(ObjectNode node) { if (node.size() == 3) { JsonNode x = node.get("op"); if (x != null) { BinaryComparisonOperator op = BinaryComparisonOperator.fromString(x.asText()); if (op != null) { x = node.get("field"); if (x != null) { Path field = new Path(x.asText()); x = node.get("rfield"); if (x != null) { return new FieldComparisonExpression(field, op, new Path(x.asText())); } else { x = node.get("rvalue"); if (x != null) { return new ValueComparisonExpression(field, op, Value.fromJson(x)); } } } } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses an rvalue from a json node. */ public static RValueExpression fromJson(JsonNode node) { if (node instanceof ObjectNode) { if (node.size() == 1) { JsonNode path = node.get("$valueof"); if (path != null && path.isValueNode()) { return new RValueExpression(new Path(path.asText())); } else { return new RValueExpression(new Value(node)); } } else { return new RValueExpression(new Value(node)); } } if (node instanceof ArrayNode) { return new RValueExpression(new Value(node)); } else if (node.isValueNode()) { if (node.asText().equals("$null")) { return NULL; } else { return new RValueExpression(Value.fromJson(node)); } } throw Error.get(QueryConstants.ERR_INVALID_RVALUE_EXPRESSION, node.toString()); }
/** * Parses an rvalue from a json node. */ public static RValueExpression fromJson(JsonNode node) { if (node instanceof ObjectNode) { if (node.size() == 1) { JsonNode path = node.get("$valueof"); if (path != null && path.isValueNode()) { return new RValueExpression(new Path(path.asText())); } else { return new RValueExpression(new Value(node)); } } else { return new RValueExpression(new Value(node)); } } if (node instanceof ArrayNode) { return new RValueExpression(new Value(node)); } else if (node.isValueNode()) { if (node.asText().equals("$null")) { return NULL; } else { return new RValueExpression(Value.fromJson(node)); } } throw Error.get(QueryConstants.ERR_INVALID_RVALUE_EXPRESSION, node.toString()); }