示例#1
0
  @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);
  }
示例#2
0
  @Override
  public void onHit(EventID eventID) {
    assert !finished : "getting events even after finish";

    final LocationExpression expression = this.expression;
    if (!lastStep) {
      if (eventID.isEmpty(expression.locationPath.steps[index + 1].axis)) return;
    }

    final Event event = this.event;

    if (positionTracker != null) {
      event.positionTrackerStack.addFirst(positionTracker);
      positionTracker.addEvaluation(event);
    }
    LinkableEvaluation childEval = null;

    Expression predicate = currentStep.predicateSet.getPredicate();
    Object predicateResult = predicate == null ? Boolean.TRUE : event.evaluate(predicate);
    if (predicateResult == Boolean.TRUE) {
      if (lastStep) consume(event);
      else childEval = new LocationEvaluation(expression, index + 1, event, eventID);
    } else if (predicateResult == null) {
      Evaluation predicateEvaluation = event.evaluation;
      if (lastStep) {
        childEval =
            new PredicateEvaluation(
                expression,
                event.order(),
                expression.getResultItem(event),
                event,
                predicate,
                predicateEvaluation);
        if (nodeSetListener != null) nodeSetListener.mayHit();
      } else
        childEval =
            new LocationEvaluation(
                expression, index + 1, event, eventID, predicate, predicateEvaluation);
    }

    if (childEval != null) {
      if (childEval instanceof LocationEvaluation)
        ((LocationEvaluation) childEval).nodeSetListener = nodeSetListener;
      else ((PredicateEvaluation) childEval).nodeSetListener = nodeSetListener;

      childEval.addListener(this);
      if (pendingEvaluationTail != null) {
        pendingEvaluationTail.next = childEval;
        childEval.previous = pendingEvaluationTail;
        pendingEvaluationTail = childEval;
      } else pendingEvaluationHead = pendingEvaluationTail = childEval;
      childEval.start();
    }

    if (positionTracker != null) {
      positionTracker.startEvaluation();
      event.positionTrackerStack.pollFirst();
    }
    if (exactPosition && predicateResult == Boolean.TRUE) {
      manuallyExpired = true;
      expired();
    }
  }