code: public static Map<MediaType, QualityValue> getMediaTypeQualityValues(String header)
     {
        if (header == null)
           return null;
        header = header.trim();
        if (header.length() == 0)
           return null;
        Map<MediaType, QualityValue> result = new LinkedHashMap<MediaType, QualityValue>();
  
        int offset = 0;
        while (offset >= 0)
        {
           int slashIndex = header.indexOf('/', offset);
           if (slashIndex < 0)
              throw new IllegalArgumentException("Malformed media type: " + header);
           String type = header.substring(offset, slashIndex);
           String subtype;
           Map<String, String> parameters = null;
           QualityValue qualityValue = QualityValue.DEFAULT;
  
           offset = slashIndex + 1;
           int parameterStartIndex = header.indexOf(';', offset);
           int itemEndIndex = header.indexOf(',', offset);
           if (parameterStartIndex == itemEndIndex)
           {
              assert itemEndIndex == -1;
              subtype = header.substring(offset);
              offset = -1;
           }
           else if (itemEndIndex < 0 || (parameterStartIndex >= 0 && parameterStartIndex < itemEndIndex))
           {
              subtype = header.substring(offset, parameterStartIndex);
              offset = parameterStartIndex + 1;
              parameters = new LinkedHashMap<String, String>();
              offset = parseParameters(parameters, header, offset);
              qualityValue = evaluateAcceptParameters(parameters);
           }
           else
           {
              subtype = header.substring(offset, itemEndIndex);
              offset = itemEndIndex + 1;
           }
           result.put(new MediaType(type.trim(), subtype.trim(), parameters), qualityValue);
        }
  
        if (logger.isDebugEnabled())
           logger.debug(result.toString());
        return result;
     }
docs: Gets the media types from a comma-separated list.
  
  @param header the header value.
  @return the listed items in order of appearance or {@code null} if the header didn't contain any entries.