IOSStringsResource extends ResourceFilter { @Override public LanguageBundle parse(InputStream inStream, FilterOptions options) throws IOException, ResourceFilterException { BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, CHAR_SET)); LanguageBundleBuilder bb = new LanguageBundleBuilder(true); String line; List<String> notes = new ArrayList<>(); Boolean commentIsGlobal = true; while ((line = reader.readLine()) != null) { if (line.trim().startsWith(COMMENT_BEGIN)) { String comment = line.substring(line.indexOf(COMMENT_BEGIN)+2); Boolean commentEndProcessed = false; while (!commentEndProcessed && line != null) { if (comment.trim().endsWith(COMMENT_END)) { comment = comment.substring(0, comment.lastIndexOf(COMMENT_END)); commentEndProcessed = true; } notes.add(comment); if (!commentEndProcessed) { line = reader.readLine(); comment = line; } } } else if (commentIsGlobal && line.isEmpty()) { commentIsGlobal = false; if (!notes.isEmpty()) { bb.addNotes(notes); notes.clear(); } } else if (line.matches("^\\s*\".*")) { StringBuilder entry = new StringBuilder(128); do { entry.append(line.trim()).append(' '); } while (!line.matches(".*[^\\\\];\\s*$") && (line = reader.readLine()) != null); String[] parts = entry.toString().split("\"\\s*=\\s*\""); String key = parts[0].substring(parts[0].indexOf('"') + 1).trim(); String value = parts[1].substring(0, parts[1].lastIndexOf('"')).trim(); if (notes.isEmpty()) { bb.addResourceString(key, value); } else { bb.addResourceString(ResourceString.with(key, value).notes(notes)); notes.clear(); } } } return bb.build(); }  @Override LanguageBundle parse(InputStream inStream, FilterOptions options); @Override void write(OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options); @Override void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options);  }
@Test public void testParse() throws IOException, ResourceFilterException { assertTrue("The input test file <" + INPUT + "> does not exist.", INPUT.exists()); try (InputStream is = new FileInputStream(INPUT)) { LanguageBundle bundle = res.parse(is, null); List<ResourceString> resStrList = new ArrayList<>(bundle.getResourceStrings()); Collections.sort(resStrList, new ResourceStringComparator()); assertEquals("ResourceStrings did not match.", EXPECTED_INPUT_RES_LIST, resStrList); List<String> globalNotes = bundle.getNotes(); assertEquals("Global comments did not match.", EXPECTED_GLOBAL_NOTES, globalNotes); } }