String[] pairs = headerValue.split( ",(?=[^,]+=)" ); // comma with key as look-ahead (not part of match)
for ( String pair : pairs ) {
String[] components = pair.split( "=", 2 );
String name = URLDecoder.decode( components[0].trim(), "UTF-8" );
String value = components.length > 1 ? URLDecoder.decode( components[1], "UTF-8" ) : null;
Metadata metadata = new Metadata( name, value, listable );
metadataMap.put( name, metadata );
}
return metadataMap;
} catch ( UnsupportedEncodingException e ) {
throw new RuntimeException( "UTF-8 encoding isn't supported on this system", e );