test_class.declarator: INPUT_FILE = new File("src/test/resource/resfilter/po/input.po")
test_class.modifier: private static final
test_class.original_string: private static final File INPUT_FILE = new File("src/test/resource/resfilter/po/input.po");
test_class.type: File
test_class.var_name: INPUT_FILE
test_class.declarator: EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/po/write-output.po")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/po/write-output.po");
test_class.type: File
test_class.var_name: EXPECTED_WRITE_FILE
test_class.declarator: MERGE_INPUT_1_FILE = new File("src/test/resource/resfilter/pot/merge-input-1.pot")
test_class.modifier: private static final
test_class.original_string: private static final File MERGE_INPUT_1_FILE = new File("src/test/resource/resfilter/pot/merge-input-1.pot");
test_class.type: File
test_class.var_name: MERGE_INPUT_1_FILE
test_class.declarator: MERGE_INPUT_2_FILE = new File("src/test/resource/resfilter/pot/merge-input-2.pot")
test_class.modifier: private static final
test_class.original_string: private static final File MERGE_INPUT_2_FILE = new File("src/test/resource/resfilter/pot/merge-input-2.pot");
test_class.type: File
test_class.var_name: MERGE_INPUT_2_FILE
test_class.declarator: EXPECTED_MERGE_1_FILE = new File("src/test/resource/resfilter/pot/merge-output-1.pot")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_MERGE_1_FILE = new File("src/test/resource/resfilter/pot/merge-output-1.pot");
test_class.type: File
test_class.var_name: EXPECTED_MERGE_1_FILE
test_class.declarator: EXPECTED_MERGE_2_FILE = new File("src/test/resource/resfilter/pot/merge-output-2.pot")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_MERGE_2_FILE = new File("src/test/resource/resfilter/pot/merge-output-2.pot");
test_class.type: File
test_class.var_name: EXPECTED_MERGE_2_FILE
test_class.declarator: EXPECTED_INPUT_RES_LIST
test_class.modifier: private static final
test_class.original_string: private static final Collection<ResourceString> EXPECTED_INPUT_RES_LIST;
test_class.type: Collection<ResourceString>
test_class.var_name: EXPECTED_INPUT_RES_LIST
test_class.declarator: WRITE_BUNDLE
test_class.modifier: private static
test_class.original_string: private static LanguageBundle WRITE_BUNDLE;
test_class.type: LanguageBundle
test_class.var_name: WRITE_BUNDLE
test_class.declarator: MERGE_BUNDLE
test_class.modifier: private static
test_class.original_string: private static LanguageBundle MERGE_BUNDLE;
test_class.type: LanguageBundle
test_class.var_name: MERGE_BUNDLE
test_class.declarator: res = new POResource()
test_class.modifier: private static final
test_class.original_string: private static final POResource res = new POResource();
test_class.type: POResource
test_class.var_name: res
test_class.file: gp-res-filter/src/test/java/com/ibm/g11n/pipeline/resfilter/impl/POResourceTest.java
test_class.identifier: POResourceTest
test_case.body: @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);
          }
      }
test_case.class_method_signature: POResourceTest.testParse()
test_case.full_signature: @Test public void testParse()
test_case.identifier: testParse
test_case.invocations: assertTrue exists parse getResourceStrings sort assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testParse()
focal_class.file: gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/impl/POResource.java
focal_class.identifier: POResource
focal_class.class_method_signature: POResource.parse(InputStream inStream, FilterOptions options)
focal_class.full_signature: @Override public LanguageBundle parse(InputStream inStream, FilterOptions options)
focal_class.identifier: parse
focal_class.modifiers: @Override public
focal_class.parameters: (InputStream inStream, FilterOptions options)
focal_class.return: LanguageBundle
focal_class.signature: LanguageBundle parse(InputStream inStream, FilterOptions options)
focal_class.class_method_signature: POResource.write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.full_signature: @Override public void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.identifier: write
focal_class.modifiers: @Override public
focal_class.parameters: (OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.return: void
focal_class.signature: void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.superclass: extends POTResource
focal_method.body: @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));
  
          // use these to store the state of an entry
          String singularKey = null;
          String pluralKey = null;
          boolean singularValueSet = false;
  
          String line;
          while ((line = reader.readLine()) != null) {
  
              if (line.isEmpty()) {
                  // reset state, new entry is starting next
                  singularKey = null;
                  pluralKey = null;
                  singularValueSet = false;
                  continue;
              }
  
              String value = extractMessage(line, reader);
              if (value == null || value.isEmpty()) {
                  continue;
              }
  
              if (line.startsWith(UNTRANSLATED_STRING_PREFIX)) {
                  // save the singular key for next loop iteration
                  singularKey = value;
              } else if (singularKey != null && pluralKey == null && line.startsWith(UNTRANSLATED_PLURAL_STRING_PREFIX)) {
                  // save the plural key for next loop iteration
                  pluralKey = value;
              } else if (singularKey != null && pluralKey == null && line.startsWith(TRANSLATED_STRING_PREFIX)
                      && !line.startsWith(TRANSLATED_PLURAL_0_STRING_PREFIX)) {
                  // this covers the normal case when:
                  // msgid "untranslated-string"
                  // msgstr "translated-string"
                  
                  bb.addResourceString(singularKey, value);
              } else if (singularKey != null && pluralKey != null && line.startsWith(TRANSLATED_PLURAL_0_STRING_PREFIX)) {
                  // this covers the singular key/value in a plural entry
                  // the key is the value of msgid and the value is that of
                  // msgstr[0]
                  // msgid "Unable to find user: @users"
                  // msgid_plural "Unable to find users: @users"
                  // msgstr[0] "Benutzer konnte nicht gefunden werden: @users"
                  // msgstr[1] "Benutzer konnten nicht gefunden werden: @users"
  
                  bb.addResourceString(singularKey, value);
                  singularValueSet = true;
              } else if (singularKey != null && pluralKey != null && singularValueSet
                      && line.startsWith(TRANSLATED_PLURAL_1_STRING_PREFIX)) {
                  // this covers the plural key/value in a plural entry
                  // the key is the value of msgid_plural and the value is that of
                  // msgstr[1]
                  bb.addResourceString(pluralKey, value);
              }
          }
  
          return bb.build();
      }
focal_method.class_method_signature: POResource.parse(InputStream inStream, FilterOptions options)
focal_method.full_signature: @Override public LanguageBundle parse(InputStream inStream, FilterOptions options)
focal_method.identifier: parse
focal_method.invocations: readLine isEmpty extractMessage isEmpty startsWith startsWith startsWith startsWith addResourceString startsWith addResourceString startsWith addResourceString build
focal_method.modifiers: @Override public
focal_method.parameters: (InputStream inStream, FilterOptions options)
focal_method.return: LanguageBundle
focal_method.signature: LanguageBundle parse(InputStream inStream, FilterOptions options)