question: public static void formatValue ( final StringBuffer buffer , final String value , final boolean alwaysUseQuotes ) { if ( buffer == null ) { throw new IllegalArgumentException ( "String buffer may not be null" ) ; } if ( value == null ) { throw new IllegalArgumentException ( "Value buffer may not be null" ) ; } if ( alwaysUseQuotes ) { buffer . append ( '"' ) ; for ( int i = 0 ; i < value . length ( ) ; i ++ ) { final char ch = value . charAt ( i ) ; if ( isUnsafeChar ( ch ) ) { buffer . append ( '\\' ) ; } buffer . append ( ch ) ; } buffer . append ( '"' ) ; } else { final int offset = buffer . length ( ) ; boolean unsafe = false ; for ( int i = 0 ; i < value . length ( ) ; i ++ ) { final char ch = value . charAt ( i ) ; if ( isSeparator ( ch ) ) { unsafe = true ; } if ( isUnsafeChar ( ch ) ) { buffer . append ( '\\' ) ; } buffer . append ( ch ) ; } if ( unsafe ) { buffer . insert ( offset , '"' ) ; buffer . append ( '"' ) ; } } }
target:  Formats the given parameter value using formatting rules defined in RFC 2616