JsonPath仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

package com.jayway.jsonpath.internal;
12 years ago
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.internal.compiler.EvaluationContextImpl;
import com.jayway.jsonpath.internal.compiler.PathToken;
12 years ago
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CompiledPath implements Path {
12 years ago
private static final Logger logger = LoggerFactory.getLogger(CompiledPath.class);
private final PathToken root;
private final boolean isRootPath;
12 years ago
public CompiledPath(PathToken root, boolean isRootPath) {
12 years ago
this.root = root;
this.isRootPath = isRootPath;
}
@Override
public boolean isRootPath() {
return isRootPath;
12 years ago
}
@Override
public EvaluationContext evaluate(Object document, Object rootDocument, Configuration configuration) {
if (logger.isDebugEnabled()) {
12 years ago
logger.debug("Evaluating path: {}", toString());
}
EvaluationContextImpl ctx = new EvaluationContextImpl(this, rootDocument, configuration);
root.evaluate("", document, ctx);
12 years ago
return ctx;
}
@Override
public boolean isDefinite() {
return root.isPathDefinite();
}
@Override
public String toString() {
return root.toString();
}
}