Beispiel #1
0
  // implement SargExpr
  public SargIntervalSequence evaluate() {
    if (setOp == SargSetOperator.COMPLEMENT) {
      assert (children.size() == 1);
      SargExpr child = children.get(0);
      return child.evaluateComplemented();
    }

    List<SargIntervalSequence> list = evaluateChildren(this);

    switch (setOp) {
      case UNION:
        return evaluateUnion(list);
      case INTERSECTION:
        return evaluateIntersection(list);
      default:
        throw Util.newInternal(setOp.toString());
    }
  }
Beispiel #2
0
  // implement SargExpr
  public SargIntervalSequence evaluateComplemented() {
    if (setOp == SargSetOperator.COMPLEMENT) {
      // Double negation is a nop
      return children.get(0).evaluate();
    }

    // Use DeMorgan's Law:  complement of union is intersection of
    // complements, and vice versa
    List<SargIntervalSequence> list = new ArrayList<SargIntervalSequence>();
    for (SargExpr child : children) {
      SargIntervalSequence newSeq = child.evaluateComplemented();
      list.add(newSeq);
    }
    switch (setOp) {
      case INTERSECTION:
        return evaluateUnion(list);
      case UNION:
        return evaluateIntersection(list);
      default:
        throw Util.newInternal(setOp.toString());
    }
  }