public String toString() { StringBuffer buffer = new StringBuffer(); Step[] steps = getSteps(); if (steps != null) { for (int i = 0; i < steps.length; i++) { if (i > 0 || absolute) { buffer.append('/'); } buffer.append(steps[i]); } } return buffer.toString(); }
public Object compute(EvalContext context) { // Create a chain of contexts EvalContext rootContext; if (isAbsolute()) { rootContext = context.getRootContext().getAbsoluteRootContext(); } else { rootContext = new InitialContext(context); } return evalSteps(rootContext); }
/** * Checks if the path follows the JXPath restrictions on the type * of path that can be passed to create... methods. * @param expr Expression to check */ private void checkSimplePath(Expression expr) { if (!(expr instanceof LocationPath) || !((LocationPath) expr).isSimplePath()) { throw new JXPathInvalidSyntaxException( "JXPath can only create a path if it uses exclusively " + "the child:: and attribute:: axes and has " + "no context-dependent predicates"); } }
public Object computeValue(EvalContext context) { // Create a chain of contexts EvalContext rootContext; if (isAbsolute()) { rootContext = context.getRootContext().getAbsoluteRootContext(); } else { rootContext = new InitialContext(context); } return getSingleNodePointerForSteps(rootContext); } }
Step[] steps = locationPath.getSteps(); path.setAbsolute(locationPath.isAbsolute()); path.setSimplePath(locationPath.isSimplePath());
public Object locationPath(boolean absolute, Object[] steps) { return new LocationPath(absolute, toStepArray(steps)); }
/** * Learn whether arg is a name attribute test. * @param arg Expression to test * @return boolean */ private boolean isNameAttributeTest(Expression arg) { if (!(arg instanceof LocationPath)) { return false; } Step[] steps = ((LocationPath) arg).getSteps(); if (steps.length != 1) { return false; } if (steps[0].getAxis() != Compiler.AXIS_ATTRIBUTE) { return false; } NodeTest test = steps[0].getNodeTest(); if (!(test instanceof NodeNameTest)) { return false; } if (!((NodeNameTest) test).getNodeName().equals(QNAME_NAME)) { return false; } return true; } }