public static String prepareValue ( Object val ) { StringBuilder result = new StringBuilder ( ) ; boolean numberOrBooleanOrNull ; if ( val != null && ! ( val instanceof Number ) && ! ( val instanceof Boolean ) ) { numberOrBooleanOrNull = false ; result . append ( "'" ) ; } else { numberOrBooleanOrNull = true ; } if ( val instanceof Boolean ) { Boolean boolVal = ( Boolean ) val ; if ( boolVal . equals ( Boolean . TRUE ) ) { result . append ( 1 ) ; } else { result . append ( 0 ) ; } } else { result . append ( val ) ; } if ( ! numberOrBooleanOrNull ) { result . append ( "'" ) ; } return result . toString ( ) ; }
Generates an SQL - ready string for the given value based on its type .