public static String filterEncode ( String value ) { if ( value == null ) return null ; // make buffer roomy StringBuilder encodedValue = new StringBuilder ( value . length ( ) * 2 ) ; int length = value . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char c = value . charAt ( i ) ; if ( c < FILTER_ESCAPE_TABLE . length ) { encodedValue . append ( FILTER_ESCAPE_TABLE [ c ] ) ; } else { // default: add the char encodedValue . append ( c ) ; } } return encodedValue . toString ( ) ; }
Escape a value for use in a filter .