&& step1.getAxis() == Axis.DESCENDANT_OR_SELF) { if (step2 instanceof NameStep && step2.getAxis() == Axis.CHILD) { final List<Predicate> predicates = step2.getPredicates(); allNodeStep.addPredicate(predicate);
public String getText() { StringBuffer buf = new StringBuffer(); Iterator stepIter = getSteps().iterator(); while (stepIter.hasNext()) { buf.append(((Step) stepIter.next()).getText()); if (stepIter.hasNext()) { buf.append("/"); } } return buf.toString(); }
public Object evaluate(Context context) throws JaxenException { List nodeSet = context.getNodeSet(); List contextNodeSet = new ArrayList(nodeSet); ContextSupport support = context.getContextSupport(); Context stepContext = new Context(support); Iterator stepIter = getSteps().iterator(); while ( stepIter.hasNext() ) { Step eachStep = (Step) stepIter.next(); stepContext.setNodeSet(contextNodeSet); contextNodeSet = eachStep.evaluate(stepContext); // now we need to reverse the list if this is a reverse axis if (isReverseAxis(eachStep)) { Collections.reverse(contextNodeSet); } } if (getSteps().size() > 1 || nodeSet.size() > 1) { Collections.sort(contextNodeSet, new NodeComparator(support.getNavigator())); } return contextNodeSet; }
public PredicatesEvaluatorBuilder(Step step, Step attributeStep, SelectorStep selectorStep, Properties namespaces) { this.step = step; this.attributeStep = attributeStep; this.selectorStep = selectorStep; this.namespaces = namespaces; if(attributeStep != null && attributeStep.getAxis() != Axis.ATTRIBUTE) { throw new IllegalStateException("Unexpected 'attributeStep' arg '" + attributeStep.getText() + "'. Must be an ATTRIBUTE Axis step."); } }
private boolean isReverseAxis(Step step) { int axis = step.getAxis(); return axis == org.jaxen.saxpath.Axis.PRECEDING || axis == org.jaxen.saxpath.Axis.PRECEDING_SIBLING || axis == org.jaxen.saxpath.Axis.ANCESTOR || axis == org.jaxen.saxpath.Axis.ANCESTOR_OR_SELF; }
protected static boolean navigationStep( Step step ) { if ( step instanceof DefaultNameStep ) { return true; } else if ( step.getClass().equals( DefaultStep.class ) ) { return ! step.getPredicates().isEmpty(); } else { return true; } }
if ( !step.getPredicates().isEmpty() ) { List<?> predicates = step.getPredicates(); if ( predicates.size() == 1 ) { Expr predicate = ( (Predicate) predicates.get( 0 ) ).getExpr(); NameStep ns = (NameStep) step; QName name = getQName( ns ); if ( step.getAxis() == Axis.ATTRIBUTE ) { for ( TypedObjectNode particleValue : particleValues ) { if ( particleValue instanceof PrimitiveValue ) { } else if ( step.getAxis() == Axis.CHILD ) { for ( TypedObjectNode particleValue : particleValues ) { if ( particleValue instanceof PrimitiveValue ) { LOG.warn( "Unhandled axis type '" + step.getAxis() + "' for path: '" + particleMapping.getPath() + "'" );
public PredicatesEvaluatorBuilder(Step step, Step attributeStep, SelectorStep selectorStep, Properties namespaces) { this.step = step; this.attributeStep = attributeStep; this.selectorStep = selectorStep; this.namespaces = namespaces; if(attributeStep != null && attributeStep.getAxis() != Axis.ATTRIBUTE) { throw new IllegalStateException("Unexpected 'attributeStep' arg '" + attributeStep.getText() + "'. Must be an ATTRIBUTE Axis step."); } }
int axis = step.getAxis(); if ( axis == Axis.DESCENDANT || axis == Axis.DESCENDANT_OR_SELF )
private void addEvaluators(Step step, PredicatesEvaluator evaluator) throws SAXPathException { List<Predicate> predicates = step.getPredicates(); for (Predicate predicate : predicates) { XPathExpressionEvaluator predicateEvaluator = XPathExpressionEvaluator.getInstance(predicate.getExpr(), selectorStep, namespaces); evaluator.addEvaluator(predicateEvaluator); } }
public PredicatesEvaluatorBuilder(Step step, Step attributeStep, SelectorStep selectorStep, Properties namespaces) { this.step = step; this.attributeStep = attributeStep; this.selectorStep = selectorStep; this.namespaces = namespaces; if(attributeStep != null && attributeStep.getAxis() != Axis.ATTRIBUTE) { throw new IllegalStateException("Unexpected 'attributeStep' arg '" + attributeStep.getText() + "'. Must be an ATTRIBUTE Axis step."); } }
&& step1.getAxis() == Axis.DESCENDANT_OR_SELF) { if (step2 instanceof NameStep && step2.getAxis() == Axis.CHILD) { final List<Predicate> predicates = step2.getPredicates(); allNodeStep.addPredicate(predicate);
int axis = step.getAxis(); if ( axis == Axis.ATTRIBUTE )
@SuppressWarnings("unchecked") private void addEvaluators(Step step, PredicatesEvaluator evaluator) throws SAXPathException { List<Predicate> predicates = step.getPredicates(); for (Predicate predicate : predicates) { XPathExpressionEvaluator predicateEvaluator = XPathExpressionEvaluator.getInstance(predicate.getExpr(), selectorStep, namespaces); evaluator.addEvaluator(predicateEvaluator); } }
@SuppressWarnings("unchecked") public String getElementNameWithPredicates() throws JaxenException { BaseXPath baseXPath = new BaseXPath(xPath, new DocumentNavigator()); Expr rootExpr = baseXPath.getRootExpr(); LocationPath locationPath = (LocationPath) rootExpr; List<Step> steps = locationPath.getSteps(); Step lastStep = steps.get(steps.size() - 1); return MCRNodeBuilder.simplify(lastStep.getText()); }
public PredicatesEvaluatorBuilder(Step step, Step attributeStep, SelectorStep selectorStep, Properties namespaces) { this.step = step; this.attributeStep = attributeStep; this.selectorStep = selectorStep; this.namespaces = namespaces; if(attributeStep != null && attributeStep.getAxis() != Axis.ATTRIBUTE) { throw new IllegalStateException("Unexpected 'attributeStep' arg '" + attributeStep.getText() + "'. Must be an ATTRIBUTE Axis step."); } }
@SuppressWarnings("unchecked") private void addEvaluators(Step step, PredicatesEvaluator evaluator) throws SAXPathException { List<Predicate> predicates = step.getPredicates(); for (Predicate predicate : predicates) { XPathExpressionEvaluator predicateEvaluator = XPathExpressionEvaluator.getInstance(predicate.getExpr(), selectorStep, namespaces); evaluator.addEvaluator(predicateEvaluator); } }
public XPathExpressionEvaluator build() throws SAXPathException { PredicatesEvaluator evaluator = new PredicatesEvaluator(); if (!(step instanceof NameStep)) { throw new SAXPathException("Unsupported step '" + step.getText() + "'."); } addEvaluators(step, evaluator); // Add the evaluators for the attribute step... if(attributeStep != null) { addEvaluators(attributeStep, evaluator); } return evaluator; }
public PredicatesEvaluatorBuilder(Step step, Step attributeStep, SelectorStep selectorStep, Properties namespaces) { this.step = step; this.attributeStep = attributeStep; this.selectorStep = selectorStep; this.namespaces = namespaces; if(attributeStep != null && attributeStep.getAxis() != Axis.ATTRIBUTE) { throw new IllegalStateException("Unexpected 'attributeStep' arg '" + attributeStep.getText() + "'. Must be an ATTRIBUTE Axis step."); } }