public static String convertToSQL92(char escape, char multi, char single, String pattern)
			throws IllegalArgumentException {
		if ((escape == '\'') || (multi == '\'') || (single == '\'')) {
			throw new IllegalArgumentException("do not use single quote (') as special char!");
		}
		
		StringBuilder result = new StringBuilder(pattern.length() + 5);
		int i = 0;
		while (i < pattern.length()) {
			char chr = pattern.charAt(i);
			if (chr == escape) {
				// emit the next char and skip it
				if (i != (pattern.length() - 1)) {
					result.append(pattern.charAt(i + 1));
				}
				i++; // skip next char
			} else if (chr == single) {
				result.append('_');
			} else if (chr == multi) {
				result.append('%');
			} else if (chr == '\'') {
				result.append('\'');
				result.append('\'');
			} else {
				result.append(chr);
			}
			i++;
		}

		return result.toString();
	}
public static String convertToSQL92 ( char escape , char multi , char single , String pattern ) throws IllegalArgumentException { if ( ( escape == '\'' ) || ( multi == '\'' ) || ( single == '\'' ) ) { throw new IllegalArgumentException ( "do not use single quote (') as special char!" ) ; } StringBuilder result = new StringBuilder ( pattern . length ( ) + 5 ) ; int i = 0 ; while ( i < pattern . length ( ) ) { char chr = pattern . charAt ( i ) ; if ( chr == escape ) { if ( i != ( pattern . length ( ) - 1 ) ) { result . append ( pattern . charAt ( i + 1 ) ) ; } i ++ ; } else if ( chr == single ) { result . append ( '_' ) ; } else if ( chr == multi ) { result . append ( '%' ) ; } else if ( chr == '\'' ) { result . append ( '\'' ) ; result . append ( '\'' ) ; } else { result . append ( chr ) ; } i ++ ; } return result . toString ( ) ; }
Given OGC PropertyIsLike Filter information, construct an SQL-compatible 'like' pattern.

SQL % --> match any number of characters _ --> match a single character

NOTE; the SQL command is 'string LIKE pattern [ESCAPE escape-character]' We could re-define the escape character,
but I'm not doing to do that in this code since some databases will not handle this case.

Method: 1.

Examples: ( escape ='!', multi='*', single='.' ) broadway* -> 'broadway%' broad_ay -> 'broad_ay' broadway ->
'broadway'

broadway!* -> 'broadway*' (* has no significance and is escaped) can't -> 'can''t' ( ' escaped for SQL
compliance)


NOTE: we also handle "'" characters as special because they are end-of-string characters. SQL will convert ' to
'' (double single quote).

NOTE: we don't handle "'" as a 'special' character because it would be too confusing to have a special char as
another special char. Using this will throw an error (IllegalArgumentException).

@param escape escape character
@param multi ?????
@param single ?????
@param pattern pattern to match
@return SQL like sub-expression
@throws IllegalArgumentException oops