test_class.declarator: INPUT_FILE = new File("src/test/resource/resfilter/yml/input.yml")
test_class.modifier: private static final
test_class.original_string: private static final File INPUT_FILE = new File("src/test/resource/resfilter/yml/input.yml");
test_class.type: File
test_class.var_name: INPUT_FILE
test_class.declarator: EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/yml/write-output.yml")
test_class.modifier: @SuppressWarnings("unused")
      private static final
test_class.original_string: @SuppressWarnings("unused")
      private static final File EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/yml/write-output.yml");
test_class.type: File
test_class.var_name: EXPECTED_WRITE_FILE
test_class.declarator: EXPECTED_MERGE_FILE = new File("src/test/resource/resfilter/yml/merge-output.yml")
test_class.modifier: @SuppressWarnings("unused")
      private static final
test_class.original_string: @SuppressWarnings("unused")
      private static final File EXPECTED_MERGE_FILE = new File("src/test/resource/resfilter/yml/merge-output.yml");
test_class.type: File
test_class.var_name: EXPECTED_MERGE_FILE
test_class.declarator: EXPECTED_INPUT_RES_LIST
test_class.modifier: private static
test_class.original_string: private static 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: res = new YMLResource()
test_class.modifier: private static final
test_class.original_string: private static final YMLResource res = new YMLResource();
test_class.type: YMLResource
test_class.var_name: res
test_class.file: gp-res-filter/src/test/java/com/ibm/g11n/pipeline/resfilter/impl/YMLResourceTest.java
test_class.identifier: YMLResourceTest
test_case.body: @Test
      public void testWrite() throws IOException, ResourceFilterException {
          File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".yml");
          tempFile.deleteOnExit();
  
          try (OutputStream os = new FileOutputStream(tempFile)) {
              res.write(os, WRITE_BUNDLE, null);
              os.flush();
              // TODO: Not ready yet
              // assertTrue(ResourceTestUtil.compareFiles(EXPECTED_WRITE_FILE, tempFile));
          }
      }
test_case.class_method_signature: YMLResourceTest.testWrite()
test_case.full_signature: @Test public void testWrite()
test_case.identifier: testWrite
test_case.invocations: createTempFile getSimpleName getClass deleteOnExit write flush
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWrite()
focal_class.file: gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/impl/YMLResource.java
focal_class.identifier: YMLResource
focal_class.class_method_signature: YMLResource.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: YMLResource.flattenMap(String prefix, Map<String, Object> map, Map<String, String> resource,
              char separator)
focal_class.full_signature: @SuppressWarnings("unchecked") private Map<String, String> flattenMap(String prefix, Map<String, Object> map, Map<String, String> resource,
              char separator)
focal_class.identifier: flattenMap
focal_class.modifiers: @SuppressWarnings("unchecked") private
focal_class.parameters: (String prefix, Map<String, Object> map, Map<String, String> resource,
              char separator)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> flattenMap(String prefix, Map<String, Object> map, Map<String, String> resource,
              char separator)
focal_class.class_method_signature: YMLResource.write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.full_signature: @SuppressWarnings("unchecked") @Override public void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.identifier: write
focal_class.modifiers: @SuppressWarnings("unchecked") @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: YMLResource.writeFile(OutputStream writer, Map<String, Object> map, int depth)
focal_class.full_signature: @SuppressWarnings("unchecked") private void writeFile(OutputStream writer, Map<String, Object> map, int depth)
focal_class.identifier: writeFile
focal_class.modifiers: @SuppressWarnings("unchecked") private
focal_class.parameters: (OutputStream writer, Map<String, Object> map, int depth)
focal_class.return: void
focal_class.signature: void writeFile(OutputStream writer, Map<String, Object> map, int depth)
focal_class.superclass: extends ResourceFilter
focal_method.body: @SuppressWarnings("unchecked")
      @Override
      public void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options) throws IOException, ResourceFilterException {
  
          List<ResourceString> resStrings = languageBundle.getSortedResourceStrings();
  
          // First we need to unflatten the map before writing the file
          char separator = '.';
  
          // map that we will alter in order to populate
          HashMap<String, Object> temp_map = new HashMap<String, Object>();
  
          // map that points to the top so we always have a reference
          HashMap<String, Object> new_map = temp_map;
  
          for (ResourceString res : resStrings) {
              String value = res.getValue();
              String key = res.getKey();
              String[] temp = key.split("\\" + separator);
  
              for (int i = 0; i < temp.length; i++) {
  
                  // last intermediate key - insert value
                  if (i == temp.length - 1) {
                      temp_map.put(temp[i], value);
                  }
  
                  // still in intermediary key - insert a new map
                  else {
                      if (!temp_map.containsKey(temp[i])) {
                          temp_map.put(temp[i], new HashMap<String, Object>());
                      }
                      temp_map = (HashMap<String, Object>) temp_map.get(temp[i]);
                  }
              }
  
              // reset map to point to top of HashMap
              temp_map = new_map;
          }
  
          // Actually write out the file
          writeFile(outStream, temp_map, 0);
      }
focal_method.class_method_signature: YMLResource.write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.full_signature: @SuppressWarnings("unchecked") @Override public void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_method.identifier: write
focal_method.invocations: getSortedResourceStrings getValue getKey split put containsKey put get writeFile
focal_method.modifiers: @SuppressWarnings("unchecked") @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)