code: public static String escapeLDAPFilterTerm(String term) {
          if (term == null)
              return null;
          Matcher m = FILTER_CHARS_TO_ESCAPE.matcher(term);
          StringBuffer sb = new StringBuffer(term.length());
          while (m.find()) {
              final String replacement = escapeFilterChar(m.group().charAt(0));
              m.appendReplacement(sb, Matcher.quoteReplacement(replacement));
          }
          m.appendTail(sb);
          return sb.toString();
      }
docs: Escape a term for use in an LDAP filter.
  
  @param term
  @return