// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package yamlproc;

import java.io.FileReader;
import java.io.IOException;
import java.util.Map;

import com.esotericsoftware.yamlbeans.YamlReader;

public class BeansTree {
    public static void main(String[] args) throws IOException {
        YamlReader parser = new YamlReader(new FileReader("/work/demo1.yaml"));
        @SuppressWarnings("unchecked")
        Map<String, Object> cfg = (Map<String, Object>)parser.read();
        @SuppressWarnings("unchecked")
        Map<String, Object> ab = (Map<String, Object>)cfg.get("ab");
        @SuppressWarnings("unchecked")
        Map<String, Object> de = (Map<String, Object>)cfg.get("de");
        int a = Integer.parseInt((String)ab.get("a"));
        int b = Integer.parseInt((String)ab.get("b"));
        int c = Integer.parseInt((String)cfg.get("c"));
        String d = (String)de.get("d");
        String e = (String)de.get("e");
        String f = (String)cfg.get("f");
        System.out.printf("%d %d %d %s %s %s\n", a, b, c, d, e, f);
    }
}
