/** * Generates the code for a new JmesPathProjection. * * @param jmesPathProjection JmesPath projection type * @param aVoid void * @return String that represents a call to * the new list projection * @throws InvalidTypeException */ @Override public String visit(final JmesPathProjection jmesPathProjection, final Void aVoid) throws InvalidTypeException { return "new JmesPathProjection( " + jmesPathProjection.getLhsExpr() .accept(this, aVoid) + ", " + jmesPathProjection.getProjectionExpr() .accept(this, aVoid) + ")"; }
private static JmesPathExpression jsonToProjection(JsonNode jsonNode) { List<JmesPathExpression> args = getChildren(jsonNode); return new JmesPathProjection(args.get(0), args.get(1)); }
/** * Evaluates a list projection expression in two steps. * The left hand side (LHS) creates a JSON array of initial * values. * The right hand side (RHS) of a projection is the * expression to project for each element in the JSON array * created by the left hand side. * * @param jmesPathProjection JmesPath list projection type * @param input Input json node against which evaluation is done * @return Result of the projection evaluation * @throws InvalidTypeException */ @Override public JsonNode visit(JmesPathProjection jmesPathProjection, JsonNode input) throws InvalidTypeException { JsonNode lhsResult = jmesPathProjection.getLhsExpr().accept(this, input); if (lhsResult.isArray()) { Iterator<JsonNode> elements = lhsResult.elements(); ArrayNode projectedArrayNode = ObjectMapperSingleton.getObjectMapper().createArrayNode(); while (elements.hasNext()) { JsonNode projectedElement = jmesPathProjection.getProjectionExpr().accept(this, elements.next()); if (projectedElement != null) { projectedArrayNode.add(projectedElement); } } return projectedArrayNode; } return NullNode.getInstance(); }
private static JmesPathExpression jsonToProjection(JsonNode jsonNode) { List<JmesPathExpression> args = getChildren(jsonNode); return new JmesPathProjection(args.get(0), args.get(1)); }
/** * Generates the code for a new JmesPathProjection. * * @param jmesPathProjection JmesPath projection type * @param aVoid void * @return String that represents a call to * the new list projection * @throws InvalidTypeException */ @Override public String visit(final JmesPathProjection jmesPathProjection, final Void aVoid) throws InvalidTypeException { return "new JmesPathProjection( " + jmesPathProjection.getLhsExpr() .accept(this, aVoid) + ", " + jmesPathProjection.getProjectionExpr() .accept(this, aVoid) + ")"; }
/** * Evaluates a list projection expression in two steps. * The left hand side (LHS) creates a JSON array of initial * values. * The right hand side (RHS) of a projection is the * expression to project for each element in the JSON array * created by the left hand side. * * @param jmesPathProjection JmesPath list projection type * @param input Input json node against which evaluation is done * @return Result of the projection evaluation * @throws InvalidTypeException */ @Override public JsonNode visit(JmesPathProjection jmesPathProjection, JsonNode input) throws InvalidTypeException { JsonNode lhsResult = jmesPathProjection.getLhsExpr().accept(this, input); if (lhsResult.isArray()) { Iterator<JsonNode> elements = lhsResult.elements(); ArrayNode projectedArrayNode = ObjectMapperSingleton.getObjectMapper().createArrayNode(); while (elements.hasNext()) { JsonNode projectedElement = jmesPathProjection.getProjectionExpr().accept(this, elements.next()); if (projectedElement != null) { projectedArrayNode.add(projectedElement); } } return projectedArrayNode; } return NullNode.getInstance(); }
/** * Evaluates a list projection expression in two steps. * The left hand side (LHS) creates a JSON array of initial * values. * The right hand side (RHS) of a projection is the * expression to project for each element in the JSON array * created by the left hand side. * * @param jmesPathProjection JmesPath list projection type * @param input Input json node against which evaluation is done * @return Result of the projection evaluation * @throws InvalidTypeException */ @Override public JsonNode visit(JmesPathProjection jmesPathProjection, JsonNode input) throws InvalidTypeException { JsonNode lhsResult = jmesPathProjection.getLhsExpr().accept(this, input); if (lhsResult.isArray()) { Iterator<JsonNode> elements = lhsResult.elements(); ArrayNode projectedArrayNode = ObjectMapperSingleton.getObjectMapper().createArrayNode(); while (elements.hasNext()) { JsonNode projectedElement = jmesPathProjection.getProjectionExpr().accept(this, elements.next()); if (projectedElement != null) { projectedArrayNode.add(projectedElement); } } return projectedArrayNode; } return NullNode.getInstance(); }