Search in sources :

Example 1 with Path

use of com.jayway.jsonpath.internal.Path in project JsonPath by jayway.

the class PathCompiler method compile.

public static Path compile(String path, final Predicate... filters) {
    try {
        path = path.trim();
        if (!(path.charAt(0) == DOC_CONTEXT) && !(path.charAt(0) == EVAL_CONTEXT)) {
            path = "$." + path;
        }
        if (path.endsWith(".")) {
            fail("Path must not end with a '.' or '..'");
        }
        LinkedList filterStack = new LinkedList<Predicate>(asList(filters));
        Path p = new PathCompiler(path.trim(), filterStack).compile();
        return p;
    } catch (Exception e) {
        InvalidPathException ipe;
        if (e instanceof InvalidPathException) {
            ipe = (InvalidPathException) e;
        } else {
            ipe = new InvalidPathException(e);
        }
        throw ipe;
    }
}
Also used : Path(com.jayway.jsonpath.internal.Path) LinkedList(java.util.LinkedList) InvalidPathException(com.jayway.jsonpath.InvalidPathException) InvalidPathException(com.jayway.jsonpath.InvalidPathException)

Aggregations

InvalidPathException (com.jayway.jsonpath.InvalidPathException)1 Path (com.jayway.jsonpath.internal.Path)1 LinkedList (java.util.LinkedList)1