@Test public void testNull() { final List<Locale> list = LocaleUtils.parseAcceptLanguage(null); assertTrue(list.isEmpty()); }
public static List<Locale> parseAcceptLanguage(final String header) { if (header == null || header.isEmpty()) { return Collections.emptyList(); } final List<Locale> result = new ArrayList<>(); for (final String str : header.split(",")) { final String[] arr = str.trim().replace("-", "_").split(";"); final Locale locale; final String[] l = arr[0].split("_"); switch (l.length) { case 2: locale = new Locale(l[0], l[1]); break; case 3: locale = new Locale(l[0], l[1], l[2]); break; default: locale = new Locale(l[0]); break; } result.add(locale); } return result; }
LocaleUtils { public static List<Locale> parseAcceptLanguage(final String header) { if (header == null || header.isEmpty()) { return Collections.emptyList(); } final List<Locale> result = new ArrayList<>(); for (final String str : header.split(",")) { final String[] arr = str.trim().replace("-", "_").split(";"); final Locale locale; final String[] l = arr[0].split("_"); switch (l.length) { case 2: locale = new Locale(l[0], l[1]); break; case 3: locale = new Locale(l[0], l[1], l[2]); break; default: locale = new Locale(l[0]); break; } result.add(locale); } return result; } }
LocaleUtils { public static List<Locale> parseAcceptLanguage(final String header) { if (header == null || header.isEmpty()) { return Collections.emptyList(); } final List<Locale> result = new ArrayList<>(); for (final String str : header.split(",")) { final String[] arr = str.trim().replace("-", "_").split(";"); final Locale locale; final String[] l = arr[0].split("_"); switch (l.length) { case 2: locale = new Locale(l[0], l[1]); break; case 3: locale = new Locale(l[0], l[1], l[2]); break; default: locale = new Locale(l[0]); break; } result.add(locale); } return result; } LocaleUtils(); }
LocaleUtils { public static List<Locale> parseAcceptLanguage(final String header) { if (header == null || header.isEmpty()) { return Collections.emptyList(); } final List<Locale> result = new ArrayList<>(); for (final String str : header.split(",")) { final String[] arr = str.trim().replace("-", "_").split(";"); final Locale locale; final String[] l = arr[0].split("_"); switch (l.length) { case 2: locale = new Locale(l[0], l[1]); break; case 3: locale = new Locale(l[0], l[1], l[2]); break; default: locale = new Locale(l[0]); break; } result.add(locale); } return result; } LocaleUtils(); static List<Locale> parseAcceptLanguage(final String header); }
LocaleUtils { public static List<Locale> parseAcceptLanguage(final String header) { if (header == null || header.isEmpty()) { return Collections.emptyList(); } final List<Locale> result = new ArrayList<>(); for (final String str : header.split(",")) { final String[] arr = str.trim().replace("-", "_").split(";"); final Locale locale; final String[] l = arr[0].split("_"); switch (l.length) { case 2: locale = new Locale(l[0], l[1]); break; case 3: locale = new Locale(l[0], l[1], l[2]); break; default: locale = new Locale(l[0]); break; } result.add(locale); } return result; } LocaleUtils(); static List<Locale> parseAcceptLanguage(final String header);  }