public Object visit(Not filter, Object extraData) {
   if (filter.getFilter() instanceof Not) {
     // simplify out double negation
     Not inner = (Not) filter.getFilter();
     return inner.getFilter().accept(this, extraData);
   } else {
     return super.visit(filter, extraData);
   }
 }
  private Filter translateOr(Or filter) throws IllegalFilterException {
    if (!(filter instanceof Or)) {
      return filter;
    }

    // a|b == ~~(a|b) negative introduction
    // ~(a|b) == (~a + ~b) modus ponens
    // ~~(a|b) == ~(~a + ~b) substitution
    // a|b == ~(~a + ~b) negative simpilification
    Iterator i = filter.getChildren().iterator();
    List translated = new ArrayList();

    while (i.hasNext()) {
      Filter f = (Filter) i.next();

      if (f instanceof Not) {
        // simplify it
        Not logic = (Not) f;
        Filter next = logic.getFilter();
        translated.add(next);
      } else {
        translated.add(ff.not(f));
      }
    }

    Filter and = ff.and(translated);
    return ff.not(and);
  }
示例#3
0
 @Override
 public Object visit(Not filter, Object extraData) {
   StringWriter output = asStringWriter(extraData);
   output.append("NOT (");
   filter.getFilter().accept(this, output);
   output.append(")");
   return output;
 }