@Test(expected = IllegalArgumentException.class) public void throwExceptionWhenAcceptTokenHeaderContainsInvalidCharacters() { AcceptToken.valueOf("utf[8"); }
public static AcceptToken valueOf(String value) { if (value == null) { throw new IllegalArgumentException(); } try { int separator = scan(value, PARAMETERS_SEPARATOR); boolean hasParameters = charAtIs(value, separator, PARAMETERS_SEPARATOR); String token = hasParameters ? value.substring(0, separator).trim() : value.trim(); token = token.trim(); int i; if ((i = isToken(token)) != -1) { throw new IllegalArgumentException(String.format("Not valid character at index %d in %s", i, token)); } if (hasParameters) { Map<String, String> param = new HeaderParameterParser().parse(value); if (param.containsKey(QVALUE)) { return new AcceptToken(token, parseQualityValue(param.get(QVALUE))); } } return new AcceptToken(token); } catch (ParseException e) { throw new IllegalArgumentException(e); } }
AcceptToken implements QualityValue { public static AcceptToken valueOf(String value) { if (value == null) { throw new IllegalArgumentException(); } try { int separator = scan(value, PARAMETERS_SEPARATOR); boolean hasParameters = charAtIs(value, separator, PARAMETERS_SEPARATOR); String token = hasParameters ? value.substring(0, separator).trim() : value.trim(); token = token.trim(); int i; if ((i = isToken(token)) != -1) { throw new IllegalArgumentException(String.format("Not valid character at index %d in %s", i, token)); } if (hasParameters) { Map<String, String> param = new HeaderParameterParser().parse(value); if (param.containsKey(QVALUE)) { return new AcceptToken(token, parseQualityValue(param.get(QVALUE))); } } return new AcceptToken(token); } catch (ParseException e) { throw new IllegalArgumentException(e); } } }
AcceptToken implements QualityValue { public static AcceptToken valueOf(String value) { if (value == null) { throw new IllegalArgumentException(); } try { int separator = scan(value, PARAMETERS_SEPARATOR); boolean hasParameters = charAtIs(value, separator, PARAMETERS_SEPARATOR); String token = hasParameters ? value.substring(0, separator).trim() : value.trim(); token = token.trim(); int i; if ((i = isToken(token)) != -1) { throw new IllegalArgumentException(String.format("Not valid character at index %d in %s", i, token)); } if (hasParameters) { Map<String, String> param = new HeaderParameterParser().parse(value); if (param.containsKey(QVALUE)) { return new AcceptToken(token, parseQualityValue(param.get(QVALUE))); } } return new AcceptToken(token); } catch (ParseException e) { throw new IllegalArgumentException(e); } } AcceptToken(String token);  AcceptToken(String token, float qValue); }
AcceptToken implements QualityValue { public static AcceptToken valueOf(String value) { if (value == null) { throw new IllegalArgumentException(); } try { int separator = scan(value, PARAMETERS_SEPARATOR); boolean hasParameters = charAtIs(value, separator, PARAMETERS_SEPARATOR); String token = hasParameters ? value.substring(0, separator).trim() : value.trim(); token = token.trim(); int i; if ((i = isToken(token)) != -1) { throw new IllegalArgumentException(String.format("Not valid character at index %d in %s", i, token)); } if (hasParameters) { Map<String, String> param = new HeaderParameterParser().parse(value); if (param.containsKey(QVALUE)) { return new AcceptToken(token, parseQualityValue(param.get(QVALUE))); } } return new AcceptToken(token); } catch (ParseException e) { throw new IllegalArgumentException(e); } } AcceptToken(String token);  AcceptToken(String token, float qValue); static AcceptToken valueOf(String value); Token getToken(); @Override float getQvalue(); boolean isCompatible(AcceptToken other); boolean isCompatible(Token other); boolean isCompatible(String other); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
AcceptToken implements QualityValue { public static AcceptToken valueOf(String value) { if (value == null) { throw new IllegalArgumentException(); } try { int separator = scan(value, PARAMETERS_SEPARATOR); boolean hasParameters = charAtIs(value, separator, PARAMETERS_SEPARATOR); String token = hasParameters ? value.substring(0, separator).trim() : value.trim(); token = token.trim(); int i; if ((i = isToken(token)) != -1) { throw new IllegalArgumentException(String.format("Not valid character at index %d in %s", i, token)); } if (hasParameters) { Map<String, String> param = new HeaderParameterParser().parse(value); if (param.containsKey(QVALUE)) { return new AcceptToken(token, parseQualityValue(param.get(QVALUE))); } } return new AcceptToken(token); } catch (ParseException e) { throw new IllegalArgumentException(e); } } AcceptToken(String token);  AcceptToken(String token, float qValue); static AcceptToken valueOf(String value); Token getToken(); @Override float getQvalue(); boolean isCompatible(AcceptToken other); boolean isCompatible(Token other); boolean isCompatible(String other); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }