@Override public void start() { assert predicateResult != Boolean.FALSE; assert !finished; if (event.hasInstantListener(expression)) { if (listener instanceof LocationEvaluation) predicateChain = ((LocationEvaluation) listener).predicateChain; else predicateChain = 0; if (predicateEvaluation != null) predicateChain++; } if (predicateEvaluation != null) { Expression predicate = predicateEvaluation.expression; if (predicate.scope() != Scope.DOCUMENT) predicateEvaluation.start(); } eventID.addListener(event, currentStep, this); }
public PathExpression(LocationPath union, Expression relativeExpression, boolean forEach) { super(Scope.DOCUMENT, relativeExpression.resultType); assert relativeExpression.scope() != Scope.DOCUMENT; this.union = union; contexts = new Expression[union.contexts.size()]; for (int i = 0; i < contexts.length; i++) contexts[i] = union.contexts.get(i).typeCast(DataType.NODESET); this.relativeExpression = relativeExpression; if (relativeExpression instanceof LocationExpression) ((LocationExpression) relativeExpression).rawResult = true; else ((Literal) relativeExpression).rawResultRequired(); this.forEach = forEach; if (union.hitExpression != null) union.hitExpression.pathExpression = this; }
private void resultPrepared() { if (!resultPrepared) { manuallyExpired = true; resultPrepared = true; for (LinkableEvaluation pendingEval = pendingEvaluationHead; pendingEval != null; pendingEval = pendingEval.next) pendingEval.removeListener(this); pendingEvaluationHead = pendingEvaluationTail = null; } if (predicateResult != null && (index != 0 || (stringEvaluations == null || stringEvaluations.size() == 0))) finished(); else if (result.size() == 0 && predicateResult == null) { // when result is empty, there is no need to wait for predicateEvaluation to // finish Expression predicate = predicateEvaluation.expression; if (predicate.scope() != Scope.DOCUMENT) predicateEvaluation.removeListener(this); else event.removeListener(predicate, this); finished(); } }