static void processSingleQuotedString ( StringBuilder sb ) { // Sanity checking. Make sure input string has at least two characters // and that the first and last are single quotes. assert ( sb . length ( ) >= 2 ) ; assert ( sb . charAt ( 0 ) == ' ' && sb . charAt ( sb . length ( ) - 1 ) == ' ' ) ; // Remove the starting and ending quotes. sb . deleteCharAt ( sb . length ( ) - 1 ) ; sb . deleteCharAt ( 0 ) ; // Loop through the string and replace any doubled apostrophes with // a single apostrophe. (Really just delete the second apostrophe.) int i = sb . indexOf ( "''" , 0 ) + 1 ; while ( i > 0 ) { sb . deleteCharAt ( i ) ; i = sb . indexOf ( "''" , i ) + 1 ; } }
This takes a single - quoted string as identified by the parser and processes it into a standard java string . It removes the surrounding quotes and substitues a single apostrophe or doubled apostrophes .