Package com.jayway.jsonpath.internal

Examples of com.jayway.jsonpath.internal.Path


    }

    private Object evaluateIfPath(Object target, PredicateContext ctx){
        Object res = target;
        if(res instanceof Path){
            Path leftPath = (Path) target;

            if(ctx instanceof PredicateContextImpl){
                //This will use cache for document ($) queries
                PredicateContextImpl ctxi = (PredicateContextImpl) ctx;
                res = ctxi.evaluate(leftPath);
            } else {
                Object doc = leftPath.isRootPath()?ctx.root():ctx.item();
                res = leftPath.evaluate(doc, ctx.root(), ctx.configuration()).getValue();
            }
        }
        return res;
    }
View Full Code Here


     * @return a new Criteria
     */
    public static Criteria create(String left, String operator, String right) {
        Object leftPrepared = left;
        Object rightPrepared = right;
        Path leftPath = null;
        Path rightPath = null;
        boolean existsCheck = true;

        if(isPath(left)){
            if(left.charAt(0) == '!'){
                existsCheck = false;
                left = left.substring(1);
            }
            leftPath = PathCompiler.compile(left);
            if(!leftPath.isDefinite()){
                throw new InvalidPathException("the predicate path: " + left + " is not definite");
            }
            leftPrepared = leftPath;
        } else if(isString(left)) {
            leftPrepared = left.substring(1, left.length() - 1);
        } else if(isPattern(left)){
            leftPrepared = compilePattern(left);
        }

        if(isPath(right)){
            if(right.charAt(0) == '!'){
                throw new InvalidPathException("Invalid negation! Can only be used for existence check e.g [?(!@.foo)]");
            }
            rightPath = PathCompiler.compile(right);
            if(!rightPath.isDefinite()){
                throw new InvalidPathException("the predicate path: " + right + " is not definite");
            }
            rightPrepared = rightPath;
        } else if(isString(right)) {
            rightPrepared = right.substring(1, right.length() - 1);
View Full Code Here

TOP

Related Classes of com.jayway.jsonpath.internal.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.