test_class.declarator: INPUT_FILE = new File("src/test/resource/resfilter/pot/input.pot")
test_class.modifier: private static final
test_class.original_string: private static final File INPUT_FILE = new File("src/test/resource/resfilter/pot/input.pot");
test_class.type: File
test_class.var_name: INPUT_FILE
test_class.declarator: EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/pot/write-output.pot")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/pot/write-output.pot");
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 POTResource()
test_class.modifier: private static final
test_class.original_string: private static final POTResource res = new POTResource();
test_class.type: POTResource
test_class.var_name: res
test_class.file: gp-res-filter/src/test/java/com/ibm/g11n/pipeline/resfilter/impl/POTResourceTest.java
test_class.identifier: POTResourceTest
test_case.body: @Test
      public void testMerge() throws IOException, ResourceFilterException {
          File tempFile;
  
          tempFile = File.createTempFile(this.getClass().getSimpleName(), ".pot");
          tempFile.deleteOnExit();
  
          try (OutputStream os = new FileOutputStream(tempFile);
                  InputStream is = new FileInputStream(MERGE_INPUT_1_FILE)) {
              res.merge(is, os, MERGE_BUNDLE, new FilterOptions(Locale.ENGLISH));
              os.flush();
              assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_1_FILE, tempFile));
          }
  
          tempFile = File.createTempFile(this.getClass().getSimpleName(), ".pot");
          tempFile.deleteOnExit();
  
          try (OutputStream os = new FileOutputStream(tempFile);
                  InputStream is = new FileInputStream(MERGE_INPUT_2_FILE)) {
              res.merge(is, os, MERGE_BUNDLE, new FilterOptions(Locale.JAPANESE));
              os.flush();
              assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_2_FILE, tempFile));
          }
      }
test_case.class_method_signature: POTResourceTest.testMerge()
test_case.full_signature: @Test public void testMerge()
test_case.identifier: testMerge
test_case.invocations: createTempFile getSimpleName getClass deleteOnExit merge flush assertTrue compareFiles createTempFile getSimpleName getClass deleteOnExit merge flush assertTrue compareFiles
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMerge()
focal_class.declarator: CHAR_SET = "UTF-8"
focal_class.modifier: static final
focal_class.original_string: static final String CHAR_SET = "UTF-8";
focal_class.type: String
focal_class.var_name: CHAR_SET
focal_class.declarator: ENTRY_PREFIX_PATTERN = "^(msgid|msgstr).*"
focal_class.modifier: static final
focal_class.original_string: static final String ENTRY_PREFIX_PATTERN = "^(msgid|msgstr).*";
focal_class.type: String
focal_class.var_name: ENTRY_PREFIX_PATTERN
focal_class.declarator: UNTRANSLATED_STRING_PREFIX = "msgid "
focal_class.modifier: static final
focal_class.original_string: static final String UNTRANSLATED_STRING_PREFIX = "msgid ";
focal_class.type: String
focal_class.var_name: UNTRANSLATED_STRING_PREFIX
focal_class.declarator: UNTRANSLATED_PLURAL_STRING_PREFIX = "msgid_plural "
focal_class.modifier: static final
focal_class.original_string: static final String UNTRANSLATED_PLURAL_STRING_PREFIX = "msgid_plural ";
focal_class.type: String
focal_class.var_name: UNTRANSLATED_PLURAL_STRING_PREFIX
focal_class.declarator: TRANSLATED_STRING_PREFIX = "msgstr "
focal_class.modifier: static final
focal_class.original_string: static final String TRANSLATED_STRING_PREFIX = "msgstr ";
focal_class.type: String
focal_class.var_name: TRANSLATED_STRING_PREFIX
focal_class.declarator: TRANSLATED_PLURAL_STRING_PREFIX = "msgstr["
focal_class.modifier: static final
focal_class.original_string: static final String TRANSLATED_PLURAL_STRING_PREFIX = "msgstr[";
focal_class.type: String
focal_class.var_name: TRANSLATED_PLURAL_STRING_PREFIX
focal_class.declarator: TRANSLATED_PLURAL_0_STRING_PREFIX = "msgstr[0] "
focal_class.modifier: static final
focal_class.original_string: static final String TRANSLATED_PLURAL_0_STRING_PREFIX = "msgstr[0] ";
focal_class.type: String
focal_class.var_name: TRANSLATED_PLURAL_0_STRING_PREFIX
focal_class.declarator: TRANSLATED_PLURAL_1_STRING_PREFIX = "msgstr[1] "
focal_class.modifier: static final
focal_class.original_string: static final String TRANSLATED_PLURAL_1_STRING_PREFIX = "msgstr[1] ";
focal_class.type: String
focal_class.var_name: TRANSLATED_PLURAL_1_STRING_PREFIX
focal_class.declarator: PLURAL_KEY_PREFIX = "{n} "
focal_class.modifier: static final
focal_class.original_string: static final String PLURAL_KEY_PREFIX = "{n} ";
focal_class.type: String
focal_class.var_name: PLURAL_KEY_PREFIX
focal_class.declarator: HEADER = "# Translations template for PROJECT.\n" + "# Copyright (C) %s ORGANIZATION\n"
              + "# This file is distributed under the same license as the " + "PROJECT project.\n"
              + "# FIRST AUTHOR <EMAIL@ADDRESS>, %s.\n" + "#\n" + "#, fuzzy\n" + "msgid \"\"\n" + "msgstr \"\"\n"
              + "\"Project-Id-Version: PROJECT VERSION\\n\"\n" + "\"Report-Msgid-Bugs-To: EMAIL@ADDRESS\\n\"\n"
              + "\"POT-Creation-Date: %s\\n\"\n" + "\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n"
              + "\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\"\n" + "\"Language-Team: LANGUAGE <LL@li.org>\\n\"\n"
              + "\"MIME-Version: 1.0\\n\"\n" + "\"Content-Type: text/plain; charset=%s\\n\"\n"
              + "\"Content-Transfer-Encoding: 8bit\\n\"\n" + "\"Generated-By: Globalization Pipeline\\n\"\n"
