code: private String translatePattern(String pat, String from, String to) {
          StringBuilder result = new StringBuilder();
          boolean inQuote = false;
          for (int i = 0; i < pat.length(); ++i) {
              char c = pat.charAt(i);
              if (inQuote) {
                  if (c == '\'')
                      inQuote = false;
              } else {
                  if (c == '\'') {
                      inQuote = true;
                  } else if (isSyntaxChar(c)) {
                      int ci = from.indexOf(c);
                      if (ci != -1) {
                          c = to.charAt(ci);
                      }
                      // do not worry on translatepattern if the character is not listed
                      // we do the validity check elsewhere
                  }
              }
              result.append(c);
          }
          if (inQuote) {
              throw new IllegalArgumentException("Unfinished quote in pattern");
          }
          return result.toString();
      }
docs: Translate a pattern, mapping each character in the from string to the
  corresponding character in the to string.