Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.DumperOptions


        assertEquals(new Double(4), result.getDoubleClass());
        assertEquals(new Double(11200), result.getDoublePrimitive());
        assertEquals(1199836800000L, result.getDate().getTime());
        assertEquals("public", result.publicField);
        //
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        Yaml yamlToDump = new Yaml(options);
        String output = yamlToDump.dump(result);
        TestBean1 result2 = (TestBean1) yaml.load(output);
        assertNotNull(result2);
        TestBean1 result3 = (TestBean1) new Yaml().load(output);
View Full Code Here


                        c, hexdump(result)));
        }
    }

    private Yaml createYaml() {
        DumperOptions options = new DumperOptions();
        options.setAllowUnicode(false);
        options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
        return new Yaml(options);
    }
View Full Code Here

public class IncompleteBeanConstructorTest extends TestCase {

    public void testRepresentor() {
        IncompleteJavaBean bean = new IncompleteJavaBean();
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(bean);
        String className = this.getClass().getPackage().getName();
        assertEquals("!!" + className + ".IncompleteJavaBean {name: No name}\n", output);
    }
View Full Code Here

import org.yaml.snakeyaml.representer.Representer;

public class DumpSetAsSequenceExampleTest extends TestCase {

    public void testDumpFlow() {
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(new SetRepresenter(), options);
        String output = yaml.dump(createBlog());
        // System.out.println(output);
        assertEquals(Util.getLocalResource("issues/issue73-dump7.txt"), output);
        //
View Full Code Here

        //
        check(output);
    }

    public void testDumpBlock() {
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        options.setDefaultFlowStyle(FlowStyle.BLOCK);
        Yaml yaml = new Yaml(new SetRepresenter(), options);
        String output = yaml.dump(createBlog());
        // System.out.println(output);
        assertEquals(Util.getLocalResource("issues/issue73-dump8.txt"), output);
        //
View Full Code Here

        TreeSet<String> labels = new TreeSet<String>();
        labels.add("Java");
        labels.add("YAML");
        labels.add("SnakeYAML");
        blog.setLabels(labels);
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(blog);
        // System.out.println(output);
        assertEquals(Util.getLocalResource("issues/issue73-1.txt"), output);
    }
View Full Code Here

        assertEquals(12345, result.getSub2().getAtt3());
    }

    public void testEmitNoTags() {
        TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
        DumperOptions options = new DumperOptions();
        options.setExplicitStart(true);
        Yaml yaml2 = new Yaml(options);
        String output = yaml2.dumpAsMap(result);
        assertFalse("No tags expected.", output.contains("Sub1"));
        // System.out.println(output);
        // parse back. Without tags it shall still work
View Full Code Here

        assertEquals(12345, result2.getSub2().getAtt3());
    }

    public void testEmitWithTags() {
        TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
        DumperOptions options = new DumperOptions();
        options.setExplicitStart(true);
        Representer repr = new Representer();
        repr.addClassTag(TestObject.class, new Tag("!ruby/object:Test::Module::Object"));
        repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
        repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
        Yaml yaml2 = new Yaml(repr, options);
View Full Code Here

            Wheel wheel = new Wheel();
            wheel.setId(i);
            wheels[i - 1] = wheel;
        }
        car.setWheels(wheels);
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(FlowStyle.BLOCK);
        Yaml yaml = new Yaml(options);
        assertEquals(Util.getLocalResource("constructor/cararray-with-tags.yaml"), yaml.dump(car));
    }
View Full Code Here

    /**
     * test block style
     */
    public void testBoolOutAsEmpty3() {
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(FlowStyle.BLOCK);
        Yaml yaml = new Yaml(new BoolRepresenter("True"), options);
        Map<String, Boolean> map = new HashMap<String, Boolean>();
        map.put("aaa", false);
        map.put("bbb", true);
        String output = yaml.dump(map);
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.