Package com.jayway.jsonpath.internal.token

Examples of com.jayway.jsonpath.internal.token.RootPathToken


            if (p != null) {
                if (logger.isDebugEnabled()) logger.debug("Using cached path: " + cacheKey);
                return p;
            }

            RootPathToken root = null;


            int i = 0;
            int positions;
            String fragment = "";

            do {
                char current = path.charAt(i);

                switch (current) {
                    case SPACE:
                        throw new InvalidPathException("Space not allowed in path");
                    case DOCUMENT:
                        fragment = "$";
                        i++;
                        break;
                    case BRACKET_OPEN:
                        positions = fastForwardUntilClosed(path, i);
                        fragment = path.substring(i, i + positions);
                        i += positions;
                        break;
                    case PERIOD:
                        i++;
                        if (path.charAt(i) == PERIOD) {
                            //This is a deep scan
                            fragment = "..";
                            i++;
                        } else {
                            positions = fastForward(path, i);
                            if (positions == 0) {
                                continue;

                            } else if (positions == 1 && path.charAt(i) == '*') {
                                fragment = new String("[*]");
                            } else {
                                assertValidFieldChars(path, i, positions);

                                fragment = PROPERTY_OPEN + path.substring(i, i + positions) + PROPERTY_CLOSE;
                            }
                            i += positions;
                        }
                        break;
                    case ANY:
                        fragment = new String("[*]");
                        i++;
                        break;
                    default:
                        positions = fastForward(path, i);

                        fragment = PROPERTY_OPEN + path.substring(i, i + positions) + PROPERTY_CLOSE;
                        i += positions;
                        break;
                }
                if (root == null) {
                    root = (RootPathToken) PathComponentAnalyzer.analyze(fragment, filterList);
                } else {
                    root.append(PathComponentAnalyzer.analyze(fragment, filterList));
                }

            } while (i < path.length());

            Path pa = new CompiledPath(root, isRootPath);
View Full Code Here


            return new PathComponentAnalyzer(pathFragment, filterList).analyze();
        }

        public PathToken analyze() {

            if ("$".equals(pathFragment)) return new RootPathToken();
            else if ("..".equals(pathFragment)) return new ScanPathToken();
            else if ("[*]".equals(pathFragment)) return new WildcardPathToken();
            else if (".*".equals(pathFragment)) return new WildcardPathToken();
            else if ("[?]".equals(pathFragment)) return new PredicatePathToken(filterList.poll());

View Full Code Here

TOP

Related Classes of com.jayway.jsonpath.internal.token.RootPathToken

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.