@Override public <T> T read(String path, Predicate... filters) { notEmpty(path, "path can not be null or empty"); // KR throw exception if config points to readRoot() if (configuration.getComputeRoot()) { throw new IllegalArgumentException("Invalid configuration, readRoot + read not supported."); } Cache cache = CacheProvider.getCache(); path = path.trim(); LinkedList filterStack = new LinkedList<Predicate>(asList(filters)); String cacheKey = Utils.concat(path, filterStack.toString()); JsonPath jsonPath = cache.get(cacheKey); if(jsonPath != null){ return read(jsonPath); } else { jsonPath = compile(path, filters); cache.put(cacheKey, jsonPath); return read(jsonPath); } }
@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); } }
if (isLeaf()) { if (ctx.configuration().getComputeRoot()) { checkAndFillArrayElements(ctx, ctx.getParent(), evalHit, effectiveIndex); if (ctx.configuration().getComputeRoot()) { curr = (ctx.configuration().jsonProvider().length(old) > effectiveIndex ? ctx.configuration().jsonProvider().getArrayIndex(old, effectiveIndex) : null); if (ctx.configuration().getComputeRoot()) { if (old != curr) {
if (ctx.configuration().getComputeRoot()) { if (null == ctx.configuration().jsonProvider().getProperty(ctx.getParent(), property)) { ctx.configuration().jsonProvider().setProperty(ctx.getParent(), property, propertyVal); if (ctx.configuration().getComputeRoot()) { curr = ctx.configuration().jsonProvider().getProperty(prev, property); if (null == curr) { if (ctx.configuration().getComputeRoot()) { if (prev != curr) { if (ctx.configuration().getComputeRoot()) { if (null == ctx.configuration().jsonProvider().getProperty(ctx.getParent(), property)) { ctx.configuration().jsonProvider().setProperty(ctx.getParent(), property, propertyVal);