private String translatePattern(String pattern,String from,String to){
  StringBuilder result=new StringBuilder();
  boolean inQuote=false;
  for (int i=0; i < pattern.length(); ++i) {
    char c=pattern.charAt(i);
    if (inQuote) {
      if (c == '\'') {
        inQuote=false;
      }
    }
 else {
      if (c == '\'') {
        inQuote=true;
      }
 else       if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
        int ci=from.indexOf(c);
        if (ci >= 0) {
          if (ci < to.length()) {
            c=to.charAt(ci);
          }
        }
 else {
          throw new IllegalArgumentException("Illegal pattern " + " character '" + c + "'");
        }
      }
    }
    result.append(c);
  }
  if (inQuote) {
    throw new IllegalArgumentException("Unfinished quote in pattern");
  }
  return result.toString();
}

private String translatePattern ( String pattern , String from , String to ) { StringBuilder result = new StringBuilder ( ) ; boolean inQuote = false ; for ( int i = 0 ; i < pattern . length ( ) ; ++ i ) { char c = pattern . charAt ( i ) ; if ( inQuote ) { if ( c == '\'' ) { inQuote = false ; } } else { if ( c == '\'' ) { inQuote = true ; } else if ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) ) { int ci = from . indexOf ( c ) ; if ( ci >= 0 ) { if ( ci < to . length ( ) ) { c = to . charAt ( ci ) ; } } else { throw new IllegalArgumentException ( "Illegal pattern " + " character '" + c + "'" ) ; } } } result . append ( c ) ; } if ( inQuote ) { throw new IllegalArgumentException ( "Unfinished quote in pattern" ) ; } return result . toString ( ) ; }
translates a pattern , mapping each character in the from string to the corresponding character in the to string .
