public static void maybeQuote ( StringBuilder buf , String value ) { if ( value == null || value . length ( ) == 0 ) { buf . append ( "\"\"" ) ; } else if ( alreadyQuoted ( value ) ) { buf . append ( ' ' ) ; buf . append ( escapeDoubleQuotes ( value , 1 , value . length ( ) - 1 ) ) ; buf . append ( ' ' ) ; } else if ( ( isHttpToken ( value ) && ! ALLOW_HTTP_SEPARATORS_IN_V0 ) || ( isV0Token ( value ) && ALLOW_HTTP_SEPARATORS_IN_V0 ) ) { buf . append ( ' ' ) ; buf . append ( escapeDoubleQuotes ( value , 0 , value . length ( ) ) ) ; buf . append ( ' ' ) ; } else { buf . append ( value ) ; } }
Quotes values if required .