test_class.declarator: INPUT_FILE = new File("src/test/resource/resfilter/xliff/input.xlf")
test_class.modifier: private static final
test_class.original_string: private static final File INPUT_FILE = new File("src/test/resource/resfilter/xliff/input.xlf");
test_class.type: File
test_class.var_name: INPUT_FILE
test_class.declarator: EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/xliff/write-output.xlf")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/xliff/write-output.xlf");
test_class.type: File
test_class.var_name: EXPECTED_WRITE_FILE
test_class.declarator: MERGE_INPUT_1_FILE = new File("src/test/resource/resfilter/xliff/merge-input-1.xlf")
test_class.modifier: private static final
test_class.original_string: private static final File MERGE_INPUT_1_FILE = new File("src/test/resource/resfilter/xliff/merge-input-1.xlf");
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/xliff/merge-input-2.xlf")
test_class.modifier: private static final
test_class.original_string: private static final File MERGE_INPUT_2_FILE = new File("src/test/resource/resfilter/xliff/merge-input-2.xlf");
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/xliff/merge-output-1.xlf")
test_class.modifier: @SuppressWarnings("unused")
      private static final
test_class.original_string: @SuppressWarnings("unused")
      private static final File EXPECTED_MERGE_1_FILE = new File("src/test/resource/resfilter/xliff/merge-output-1.xlf");
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/xliff/merge-output-2.xlf")
test_class.modifier: @SuppressWarnings("unused")
      private static final
test_class.original_string: @SuppressWarnings("unused")
      private static final File EXPECTED_MERGE_2_FILE = new File("src/test/resource/resfilter/xliff/merge-output-2.xlf");
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 XLIFFResource()
test_class.modifier: private static final
test_class.original_string: private static final XLIFFResource res = new XLIFFResource();
test_class.type: XLIFFResource
test_class.var_name: res
test_class.file: gp-res-filter/src/test/java/com/ibm/g11n/pipeline/resfilter/impl/XLIFFResourceTest.java
test_class.identifier: XLIFFResourceTest
test_case.body: @SuppressWarnings("deprecation")
      @Test
      public void testMerge() throws IOException, ResourceFilterException {
          File tempFile;
  
          tempFile = File.createTempFile(this.getClass().getSimpleName(), ".xlf");
          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();
              // TODO: Not ready yet
              // assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_1_FILE,
              // tempFile));
          }
  
          tempFile = File.createTempFile(this.getClass().getSimpleName(), ".xlf");
          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();
              // TODO: Not ready yet
              // assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_2_FILE,
              // tempFile));
          }
      }
