public void visitSingle(Single term) {
      Operator op = term.getOperator();
      boolean negation = term.isNegation();

      // gt = !le, lt = !ge
      if (op.equals(Operator.gt)) {
        op = Operator.le;
        negation = !negation;
      } else if (op.equals(Operator.lt)) {
        op = Operator.ge;
        negation = !negation;
      }

      if (negation) {
        mLdapFilter.append("(!");
      }

      ZLdapFilterFactory filterFactory = ZLdapFilterFactory.getInstance();
      String filter = null;

      String attr = term.getLhs();
      String val = getVal(term);
      if (op.equals(Operator.has)) {
        filter = filterFactory.substringFilter(attr, val, valueIsRaw);
      } else if (op.equals(Operator.eq)) {
        // there is no presence operator in Single
        if (val.equals("*")) {
          filter = filterFactory.presenceFilter(attr);
        } else {
          filter = filterFactory.equalityFilter(attr, val, valueIsRaw);
        }
      } else if (op.equals(Operator.ge)) {
        filter = filterFactory.greaterOrEqualFilter(attr, val, valueIsRaw);
      } else if (op.equals(Operator.le)) {
        filter = filterFactory.lessOrEqualFilter(attr, val, valueIsRaw);
      } else if (op.equals(Operator.startswith)) {
        filter = filterFactory.startsWithFilter(attr, val, valueIsRaw);
      } else if (op.equals(Operator.endswith)) {
        filter = filterFactory.endsWithFilter(attr, val, valueIsRaw);
      } else {
        // fallback to EQUALS
        filter = filterFactory.equalityFilter(attr, val, valueIsRaw);
      }

      mLdapFilter.append(filter);

      if (negation) {
        mLdapFilter.append(')');
      }
    }
    protected String getVal(Single term) {
      String rhs = term.getRhs();

      AttributeManager attrMgr = null;
      try {
        attrMgr = AttributeManager.getInstance();
      } catch (ServiceException e) {
        ZimbraLog.account.warn("failed to get AttributeManager instance", e);
      }

      IDNType idnType = AttributeManager.idnType(attrMgr, term.getLhs());
      rhs = IDNUtil.toAscii(rhs, idnType);

      return rhs;
    }
 protected String getVal(Single term) {
   // return LdapUtil.escapeSearchFilterArg(term.getRhs());
   return term.getRhs();
 }