class YMLResource extends ResourceFilter {

    @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);
    }

}