@UseDataProvider("forParses") @Test public void parses(String header, Map<String, String> expectedParsedParameters) throws Exception { assertEquals(expectedParsedParameters, headerParameterParser.parse(header)); }
public Map<String, String> parse(String header) throws ParseException { init(header); Map<String, String> parameters = new HashMap<>(); pos++; while (hasRemainingChars()) { String name = readToken(NAME_TERMINATORS); String value = null; if (charAtIs(source, pos, '=')) { pos++; if (charAtIs(source, pos, '"')) { value = readQuotedString(); } else if (hasRemainingChars()) { value = readToken(VALUE_TERMINATORS); } } if (charAtIs(source, pos, PARAMS_SEPARATOR)) { pos++; } if (!isNullOrEmpty(name)) { parameters.put(name, value); } } return parameters; }
HeaderParameterParser { public Map<String, String> parse(String header) throws ParseException { init(header); Map<String, String> parameters = new HashMap<>(); pos++; while (hasRemainingChars()) { String name = readToken(NAME_TERMINATORS); String value = null; if (charAtIs(source, pos, '=')) { pos++; if (charAtIs(source, pos, '"')) { value = readQuotedString(); } else if (hasRemainingChars()) { value = readToken(VALUE_TERMINATORS); } } if (charAtIs(source, pos, PARAMS_SEPARATOR)) { pos++; } if (!isNullOrEmpty(name)) { parameters.put(name, value); } } return parameters; } }
HeaderParameterParser { public Map<String, String> parse(String header) throws ParseException { init(header); Map<String, String> parameters = new HashMap<>(); pos++; while (hasRemainingChars()) { String name = readToken(NAME_TERMINATORS); String value = null; if (charAtIs(source, pos, '=')) { pos++; if (charAtIs(source, pos, '"')) { value = readQuotedString(); } else if (hasRemainingChars()) { value = readToken(VALUE_TERMINATORS); } } if (charAtIs(source, pos, PARAMS_SEPARATOR)) { pos++; } if (!isNullOrEmpty(name)) { parameters.put(name, value); } } return parameters; }  }
HeaderParameterParser { public Map<String, String> parse(String header) throws ParseException { init(header); Map<String, String> parameters = new HashMap<>(); pos++; while (hasRemainingChars()) { String name = readToken(NAME_TERMINATORS); String value = null; if (charAtIs(source, pos, '=')) { pos++; if (charAtIs(source, pos, '"')) { value = readQuotedString(); } else if (hasRemainingChars()) { value = readToken(VALUE_TERMINATORS); } } if (charAtIs(source, pos, PARAMS_SEPARATOR)) { pos++; } if (!isNullOrEmpty(name)) { parameters.put(name, value); } } return parameters; }  Map<String, String> parse(String header); }
HeaderParameterParser { public Map<String, String> parse(String header) throws ParseException { init(header); Map<String, String> parameters = new HashMap<>(); pos++; while (hasRemainingChars()) { String name = readToken(NAME_TERMINATORS); String value = null; if (charAtIs(source, pos, '=')) { pos++; if (charAtIs(source, pos, '"')) { value = readQuotedString(); } else if (hasRemainingChars()) { value = readToken(VALUE_TERMINATORS); } } if (charAtIs(source, pos, PARAMS_SEPARATOR)) { pos++; } if (!isNullOrEmpty(name)) { parameters.put(name, value); } } return parameters; }  Map<String, String> parse(String header);  }