private String transformSQLCase(String sql){
  StringBuilder s=new StringBuilder(sql);
  try {
    PositionedStringReader r=new PositionedStringReader(sql);
    StreamTokenizer st=new StreamTokenizer(r);
    st.resetSyntax();
    for (    char quote : valueQuotes)     st.quoteChar(quote);
    int start=0;
    int end=0;
    while (st.nextToken() != StreamTokenizer.TT_EOF) {
      if (end < (r.getCurrentPosition() - 1) || r.getCurrentPosition() >= (sql.length())) {
        String str=sql.substring(start,end + 1);
        str=transformCase(str);
        s.replace(start,end + 1,str);
        start=r.getCurrentPosition();
      }
      end=r.getCurrentPosition();
    }
  }
 catch (  IOException e) {
    logger.warn("Unexpected exception while transforming SQL statement case: " + e);
  }
  return s.toString();
}

private String transformSQLCase ( String sql ) { StringBuilder s = new StringBuilder ( sql ) ; try { PositionedStringReader r = new PositionedStringReader ( sql ) ; StreamTokenizer st = new StreamTokenizer ( r ) ; st . resetSyntax ( ) ; for ( char quote : valueQuotes ) st . quoteChar ( quote ) ; int start = 0 ; int end = 0 ; while ( st . nextToken ( ) != StreamTokenizer . TT_EOF ) { if ( end < ( r . getCurrentPosition ( ) - 1 ) || r . getCurrentPosition ( ) >= ( sql . length ( ) ) ) { String str = sql . substring ( start , end + 1 ) ; str = transformCase ( str ) ; s . replace ( start , end + 1 , str ) ; start = r . getCurrentPosition ( ) ; } end = r . getCurrentPosition ( ) ; } } catch ( IOException e ) { logger . warn ( "Unexpected exception while transforming SQL statement case: " + e ) ; } return s . toString ( ) ; }
transforms case of a whole sql statement except values in quotes .
