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: @Test
      public void testWrite() throws IOException, ResourceFilterException {
          File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".xlf");
          tempFile.deleteOnExit();
  
          try (OutputStream os = new FileOutputStream(tempFile)) {
              res.write(os, WRITE_BUNDLE, new FilterOptions(Locale.JAPANESE));
              os.flush();
              assertThat(EXPECTED_WRITE_FILE, CompareMatcher.isIdenticalTo(tempFile));
          }
      }
test_case.class_method_signature: XLIFFResourceTest.testWrite()
test_case.full_signature: @Test public void testWrite()
test_case.identifier: testWrite
test_case.invocations: createTempFile getSimpleName getClass deleteOnExit write flush assertThat isIdenticalTo
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWrite()
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
      public void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options) throws IOException, ResourceFilterException {
  
          List<ResourceString> resStrings = languageBundle.getSortedResourceStrings();
  
          String targetLanguage = languageBundle.getEmbeddedLanguageCode();
          if (targetLanguage == null || targetLanguage.isEmpty()) {
              throw new ResourceFilterException("Target language is not specified.");
          }
  
          DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder docBuilder = null;
          try {
              docBuilder = docFactory.newDocumentBuilder();
          } catch (ParserConfigurationException e) {
              // runtime problem
              throw new RuntimeException(e);
          }
  
          // root elements
          Document doc = docBuilder.newDocument();
  
          Element xliff = doc.createElement(XLIFF_STRING);
          xliff.setAttribute(VERSION_STRING, VERSION_NUMBER_STRING);
          xliff.setAttribute(XMLNS_STRING,XMLNS_VALUE_STRING);
          xliff.setAttribute(XSI_STRING,XSI_VALUE_STRING);
  
          Element file = doc.createElement(FILE_STRING);
          file.setAttribute(ORIGINAL_STRING, GLOBAL_STRING);
          file.setAttribute(DATATYPE_STRING, PLAINTEXT_STRING);
          // TODO: Support source languages other than English
          file.setAttribute(SOURCE_LANGUAGE_STRING, ENGLISH);
          file.setAttribute(TARGET_LANGUAGE_STRING, targetLanguage);
          xliff.appendChild(file);
  
          Element body = doc.createElement(BODY_STRING);
          file.appendChild(body);
  
          for (ResourceString resString : resStrings) {
              Element trans_unit = doc.createElement(UNIT_STRING);
              trans_unit.setAttribute(ID_STRING, resString.getKey());
              Element source = doc.createElement(SOURCE_STRING);
              source.setTextContent(resString.getSourceValue());
              trans_unit.appendChild(source);
              Element target = doc.createElement(TARGET_STRING);
              target.setTextContent(resString.getValue());
              trans_unit.appendChild(target);
              body.appendChild(trans_unit);
          }
  
          doc.appendChild(xliff);
  
          TransformerFactory transformerFactory = TransformerFactory.newInstance();
          Transformer transformer = null;
          try {
              transformer = transformerFactory.newTransformer();
          } catch (TransformerConfigurationException e) {
              // runtime problem
              throw new RuntimeException(e);
          }
  
          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
          transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
  
          DOMSource source = new DOMSource(doc);
          StreamResult result = new StreamResult(outStream);
  
          try {
              transformer.transform(source, result);
          } catch (TransformerException e) {
              // runtime problem?
              throw new RuntimeException(e);
          }
      }
focal_method.class_method_signature: XLIFFResource.write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.full_signature: @Override public void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.identifier: write
focal_method.invocations: getSortedResourceStrings getEmbeddedLanguageCode isEmpty newInstance newDocumentBuilder newDocument createElement setAttribute setAttribute setAttribute createElement setAttribute setAttribute setAttribute setAttribute appendChild createElement appendChild createElement setAttribute getKey createElement setTextContent getSourceValue appendChild createElement setTextContent getValue appendChild appendChild appendChild newInstance newTransformer setOutputProperty setOutputProperty transform
focal_method.modifiers: @Override public
focal_method.parameters: (OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.return: void
focal_method.signature: void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)