public String marshall ( ) { if ( 0 == this . num_items ) { return "" ; } boolean shouldPrepend = false ; StringBuilder output = new StringBuilder ( 10 * this . num_items ) ; // walk through the list of simple values (no key=value) first Iterator < String > i = this . genericValues . iterator ( ) ; while ( i . hasNext ( ) ) { if ( shouldPrepend ) { output . append ( this . mySep ) ; output . append ( ' ' ) ; } output . append ( i . next ( ) ) ; shouldPrepend = true ; } // now walk through the list of key=value pairs, where value may actually // be multiple values i = this . values . keySet ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { String key = i . next ( ) ; List < String > vals = this . values . get ( key ) ; if ( null == vals ) continue ; int size = vals . size ( ) ; if ( 0 == size ) { // ignore an empty key continue ; } if ( shouldPrepend ) { output . append ( this . mySep ) ; output . append ( ' ' ) ; } output . append ( key ) ; output . append ( ' ' ) ; if ( 1 == size ) { output . append ( vals . get ( 0 ) ) ; } else { // multiple values need to be quote wrapped shouldPrepend = false ; output . append ( ' ' ) ; for ( int count = 0 ; count < size ; count ++ ) { if ( shouldPrepend ) { output . append ( this . mySep ) ; output . append ( ' ' ) ; } output . append ( vals . get ( count ) ) ; shouldPrepend = true ; } output . append ( ' ' ) ; } shouldPrepend = true ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "marshalling [" + output . toString ( ) + "]" ) ; } return output . toString ( ) ; }
Take the current data in this handler and create the properly formatted string that would represent the header .