focal_class.modifier: static final
focal_class.original_string: static final String HEADER = "# Translations template for PROJECT.\n" + "# Copyright (C) %s ORGANIZATION\n"
              + "# This file is distributed under the same license as the " + "PROJECT project.\n"
              + "# FIRST AUTHOR <EMAIL@ADDRESS>, %s.\n" + "#\n" + "#, fuzzy\n" + "msgid \"\"\n" + "msgstr \"\"\n"
              + "\"Project-Id-Version: PROJECT VERSION\\n\"\n" + "\"Report-Msgid-Bugs-To: EMAIL@ADDRESS\\n\"\n"
              + "\"POT-Creation-Date: %s\\n\"\n" + "\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n"
              + "\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\"\n" + "\"Language-Team: LANGUAGE <LL@li.org>\\n\"\n"
              + "\"MIME-Version: 1.0\\n\"\n" + "\"Content-Type: text/plain; charset=%s\\n\"\n"
              + "\"Content-Transfer-Encoding: 8bit\\n\"\n" + "\"Generated-By: Globalization Pipeline\\n\"\n";
focal_class.type: String
focal_class.var_name: HEADER
focal_class.file: gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/impl/POTResource.java
focal_class.identifier: POTResource
focal_class.class_method_signature: POTResource.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: POTResource.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.class_method_signature: POTResource.merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.full_signature: @Override public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.identifier: merge
focal_class.modifiers: @Override public
focal_class.parameters: (InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.return: void
focal_class.signature: void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.class_method_signature: POTResource.extractMessage(String firstLine, BufferedReader reader)
focal_class.full_signature: static String extractMessage(String firstLine, BufferedReader reader)
focal_class.identifier: extractMessage
focal_class.modifiers: static
focal_class.parameters: (String firstLine, BufferedReader reader)
focal_class.return: String
focal_class.signature: String extractMessage(String firstLine, BufferedReader reader)
focal_class.class_method_signature: POTResource.extractMsgBetweenQuotes(String line)
focal_class.full_signature: static String extractMsgBetweenQuotes(String line)
focal_class.identifier: extractMsgBetweenQuotes
focal_class.modifiers: static
focal_class.parameters: (String line)
focal_class.return: String
focal_class.signature: String extractMsgBetweenQuotes(String line)
focal_class.class_method_signature: POTResource.formatMessage(String prefix, String message, BreakIterator brkItr)
focal_class.full_signature: static String formatMessage(String prefix, String message, BreakIterator brkItr)
focal_class.identifier: formatMessage
focal_class.modifiers: static
focal_class.parameters: (String prefix, String message, BreakIterator brkItr)
focal_class.return: String
focal_class.signature: String formatMessage(String prefix, String message, BreakIterator brkItr)
focal_class.class_method_signature: POTResource.getHeader()
focal_class.full_signature: static String getHeader()
focal_class.identifier: getHeader
focal_class.modifiers: static
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getHeader()
focal_class.superclass: extends ResourceFilter
focal_method.body: @Override
      public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options) throws IOException, ResourceFilterException {
          // put res data into a map for easier searching
          Map<String, String> kvMap = Utils.createKeyValueMap(languageBundle.getResourceStrings());
  
          BufferedReader reader = new BufferedReader(new InputStreamReader(baseStream, CHAR_SET));
          BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outStream, CHAR_SET));
  
          BreakIterator brkItr = Utils.getWordBreakIterator(options);
  
          String line;
          while ((line = reader.readLine()) != null) {
              // if the line is a msgid, extract the value and check if the key is
              // in the resMap
              if (line.startsWith(UNTRANSLATED_STRING_PREFIX)) {
                  String key = extractMessage(line, reader);
  
                  // write the msgid
                  do {
                      writer.write(line);
                      writer.newLine();
                  } while ((line = reader.readLine()) != null && line.trim().startsWith("\""));
  
                  // write msgstr
                  if (!line.startsWith(TRANSLATED_STRING_PREFIX) || key == null || key.isEmpty()
                          || !kvMap.containsKey(key) || kvMap.get(key) == null) {
                      // key not found, write msgstr as-is
                      do {
                          writer.write(line);
                          writer.newLine();
                      } while ((line = reader.readLine()) != null && !line.isEmpty());
  
                      if (line != null && line.isEmpty()) {
                          writer.newLine();
                      }
                  } else {
                      // key found, write new msgstr
                      writer.write(formatMessage(TRANSLATED_STRING_PREFIX, kvMap.get(key), brkItr));
                      writer.newLine();
  
                      // skip the old msgstr in the input stream
                      while ((line = reader.readLine()) != null && !line.isEmpty())
                          ;
                  }
              } else {
                  // write line as-is
                  writer.write(line);
                  writer.newLine();
              }
          }
  
          writer.flush();
      }
focal_method.class_method_signature: POTResource.merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.full_signature: @Override public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.identifier: merge
focal_method.invocations: createKeyValueMap getResourceStrings getWordBreakIterator readLine startsWith extractMessage write newLine readLine startsWith trim startsWith isEmpty containsKey get write newLine readLine isEmpty isEmpty newLine write formatMessage get newLine readLine isEmpty write newLine flush
focal_method.modifiers: @Override public
focal_method.parameters: (InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.return: void
focal_method.signature: void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)