public static String toExtensionHeader ( final List < WebSocketExtension > extensions ) { StringBuilder extensionsHeader = new StringBuilder ( ) ; if ( extensions != null && extensions . size ( ) > 0 ) { Iterator < WebSocketExtension > it = extensions . iterator ( ) ; while ( it . hasNext ( ) ) { WebSocketExtension extension = it . next ( ) ; extensionsHeader . append ( extension . getName ( ) ) ; for ( Parameter param : extension . getParameters ( ) ) { extensionsHeader . append ( "; " ) . append ( param . getName ( ) ) ; if ( param . getValue ( ) != null && param . getValue ( ) . length ( ) > 0 ) { extensionsHeader . append ( "=" ) . append ( param . getValue ( ) ) ; } } if ( it . hasNext ( ) ) { extensionsHeader . append ( ", " ) ; } } } return extensionsHeader . toString ( ) ; }
Compose a String from a list of extensions to be used in the response of a protocol negotiation .