public static Pattern computeJavaPattern ( String sqlPattern ) { StringBuffer pattern_buff = new StringBuffer ( ) ; // Replace "_" with "." (match exactly 1 character) // Replace "%" with ".*" (match 0 or more characters) for ( int i = 0 ; i < sqlPattern . length ( ) ; i ++ ) { char c = sqlPattern . charAt ( i ) ; if ( c == ' ' ) { pattern_buff . append ( ' ' ) ; } else if ( c == ' ' ) { pattern_buff . append ( ".*" ) ; } else pattern_buff . append ( c ) ; } return Pattern . compile ( pattern_buff . toString ( ) ) ; }
Convert the users VoltDB SQL pattern into a regex pattern