public void invoke(PathFunction pathFunction, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { ctx.addResult(currentPath, parent, pathFunction.invoke(currentPath, parent, model, ctx, null)); }
@Override public void evaluate(String currentPath, PathRef pathRef, Object model, EvaluationContextImpl ctx) { if (isLeaf()) { PathRef op = ctx.forUpdate() ? pathRef : PathRef.NO_OP; ctx.addResult(rootToken, op, model); } else { next().evaluate(rootToken, pathRef, model, ctx); } }
@Override public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { PathFunction pathFunction = PathFunctionFactory.newFunction(functionName); evaluateParameters(currentPath, parent, model, ctx); Object result = pathFunction.invoke(currentPath, parent, model, ctx, functionParams); ctx.addResult(currentPath + "." + functionName, parent, result); if (!isLeaf()) { next().evaluate(currentPath, parent, result, ctx); } }
protected void handleArrayIndex(int index, String currentPath, Object model, EvaluationContextImpl ctx) { String evalPath = Utils.concat(currentPath, "[", String.valueOf(index), "]"); PathRef pathRef = ctx.forUpdate() ? PathRef.create(model, index) : PathRef.NO_OP; int effectiveIndex = index < 0 ? ctx.jsonProvider().length(model) + index : index; try { Object evalHit = ctx.jsonProvider().getArrayIndex(model, effectiveIndex); if (isLeaf()) { ctx.addResult(evalPath, pathRef, evalHit); } else { next().evaluate(evalPath, pathRef, evalHit, ctx); } } catch (IndexOutOfBoundsException e) { } }
@Override public void evaluate(String currentPath, PathRef ref, Object model, EvaluationContextImpl ctx) { if (ctx.jsonProvider().isMap(model)) { if (accept(model, ctx.rootDocument(), ctx.configuration(), ctx)) { PathRef op = ctx.forUpdate() ? ref : PathRef.NO_OP; if (isLeaf()) { ctx.addResult(currentPath, op, model); } else { next().evaluate(currentPath, op, model, ctx); } } } else if (ctx.jsonProvider().isArray(model)){ int idx = 0; Iterable<?> objects = ctx.jsonProvider().toIterable(model); for (Object idxModel : objects) { if (accept(idxModel, ctx.rootDocument(), ctx.configuration(), ctx)) { handleArrayIndex(idx, currentPath, model, ctx); } idx++; } } else { if (isUpstreamDefinite()) { throw new InvalidPathException(format("Filter: %s can not be applied to primitives. Current context is: %s", toString(), model)); } } }
public void invoke(PathFunction pathFunction, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { ctx.addResult(currentPath, parent, pathFunction.invoke(currentPath, parent, model, ctx, null)); }
@Override public void evaluate(String currentPath, PathRef pathRef, Object model, EvaluationContextImpl ctx) { if (isLeaf()) { PathRef op = ctx.forUpdate() ? pathRef : PathRef.NO_OP; ctx.addResult(rootToken, op, model); } else { next().evaluate(rootToken, pathRef, model, ctx); } }
@Override public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { PathFunction pathFunction = PathFunctionFactory.newFunction(functionName); evaluateParameters(currentPath, parent, model, ctx); Object result = pathFunction.invoke(currentPath, parent, model, ctx, functionParams); ctx.addResult(currentPath + "." + functionName, parent, result); if (!isLeaf()) { next().evaluate(currentPath, parent, result, ctx); } }
protected void handleArrayIndex(int index, String currentPath, Object model, EvaluationContextImpl ctx) { String evalPath = Utils.concat(currentPath, "[", String.valueOf(index), "]"); PathRef pathRef = ctx.forUpdate() ? PathRef.create(model, index) : PathRef.NO_OP; int effectiveIndex = index < 0 ? ctx.jsonProvider().length(model) + index : index; try { Object evalHit = ctx.jsonProvider().getArrayIndex(model, effectiveIndex); if (isLeaf()) { ctx.addResult(evalPath, pathRef, evalHit); } else { next().evaluate(evalPath, pathRef, evalHit, ctx); } } catch (IndexOutOfBoundsException e) { } }
@Override public void evaluate(String currentPath, PathRef ref, Object model, EvaluationContextImpl ctx) { if (ctx.jsonProvider().isMap(model)) { if (accept(model, ctx.rootDocument(), ctx.configuration(), ctx)) { PathRef op = ctx.forUpdate() ? ref : PathRef.NO_OP; if (isLeaf()) { ctx.addResult(currentPath, op, model); } else { next().evaluate(currentPath, op, model, ctx); } } } else if (ctx.jsonProvider().isArray(model)){ int idx = 0; Iterable<?> objects = ctx.jsonProvider().toIterable(model); for (Object idxModel : objects) { if (accept(idxModel, ctx.rootDocument(), ctx.configuration(), ctx)) { handleArrayIndex(idx, currentPath, model, ctx); } idx++; } } else { if (isUpstreamDefinite()) { throw new InvalidPathException(format("Filter: %s can not be applied to primitives. Current context is: %s", toString(), model)); } } }
public void invoke(PathFunction pathFunction, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { ctx.addResult(currentPath, parent, pathFunction.invoke(currentPath, parent, model, ctx, null)); }
@Override public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { PathFunction pathFunction = PathFunctionFactory.newFunction(functionName); evaluateParameters(currentPath, parent, model, ctx); Object result = pathFunction.invoke(currentPath, parent, model, ctx, functionParams); ctx.addResult(currentPath + "." + functionName, parent, result); if (!isLeaf()) { next().evaluate(currentPath, parent, result, ctx); } }
@Override public void evaluate(String currentPath, PathRef ref, Object model, EvaluationContextImpl ctx) { if (ctx.jsonProvider().isMap(model)) { if (accept(model, ctx.rootDocument(), ctx.configuration(), ctx)) { PathRef op = ctx.forUpdate() ? ref : PathRef.NO_OP; if (isLeaf()) { ctx.addResult(currentPath, op, model); } else { next().evaluate(currentPath, op, model, ctx); } } } else if (ctx.jsonProvider().isArray(model)){ int idx = 0; Iterable<?> objects = ctx.jsonProvider().toIterable(model); for (Object idxModel : objects) { if (accept(idxModel, ctx.rootDocument(), ctx.configuration(), ctx)) { handleArrayIndex(idx, currentPath, model, ctx); } idx++; } } else { if (isUpstreamDefinite()) { throw new InvalidPathException(format("Filter: %s can not be applied to primitives. Current context is: %s", toString(), model)); } } }
@Override public void evaluate(String currentPath, PathRef pathRef, Object model, EvaluationContextImpl ctx) { if (isLeaf()) { PathRef op = ctx.forUpdate() ? pathRef : PathRef.NO_OP; if (ctx.configuration().getComputeRoot()) { // KR ok to overwrite root here ctx.setRoot(model); ctx.setParent(model); } ctx.addResult(rootToken, op, model); } else { if (ctx.configuration().getComputeRoot()) { Object root; if (null != ctx.getRoot()) { root = ctx.getRoot(); } else { root = ctx.configuration().jsonProvider().copy(model); } ctx.setRoot(root); ctx.setParent(root); } next().evaluate(rootToken, pathRef, model, ctx); } }
checkAndFillArrayElements(ctx, ctx.getParent(), evalHit, effectiveIndex); ctx.addResult(evalPath, pathRef, evalHit); } else {