Examples of PathToken


Examples of com.jayway.jsonpath.internal.PathToken

        }

        Object modelRef = jsonObject;

        if (jsonPath.getTokenizer().size() == 1) {
            PathToken onlyToken = jsonPath.getTokenizer().iterator().next();
            if ("$".equals(onlyToken.getFragment())) {
                return clazz.cast(modelRef);
            }
        } else {

            LinkedList<PathToken> tokens = jsonPath.getTokenizer().getPathTokens();

            PathToken currentToken;
            do {
                currentToken = tokens.poll();
                modelRef = currentToken.apply(modelRef, this.configuration);
            } while (!tokens.isEmpty());

            if (modelRef.getClass().isAssignableFrom(clazz)) {
                throw new InvalidModelException(jsonPath + " does nor refer to a Map but " + currentToken.getClass().getName());
            }
            return clazz.cast(modelRef);
        }
        throw new InvalidModelException();
    }
View Full Code Here

Examples of com.jayway.jsonpath.internal.PathToken

        throw new InvalidModelException();
    }

    private void setTargetObject(JsonPath jsonPath, Object newValue) {
        JsonPath setterPath = jsonPath.copy();
        PathToken pathToken = setterPath.getTokenizer().removeLastPathToken();


        if (pathToken.isRootToken()) {
            if (this instanceof JsonSubModel) {
                JsonSubModel thisModel = (JsonSubModel) this;

                thisModel.parent.setTargetObject(thisModel.subModelPath, newValue);
            } else {
                this.jsonObject = newValue;
            }
        } else {
            if (pathToken.isArrayIndexToken()) {
                int arrayIndex = pathToken.getArrayIndex();
                opsForArray(setterPath).set(arrayIndex, newValue);
            } else {
                opsForObject(setterPath).put(pathToken.getFragment(), newValue);
            }
        }
    }
View Full Code Here

Examples of com.jayway.jsonpath.internal.PathToken

        PlainJavaJsonProvider provider = new PlainJavaJsonProvider();
        Configuration configuration = Configuration.builder().jsonProvider(provider).build();
        jsonObject = provider.parse(currentJson);
        JsonPath path = JsonPath.compile(jsonPathExpression);
        LinkedList<PathToken> pathTokens = getPathTokensFrom(path);
        PathToken endToken = pathTokens.removeLast();
        int index = pathTokens.size();
        JsonWriteDecorator writeDecorator = new JsonWriteDecorator(provider, index, endToken, value);
        pathTokens.addLast(writeDecorator);
        path.read(jsonObject, configuration);
        jsonObject = MutableValue.FROM_MUTABLE_VALUE.apply(jsonObject);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.