test_case.class_method_signature: XLIFFResourceTest.testMerge()
test_case.full_signature: @SuppressWarnings("deprecation") @Test public void testMerge()
test_case.identifier: testMerge
test_case.invocations: createTempFile getSimpleName getClass deleteOnExit merge flush createTempFile getSimpleName getClass deleteOnExit merge flush
test_case.modifiers: @SuppressWarnings("deprecation") @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMerge()
focal_class.declarator: VERSION_STRING = "version"
focal_class.modifier: private static final
focal_class.original_string: private static final String VERSION_STRING = "version";
focal_class.type: String
focal_class.var_name: VERSION_STRING
focal_class.declarator: VERSION_NUMBER_STRING = "1.2"
focal_class.modifier: private static final
focal_class.original_string: private static final String VERSION_NUMBER_STRING = "1.2";
focal_class.type: String
focal_class.var_name: VERSION_NUMBER_STRING
focal_class.declarator: XMLNS_STRING = "xmlns:xsi"
focal_class.modifier: private static final
focal_class.original_string: private static final String XMLNS_STRING = "xmlns:xsi";
focal_class.type: String
focal_class.var_name: XMLNS_STRING
focal_class.declarator: XMLNS_VALUE_STRING = "http://www.w3.org/2001/XMLSchema-instance"
focal_class.modifier: private static final
focal_class.original_string: private static final String XMLNS_VALUE_STRING = "http://www.w3.org/2001/XMLSchema-instance";
focal_class.type: String
focal_class.var_name: XMLNS_VALUE_STRING
focal_class.declarator: XSI_STRING = "xsi:schemaLocation"
focal_class.modifier: private static final
focal_class.original_string: private static final String XSI_STRING = "xsi:schemaLocation";
focal_class.type: String
focal_class.var_name: XSI_STRING
focal_class.declarator: XSI_VALUE_STRING = "urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd"
focal_class.modifier: private static final
focal_class.original_string: private static final String XSI_VALUE_STRING = "urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd";
focal_class.type: String
focal_class.var_name: XSI_VALUE_STRING
focal_class.declarator: UNIT_STRING = "trans-unit"
focal_class.modifier: private static final
focal_class.original_string: private static final String UNIT_STRING = "trans-unit";
focal_class.type: String
focal_class.var_name: UNIT_STRING
focal_class.declarator: ID_STRING = "id"
focal_class.modifier: private static final
focal_class.original_string: private static final String ID_STRING = "id";
focal_class.type: String
focal_class.var_name: ID_STRING
focal_class.declarator: SOURCE_STRING = "source"
focal_class.modifier: private static final
focal_class.original_string: private static final String SOURCE_STRING = "source";
focal_class.type: String
focal_class.var_name: SOURCE_STRING
focal_class.declarator: TARGET_STRING = "target"
focal_class.modifier: private static final
focal_class.original_string: private static final String TARGET_STRING = "target";
focal_class.type: String
focal_class.var_name: TARGET_STRING
focal_class.declarator: XLIFF_STRING = "xliff"
focal_class.modifier: private static final
focal_class.original_string: private static final String XLIFF_STRING = "xliff";
focal_class.type: String
focal_class.var_name: XLIFF_STRING
focal_class.declarator: FILE_STRING = "file"
focal_class.modifier: private static final
focal_class.original_string: private static final String FILE_STRING = "file";
focal_class.type: String
focal_class.var_name: FILE_STRING
focal_class.declarator: ORIGINAL_STRING = "original"
focal_class.modifier: private static final
focal_class.original_string: private static final String ORIGINAL_STRING = "original";
focal_class.type: String
focal_class.var_name: ORIGINAL_STRING
focal_class.declarator: GLOBAL_STRING = "g11n-pipeline"
focal_class.modifier: private static final
focal_class.original_string: private static final String GLOBAL_STRING = "g11n-pipeline";
focal_class.type: String
focal_class.var_name: GLOBAL_STRING
focal_class.declarator: DATATYPE_STRING = "datatype"
focal_class.modifier: private static final
focal_class.original_string: private static final String DATATYPE_STRING = "datatype";
focal_class.type: String
focal_class.var_name: DATATYPE_STRING
focal_class.declarator: PLAINTEXT_STRING = "plaintext"
focal_class.modifier: private static final
focal_class.original_string: private static final String PLAINTEXT_STRING = "plaintext";
focal_class.type: String
focal_class.var_name: PLAINTEXT_STRING
focal_class.declarator: SOURCE_LANGUAGE_STRING = "source-language"
focal_class.modifier: private static final
focal_class.original_string: private static final String SOURCE_LANGUAGE_STRING = "source-language";
focal_class.type: String
focal_class.var_name: SOURCE_LANGUAGE_STRING
focal_class.declarator: ENGLISH = "en"
focal_class.modifier: private static final
focal_class.original_string: private static final String ENGLISH = "en";
focal_class.type: String
focal_class.var_name: ENGLISH
focal_class.declarator: TARGET_LANGUAGE_STRING = "target-language"
focal_class.modifier: private static final
focal_class.original_string: private static final String TARGET_LANGUAGE_STRING = "target-language";
focal_class.type: String
focal_class.var_name: TARGET_LANGUAGE_STRING
focal_class.declarator: BODY_STRING = "body"
focal_class.modifier: private static final
focal_class.original_string: private static final String BODY_STRING = "body";
focal_class.type: String
focal_class.var_name: BODY_STRING
focal_class.file: gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/impl/XLIFFResource.java
focal_class.identifier: XLIFFResource
focal_class.class_method_signature: XLIFFResource.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: XLIFFResource.collectResourceStrings(NodeList nodeList, LanguageBundleBuilder bb, int version, String key)
focal_class.full_signature: private void collectResourceStrings(NodeList nodeList, LanguageBundleBuilder bb, int version, String key)
focal_class.identifier: collectResourceStrings
focal_class.modifiers: private
focal_class.parameters: (NodeList nodeList, LanguageBundleBuilder bb, int version, String key)
focal_class.return: void
focal_class.signature: void collectResourceStrings(NodeList nodeList, LanguageBundleBuilder bb, int version, String key)
focal_class.class_method_signature: XLIFFResource.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: XLIFFResource.merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.full_signature: @Override @Deprecated /* * This method is incomplete and may not produce the expected output. * * (non-Javadoc) * @see com.ibm.g11n.pipeline.resfilter.ResourceFilter#merge(java.io.InputStream, java.io.OutputStream, java.lang.String, java.util.Collection) */ public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.identifier: merge
focal_class.modifiers: @Override @Deprecated /* * This method is incomplete and may not produce the expected output. * * (non-Javadoc) * @see com.ibm.g11n.pipeline.resfilter.ResourceFilter#merge(java.io.InputStream, java.io.OutputStream, java.lang.String, java.util.Collection) */ 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.superclass: extends ResourceFilter
focal_method.body: @Override
      @Deprecated
      /*
       * This method is incomplete and may not produce the expected output.
       *
       * (non-Javadoc)
       * @see com.ibm.g11n.pipeline.resfilter.ResourceFilter#merge(java.io.InputStream, java.io.OutputStream, java.lang.String, java.util.Collection)
       */
      public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options) throws IOException, ResourceFilterException {
  
          String targetLanguage = languageBundle.getEmbeddedLanguageCode();
          if (targetLanguage == null || targetLanguage.isEmpty()) {
              throw new ResourceFilterException("Target language is not specified.");
          }
  
          Map<String, String> kvMap = Utils.createKeyValueMap(languageBundle.getResourceStrings());
  
          // TODO: We should use xml encoding declaration, instead of hardcoding
          // "UTF-8"
          Scanner in = new Scanner(baseStream, "UTF-8");
          String line = "";
          String key_pattern = "^.*<unit.*id=\".*\">\n$";
          String end_source_pattern = ".*</source>\n$";
          while (in.hasNextLine()) {
              line = in.nextLine() + '\n';
              if (!line.matches(key_pattern)) {
                  if (line.indexOf("<xliff") != -1) {
                      StringBuilder newline = new StringBuilder(100);
                      newline.append("<xliff version=\"2.0\" srcLang=\"en\" targLang=\"").append(targetLanguage).append("\">");
                      line = newline.toString();
                  }
                  outStream.write(line.getBytes());
              } else {
                  String[] wordList = line.split("\"");
                  String key = wordList[1];
  
                  // +2 for source and source block
                  String whiteSpace = line.substring(0, line.indexOf("<")) + "  ";
  
                  // writes key line
                  while (!line.matches(end_source_pattern)) {
                      outStream.write(line.getBytes());
                      line = in.nextLine() + '\n';
                  }
  
                  outStream.write(line.getBytes());
                  // TODO: Instead of linear search resource key every time,
                  // we may create hash map first.
  
                  if (kvMap.containsKey(key)) {
                      String value = kvMap.get(key);
                      final int character_offset = 80;
  
                      BreakIterator b = BreakIterator.getWordInstance();
                      b.setText(value);
  
                      int offset = 80;
                      int start = 0;
  
                      boolean first = true;
  
                      StringBuilder temp = new StringBuilder(100);
                      temp.append(whiteSpace).append("<target>");
                      while (start < value.length()) {
                          if (value.length() > character_offset) {
  
                              if (!first) {
                                  temp.append(whiteSpace).append(" ");
                              }
  
                              first = false;
                              int end = b.following(offset);
                              String str = value.substring(start, end);
                              start = end;
                              offset += 80;
                              temp.append(str).append(" \\\n");
                          } else {
                              temp.append(value);
                              start = value.length();
                          }
                      }
  
                      if (value.length() > character_offset) {
                          temp.append(whiteSpace);
                      }
  
                      temp.append("</target>\n");
                      outStream.write(temp.toString().getBytes());
                  } else {
                      outStream.write(line.getBytes());
                  }
  
              }
          }
          in.close();
      }
focal_method.class_method_signature: XLIFFResource.merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.full_signature: @Override @Deprecated /* * This method is incomplete and may not produce the expected output. * * (non-Javadoc) * @see com.ibm.g11n.pipeline.resfilter.ResourceFilter#merge(java.io.InputStream, java.io.OutputStream, java.lang.String, java.util.Collection) */ public void merge(InputStream baseStream, OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.identifier: merge
focal_method.invocations: getEmbeddedLanguageCode isEmpty createKeyValueMap getResourceStrings hasNextLine nextLine matches indexOf append append append toString write getBytes split substring indexOf matches write getBytes nextLine write getBytes containsKey get getWordInstance setText append append length length append append following substring append append append length length append append write getBytes toString write getBytes close
focal_method.modifiers: @Override @Deprecated /* * This method is incomplete and may not produce the expected output. * * (non-Javadoc) * @see com.ibm.g11n.pipeline.resfilter.ResourceFilter#merge(java.io.InputStream, java.io.OutputStream, java.lang.String, java.util.Collection) */ 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)