Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.Yaml.represent()


        assertNull("The tag should not be specified: " + tag, tag);
    }

    public void testDump() {
        Yaml yaml = new Yaml();
        Node intNode = yaml.represent(7);
        assertEquals("tag:yaml.org,2002:int", intNode.getTag().toString());
        // System.out.println(intNode);
        List<Event> intEvents = yaml.serialize(intNode);
        String tag = ((ScalarEvent) intEvents.get(2)).getTag();
        assertEquals("Without the tag emitter would not know how to emit '7'",
View Full Code Here


        List<Event> intEvents = yaml.serialize(intNode);
        String tag = ((ScalarEvent) intEvents.get(2)).getTag();
        assertEquals("Without the tag emitter would not know how to emit '7'",
                "tag:yaml.org,2002:int", tag);
        //
        Node strNode = yaml.represent("7");
        assertEquals("tag:yaml.org,2002:str", strNode.getTag().toString());
        // System.out.println(strNode);
    }
}
View Full Code Here

        list.add(map);
        Yaml yaml = new Yaml();
        String etalon = yaml.dump(list);
        // System.out.println(etalon);
        //
        Node node = yaml.represent(list);
        // System.out.println(node);
        assertEquals(
                "Representation tree from an object and from its YAML document must be the same.",
                yaml.compose(new StringReader(etalon)).toString(), node.toString());
        //
View Full Code Here

        bean.setDate(etalon);
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(FlowStyle.BLOCK);
        Yaml dumper = new Yaml(new JodaTimeRepresenter(), options);
        // compare Nodes with flow style AUTO and flow style BLOCK
        Node node1 = dumper.represent(bean);
        DumperOptions options2 = new DumperOptions();
        options2.setDefaultFlowStyle(FlowStyle.AUTO);
        Yaml dumper2 = new Yaml(new JodaTimeRepresenter(), options2);
        Node node2 = dumper2.represent(bean);
        assertEquals(node2.toString(), node1.toString());
View Full Code Here

        // compare Nodes with flow style AUTO and flow style BLOCK
        Node node1 = dumper.represent(bean);
        DumperOptions options2 = new DumperOptions();
        options2.setDefaultFlowStyle(FlowStyle.AUTO);
        Yaml dumper2 = new Yaml(new JodaTimeRepresenter(), options2);
        Node node2 = dumper2.represent(bean);
        assertEquals(node2.toString(), node1.toString());
        // compare Events with flow style AUTO and flow style BLOCK
        List<Event> events1 = dumper.serialize(node1);
        List<Event> events2 = dumper2.serialize(node2);
        assertEquals(events2.size(), events1.size());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.