@Test public void testSkipMalformedEntries() throws Exception { lm = LocaleMap.load(new StringReader("abc\nfoo=\n=bar")); assertEquals(0, lm.map.size()); }
public static LocaleMap load(Reader reader) throws IOException { BufferedReader r = new BufferedReader(reader); LocaleMap lm = new LocaleMap(); for (String line = r.readLine(); line != null; line = r.readLine()) { String[] parts = line.replace('_', '-').split("="); for (int i = 0; i < parts.length; i++) { parts[i] = parts[i].trim(); } if (parts.length != 2 || "".equals(parts[0]) || "".equals(parts[1])) { log.warn("Skipping malformed locale mapping: '{}'", line); continue; } try { lm.add(LocaleId.fromBCP47(parts[0], true), LocaleId.fromBCP47(parts[1], true)); } catch (IllegalArgumentException e) { log.warn("Skipping locale mapping '{}'. Reason: {}", line, e.getMessage()); } } return lm; }
LocaleMap { public static LocaleMap load(Reader reader) throws IOException { BufferedReader r = new BufferedReader(reader); LocaleMap lm = new LocaleMap(); for (String line = r.readLine(); line != null; line = r.readLine()) { String[] parts = line.replace('_', '-').split("="); for (int i = 0; i < parts.length; i++) { parts[i] = parts[i].trim(); } if (parts.length != 2 || "".equals(parts[0]) || "".equals(parts[1])) { log.warn("Skipping malformed locale mapping: '{}'", line); continue; } try { lm.add(LocaleId.fromBCP47(parts[0], true), LocaleId.fromBCP47(parts[1], true)); } catch (IllegalArgumentException e) { log.warn("Skipping locale mapping '{}'. Reason: {}", line, e.getMessage()); } } return lm; } }
LocaleMap { public static LocaleMap load(Reader reader) throws IOException { BufferedReader r = new BufferedReader(reader); LocaleMap lm = new LocaleMap(); for (String line = r.readLine(); line != null; line = r.readLine()) { String[] parts = line.replace('_', '-').split("="); for (int i = 0; i < parts.length; i++) { parts[i] = parts[i].trim(); } if (parts.length != 2 || "".equals(parts[0]) || "".equals(parts[1])) { log.warn("Skipping malformed locale mapping: '{}'", line); continue; } try { lm.add(LocaleId.fromBCP47(parts[0], true), LocaleId.fromBCP47(parts[1], true)); } catch (IllegalArgumentException e) { log.warn("Skipping locale mapping '{}'. Reason: {}", line, e.getMessage()); } } return lm; }  }
LocaleMap { public static LocaleMap load(Reader reader) throws IOException { BufferedReader r = new BufferedReader(reader); LocaleMap lm = new LocaleMap(); for (String line = r.readLine(); line != null; line = r.readLine()) { String[] parts = line.replace('_', '-').split("="); for (int i = 0; i < parts.length; i++) { parts[i] = parts[i].trim(); } if (parts.length != 2 || "".equals(parts[0]) || "".equals(parts[1])) { log.warn("Skipping malformed locale mapping: '{}'", line); continue; } try { lm.add(LocaleId.fromBCP47(parts[0], true), LocaleId.fromBCP47(parts[1], true)); } catch (IllegalArgumentException e) { log.warn("Skipping locale mapping '{}'. Reason: {}", line, e.getMessage()); } } return lm; }  void add(LocaleId originalLocale, LocaleId mappedLocale); LocaleId getMappedLocale(LocaleId locale); static LocaleMap load(Reader reader); }
LocaleMap { public static LocaleMap load(Reader reader) throws IOException { BufferedReader r = new BufferedReader(reader); LocaleMap lm = new LocaleMap(); for (String line = r.readLine(); line != null; line = r.readLine()) { String[] parts = line.replace('_', '-').split("="); for (int i = 0; i < parts.length; i++) { parts[i] = parts[i].trim(); } if (parts.length != 2 || "".equals(parts[0]) || "".equals(parts[1])) { log.warn("Skipping malformed locale mapping: '{}'", line); continue; } try { lm.add(LocaleId.fromBCP47(parts[0], true), LocaleId.fromBCP47(parts[1], true)); } catch (IllegalArgumentException e) { log.warn("Skipping locale mapping '{}'. Reason: {}", line, e.getMessage()); } } return lm; }  void add(LocaleId originalLocale, LocaleId mappedLocale); LocaleId getMappedLocale(LocaleId locale); static LocaleMap load(Reader reader);  }