class HeaderParameterParser {

    public Map<String, String> parse(String header) throws ParseException {
        init(header);

        Map<String, String> parameters = new HashMap<>();

        pos++; // skip first ';'
        while (hasRemainingChars()) {
            String name = readToken(NAME_TERMINATORS);
            String value = null;
            if (charAtIs(source, pos, '=')) {
                pos++; // skip '='
                if (charAtIs(source, pos, '"')) {
                    value = readQuotedString();
                } else if (hasRemainingChars()) {
                    value = readToken(VALUE_TERMINATORS);
                }
            }

            if (charAtIs(source, pos, PARAMS_SEPARATOR)) {
                pos++; // skip ';'
            }

            if (!isNullOrEmpty(name)) {
                parameters.put(name, value);
            }

        }
        return parameters;
    }

}