private static void append ( final StringBuilder builder , final String identifier , final String quote ) throws SQLException { if ( identifier . indexOf ( ' ' ) >= 0 || identifier . indexOf ( ' ' ) >= 0 ) { throw new SQLException ( "Identifier contains line breaks: " + identifier ) ; } else if ( " " . equals ( quote ) ) { for ( int i = 0 ; i < identifier . length ( ) ; ++ i ) { char c = identifier . charAt ( i ) ; if ( ! Character . isLetterOrDigit ( c ) && c != ' ' && c != ' ' && c != ' ' && c != ' ' ) { throw new SQLException ( "Illegal identifier: " + identifier ) ; } } builder . append ( identifier ) ; } else { builder . append ( quote ) . append ( identifier . replace ( quote , quote + quote ) ) . append ( quote ) ; } }
Appends a database identifier securely to a builder that is building a SQL statement .