@Test public void testFromStringEmpty() { AcceptCharset charset = acceptCharsetDelegate.fromString(""); assertFalse(charset.isAnyCharsetAllowed()); assertEquals(Collections.singletonList("ISO-8859-1"), charset.getAcceptableCharsets()); assertEquals(Collections.EMPTY_LIST, charset.getBannedCharsets()); }
public AcceptCharset fromString(String value) throws IllegalArgumentException { AcceptCharset cached = cache.get(value); if (cached != null) { return cached; } List<String> acceptable = new LinkedList<String>(); List<String> banned = new LinkedList<String>(); boolean anyAllowed = (value == null); List<AcceptCharset.ValuedCharset> vCharsets = parseAcceptCharset(value); for (AcceptCharset.ValuedCharset qCharset : vCharsets) { if (anyAllowed) { if (qCharset.qValue == 0 && !qCharset.isWildcard()) { banned.add(qCharset.charset); } } else { if (qCharset.qValue == 0) { break; } if (qCharset.isWildcard()) { anyAllowed = true; } else { acceptable.add(qCharset.charset); } } } return cache .put(value, new AcceptCharset(value, acceptable, banned, anyAllowed, vCharsets)); }
AcceptCharsetHeaderDelegate implements HeaderDelegate<AcceptCharset> { public AcceptCharset fromString(String value) throws IllegalArgumentException { AcceptCharset cached = cache.get(value); if (cached != null) { return cached; } List<String> acceptable = new LinkedList<String>(); List<String> banned = new LinkedList<String>(); boolean anyAllowed = (value == null); List<AcceptCharset.ValuedCharset> vCharsets = parseAcceptCharset(value); for (AcceptCharset.ValuedCharset qCharset : vCharsets) { if (anyAllowed) { if (qCharset.qValue == 0 && !qCharset.isWildcard()) { banned.add(qCharset.charset); } } else { if (qCharset.qValue == 0) { break; } if (qCharset.isWildcard()) { anyAllowed = true; } else { acceptable.add(qCharset.charset); } } } return cache .put(value, new AcceptCharset(value, acceptable, banned, anyAllowed, vCharsets)); } }
AcceptCharsetHeaderDelegate implements HeaderDelegate<AcceptCharset> { public AcceptCharset fromString(String value) throws IllegalArgumentException { AcceptCharset cached = cache.get(value); if (cached != null) { return cached; } List<String> acceptable = new LinkedList<String>(); List<String> banned = new LinkedList<String>(); boolean anyAllowed = (value == null); List<AcceptCharset.ValuedCharset> vCharsets = parseAcceptCharset(value); for (AcceptCharset.ValuedCharset qCharset : vCharsets) { if (anyAllowed) { if (qCharset.qValue == 0 && !qCharset.isWildcard()) { banned.add(qCharset.charset); } } else { if (qCharset.qValue == 0) { break; } if (qCharset.isWildcard()) { anyAllowed = true; } else { acceptable.add(qCharset.charset); } } } return cache .put(value, new AcceptCharset(value, acceptable, banned, anyAllowed, vCharsets)); }  }
AcceptCharsetHeaderDelegate implements HeaderDelegate<AcceptCharset> { public AcceptCharset fromString(String value) throws IllegalArgumentException { AcceptCharset cached = cache.get(value); if (cached != null) { return cached; } List<String> acceptable = new LinkedList<String>(); List<String> banned = new LinkedList<String>(); boolean anyAllowed = (value == null); List<AcceptCharset.ValuedCharset> vCharsets = parseAcceptCharset(value); for (AcceptCharset.ValuedCharset qCharset : vCharsets) { if (anyAllowed) { if (qCharset.qValue == 0 && !qCharset.isWildcard()) { banned.add(qCharset.charset); } } else { if (qCharset.qValue == 0) { break; } if (qCharset.isWildcard()) { anyAllowed = true; } else { acceptable.add(qCharset.charset); } } } return cache .put(value, new AcceptCharset(value, acceptable, banned, anyAllowed, vCharsets)); }  AcceptCharset fromString(String value); String toString(AcceptCharset value); }
AcceptCharsetHeaderDelegate implements HeaderDelegate<AcceptCharset> { public AcceptCharset fromString(String value) throws IllegalArgumentException { AcceptCharset cached = cache.get(value); if (cached != null) { return cached; } List<String> acceptable = new LinkedList<String>(); List<String> banned = new LinkedList<String>(); boolean anyAllowed = (value == null); List<AcceptCharset.ValuedCharset> vCharsets = parseAcceptCharset(value); for (AcceptCharset.ValuedCharset qCharset : vCharsets) { if (anyAllowed) { if (qCharset.qValue == 0 && !qCharset.isWildcard()) { banned.add(qCharset.charset); } } else { if (qCharset.qValue == 0) { break; } if (qCharset.isWildcard()) { anyAllowed = true; } else { acceptable.add(qCharset.charset); } } } return cache .put(value, new AcceptCharset(value, acceptable, banned, anyAllowed, vCharsets)); }  AcceptCharset fromString(String value); String toString(AcceptCharset value);  }