Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.DumperOptions


import org.yaml.snakeyaml.nodes.Tag;
import org.yaml.snakeyaml.representer.Representer;

public class LongTest extends TestCase {
    public void testLongFail() {
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
        Yaml yaml = new Yaml(options);
        Foo foo = new Foo();
        String output = yaml.dump(foo);
        // System.out.println(output);
        try {
View Full Code Here


            this.bar = bar;
        }
    }

    public void testLongRepresenter() {
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
        Representer repr = new Representer();
        repr.addClassTag(Long.class, new Tag("!!java.lang.Long"));
        Yaml yaml = new Yaml(repr, options);

        Foo foo = new Foo();
View Full Code Here

        list.add(new Date(1229684761009L));
        list.add(new Date(1229684761150L));
        list.add(new Date(1229684761100L));
        list.add(new Date(1229684761000L));
        list.add(new Date(1229684760000L));
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(list);
        assertEquals(
                "- 2008-12-19T11:06:01.159Z\n- 2008-12-19T11:06:01.059Z\n- 2008-12-19T11:06:01.009Z\n- 2008-12-19T11:06:01.150Z\n- 2008-12-19T11:06:01.100Z\n- 2008-12-19T11:06:01Z\n- 2008-12-19T11:06:00Z\n",
                output);
View Full Code Here

        list.add(new Integer(1));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("list", list);
        map.put("name", "Ubuntu");
        map.put("age", 5);
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(map);
        assertTrue(output.contains("\"age\": !!int \"5\""));
        assertTrue(output.contains("\"name\": \"Ubuntu\""));
        assertTrue(output.contains("- !!int \"1\""));
View Full Code Here

        list.add(new Integer(1));
        Map<String, Object> map = new LinkedHashMap<String, Object>();
        map.put("age", 5);
        map.put("name", "Ubuntu");
        map.put("list", list);
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(map);
        assertEquals("{'age': !!int '5', 'name': 'Ubuntu', 'list': [!!int '1', !!int '1']}\n",
                output);
    }
View Full Code Here

        list.add(new Integer(1));
        Map<String, Object> map = new LinkedHashMap<String, Object>();
        map.put("age", 5);
        map.put("name", "Ubuntu");
        map.put("list", list);
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
        options.setPrettyFlow(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(map);
        assertEquals(
                "{\n  'age': !!int '5',\n  'name': 'Ubuntu',\n  'list': [\n    !!int '1',\n    !!int '1']\n  \n}\n",
                output);
View Full Code Here

    }

    public void testStringsPretty() {
        A a = new A();
        a.setNames(new String[] { "aaa", "bbb", "ccc" });
        DumperOptions options = new DumperOptions();
        options.setPrettyFlow(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(a);
        assertEquals(
                "!!org.yaml.snakeyaml.javabeans.StringArrayTest$A\nnames: [\n  aaa,\n  bbb,\n  ccc]\n",
                output);
View Full Code Here

import org.yaml.snakeyaml.representer.Representer;

public class DiceExampleTest extends TestCase {
    public void testRepresenter() {
        Dice dice = new Dice(3, 6);
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(dice);
        assertEquals("!!examples.Dice {a: 3, b: 6}\n", output);
    }
View Full Code Here

    public void testDiceRepresenter() {
        Dice dice = new Dice(3, 6);
        Map<String, Dice> data = new HashMap<String, Dice>();
        data.put("gold", dice);
        Yaml yaml = new Yaml(new DiceRepresenter(), new DumperOptions());
        String output = yaml.dump(data);
        assertEquals("{gold: !dice '3d6'}\n", output);
    }
View Full Code Here

        String document = "  a: 1\n  b:\n    c: 3\n    d: 4\n";
        assertEquals("a: 1\nb: {c: 3, d: 4}\n", yaml.dump(yaml.load(document)));
    }

    public void testNestedStyle2() {
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        Yaml yaml = new Yaml(options);
        String document = "  a: 1\n  b:\n    c: 3\n    d: 4\n";
        assertEquals("a: 1\nb:\n  c: 3\n  d: 4\n", yaml.dump(yaml.load(document)));
    }
View Full Code Here

TOP

Related Classes of org.yaml.snakeyaml.DumperOptions

Copyright © 2018 www.massapicom. 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.