@Override public QueryExpression parseQuery(JsonNode object) { return object == null ? null : QueryExpression.fromJson(object); }
@Override public QueryExpression getQuery(JsonNode object, String name) { JsonNode node = object.get(name); return node == null ? null : QueryExpression.fromJson(node); }
@Override public QueryExpression getQuery(JsonNode object, String name) { JsonNode node = object.get(name); return node == null ? null : QueryExpression.fromJson(node); }
/** * Parses a query expression that can be used in for-each clauses */ public static QueryExpression fromJson(JsonNode node) { if (node instanceof TextNode && "$all".equals(node.asText())) { return new AllMatchExpression(); } else { return QueryExpression.fromJson(node); } } }
/** * Parses a query expression that can be used in for-each clauses */ public static QueryExpression fromJson(JsonNode node) { if (node instanceof TextNode && "$all".equals(node.asText())) { return new AllMatchExpression(); } else { return QueryExpression.fromJson(node); } } }
@Override public QueryExpression parseQuery(BSONObject object) { return object == null ? null : QueryExpression.fromJson(toJson(object)); }
/** * Parses an object node and populates a DeleteRequest. It is up to the * caller to make sure that the node is actually a DeleteRequest. Any * unrecignized elements are ignored. */ public static DeleteRequest fromJson(ObjectNode node) { DeleteRequest req = new DeleteRequest(); req.parse(node); JsonNode x = node.get("query"); if (x != null) { req.query = QueryExpression.fromJson(x); } return req; } }
@Override public QueryExpression getQuery(BSONObject object, String name) { String x = (String) object.get(name); return x == null ? null : QueryExpression.fromJson(toJson(x)); }
/** * Parses an object node and populates a DeleteRequest. It is up to the * caller to make sure that the node is actually a DeleteRequest. Any * unrecignized elements are ignored. */ public static DeleteRequest fromJson(ObjectNode node) { DeleteRequest req = new DeleteRequest(); req.parse(node); JsonNode x = node.get("query"); if (x != null) { req.query = QueryExpression.fromJson(x); } return req; } }
/** * Parses an array match expression from the given json object */ public static ArrayMatchExpression fromJson(ObjectNode node) { JsonNode x = node.get("array"); if (x != null) { Path field = new Path(x.asText()); x = node.get("elemMatch"); if (x != null) { return new ArrayMatchExpression(field, QueryExpression.fromJson(x)); } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_COMPARISON_EXPRESSION, node.toString()); } }
@Override public QueryExpression getQuery(Object object, String name) { String x = (String) ((BSONObject) object).get(name); return x == null ? null : QueryExpression.fromJson(toJson(x)); }
/** * Parses an object node and populates a DeleteRequest. It is up to the * caller to make sure that the node is actually a DeleteRequest. Any * unrecignized elements are ignored. */ public static DeleteRequest fromJson(ObjectNode node) { DeleteRequest req = new DeleteRequest(); req.parse(node); JsonNode x = node.get("query"); if (x != null) { req.query = QueryExpression.fromJson(x); } return req; } }
/** * Parses an array match expression from the given json object */ public static ArrayMatchExpression fromJson(ObjectNode node) { JsonNode x = node.get("array"); if (x != null) { Path field = new Path(x.asText()); x = node.get("elemMatch"); if (x != null) { return new ArrayMatchExpression(field, QueryExpression.fromJson(x)); } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses a find request from a json object. Unrecognized elements are * ignored. */ public void fromJson(ObjectNode node) { JsonNode x = node.get("query"); if (x != null) { query = QueryExpression.fromJson(x); } x = node.get("projection"); if (x != null) { projection = Projection.fromJson(x); } x = node.get("sort"); if (x != null) { sort = Sort.fromJson(x); } x = node.get("range"); if (x instanceof ArrayNode && ((ArrayNode) x).size() == 2) { from = ((ArrayNode) x).get(0).asLong(); to = ((ArrayNode) x).get(1).asLong(); } }
/** * Parses an update request from a Json object */ public static UpdateRequest fromJson(ObjectNode node) { UpdateRequest req = new UpdateRequest(); req.parse(node); JsonNode x = node.get("query"); if (x != null) { req.query = QueryExpression.fromJson(x); } x = node.get("update"); if (x != null) { req.updateExpression = UpdateExpression.fromJson(x); } x = node.get("projection"); if (x != null) { req.returnFields = Projection.fromJson(x); } return req; } }
/** * Parses a unary logical expression using the given object node */ public static UnaryLogicalExpression fromJson(ObjectNode node) { if (node.size() != 1) { throw Error.get(QueryConstants.ERR_INVALID_LOGICAL_EXPRESSION, node.toString()); } String fieldName = node.fieldNames().next(); UnaryLogicalOperator op = UnaryLogicalOperator.fromString(fieldName); if (op == null) { throw Error.get(QueryConstants.ERR_INVALID_LOGICAL_EXPRESSION, node.toString()); } QueryExpression q = QueryExpression.fromJson(node.get(fieldName)); return new UnaryLogicalExpression(op, q); } }
/** * Parses a unary logical expression using the given object node */ public static UnaryLogicalExpression fromJson(ObjectNode node) { if (node.size() != 1) { throw Error.get(QueryConstants.ERR_INVALID_LOGICAL_EXPRESSION, node.toString()); } String fieldName = node.fieldNames().next(); UnaryLogicalOperator op = UnaryLogicalOperator.fromString(fieldName); if (op == null) { throw Error.get(QueryConstants.ERR_INVALID_LOGICAL_EXPRESSION, node.toString()); } QueryExpression q = QueryExpression.fromJson(node.get(fieldName)); return new UnaryLogicalExpression(op, q); } }
/** * Parses a find request from a json object. Unrecognized elements are * ignored. */ public void fromJson(ObjectNode node) { JsonNode x = node.get("query"); if (x != null) { query = QueryExpression.fromJson(x); } x = node.get("projection"); if (x != null) { projection = Projection.fromJson(x); } x = node.get("sort"); if (x != null) { sort = Sort.fromJson(x); } Range r = WithRange.fromJson(node); setFrom(r.from); setTo(r.to); }
/** * Parses a find request from a json object. Unrecognized elements are * ignored. */ public void fromJson(ObjectNode node) { JsonNode x = node.get("query"); if (x != null) { query = QueryExpression.fromJson(x); } x = node.get("projection"); if (x != null) { projection = Projection.fromJson(x); } x = node.get("sort"); if (x != null) { sort = Sort.fromJson(x); } Range r = WithRange.fromJson(node); setFrom(r.from); setTo(r.to); }
/** * Parses an update request from a Json object */ public static UpdateRequest fromJson(ObjectNode node) { UpdateRequest req = new UpdateRequest(); req.parse(node); JsonNode x = node.get("query"); if (x != null) { req.query = QueryExpression.fromJson(x); } x = node.get("update"); if (x != null) { req.updateExpression = UpdateExpression.fromJson(x); } x = node.get("projection"); if (x != null) { req.returnFields = Projection.fromJson(x); } WithIfCurrent.fromJson(req,node); Range r = WithRange.fromJson(node); req.setFrom(r.from); req.setTo(r.to); return req; } }