POResource extends POTResource { @Override public LanguageBundle parse(InputStream inStream, FilterOptions options) throws IOException, ResourceFilterException { LanguageBundleBuilder bb = new LanguageBundleBuilder(true); BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, CHAR_SET)); String singularKey = null; String pluralKey = null; boolean singularValueSet = false; String line; while ((line = reader.readLine()) != null) { if (line.isEmpty()) { singularKey = null; pluralKey = null; singularValueSet = false; continue; } String value = extractMessage(line, reader); if (value == null || value.isEmpty()) { continue; } if (line.startsWith(UNTRANSLATED_STRING_PREFIX)) { singularKey = value; } else if (singularKey != null && pluralKey == null && line.startsWith(UNTRANSLATED_PLURAL_STRING_PREFIX)) { pluralKey = value; } else if (singularKey != null && pluralKey == null && line.startsWith(TRANSLATED_STRING_PREFIX) && !line.startsWith(TRANSLATED_PLURAL_0_STRING_PREFIX)) { bb.addResourceString(singularKey, value); } else if (singularKey != null && pluralKey != null && line.startsWith(TRANSLATED_PLURAL_0_STRING_PREFIX)) { bb.addResourceString(singularKey, value); singularValueSet = true; } else if (singularKey != null && pluralKey != null && singularValueSet && line.startsWith(TRANSLATED_PLURAL_1_STRING_PREFIX)) { bb.addResourceString(pluralKey, value); } } return bb.build(); }  @Override LanguageBundle parse(InputStream inStream, FilterOptions options); @Override void write(OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options);  }
@Test public void testParse() throws IOException, ResourceFilterException { assertTrue("The input test file <" + INPUT_FILE + "> does not exist.", INPUT_FILE.exists()); try (InputStream is = new FileInputStream(INPUT_FILE)) { 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); } }