private static void addHeader(Message message,String name,String value){
  Map<String,List<String>> protocolHeaders=CastUtils.cast((Map<?,?>)message.get(Message.PROTOCOL_HEADERS));
  if (protocolHeaders == null) {
    protocolHeaders=new TreeMap<String,List<String>>(String.CASE_INSENSITIVE_ORDER);
    message.put(Message.PROTOCOL_HEADERS,protocolHeaders);
  }
  List<String> header=CastUtils.cast((List<?>)protocolHeaders.get(name));
  if (header == null) {
    header=new ArrayList<String>();
    protocolHeaders.put(name,header);
  }
  if (header.size() == 0) {
    header.add(value);
  }
 else {
    header.set(0,header.get(0) + "," + value);
  }
}

private static void addHeader ( Message message , String name , String value ) { Map < String , List < String > > protocolHeaders = CastUtils . cast ( ( Map < ? , ? > ) message . get ( Message . PROTOCOL_HEADERS ) ) ; if ( protocolHeaders == null ) { protocolHeaders = new TreeMap < String , List < String > > ( String . CASE_INSENSITIVE_ORDER ) ; message . put ( Message . PROTOCOL_HEADERS , protocolHeaders ) ; } List < String > header = CastUtils . cast ( ( List < ? > ) protocolHeaders . get ( name ) ) ; if ( header == null ) { header = new ArrayList < String > ( ) ; protocolHeaders . put ( name , header ) ; } if ( header . size ( ) == 0 ) { header . add ( value ) ; } else { header . set ( 0 , header . get ( 0 ) + "," + value ) ; } }
adds a value to a header . if the given header name is not currently set in the message , an entry is created with the given single value . if the header is already set , the value is appended to the first element of the list , following a comma .
