Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.DumperOptions


/**
* to test http://code.google.com/p/snakeyaml/issues/detail?id=29
*/
public class FlexibleScalarStyleTest extends TestCase {
    public void testLong() {
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(ScalarStyle.FOLDED);
        Yaml yaml = new Yaml(options);
        String result = yaml
                .dump("qqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq "
                        + "qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq "
                        + "qqqqqqqqqqqqqqqqqqqqqqqqq 111111111111111111111111\n "
View Full Code Here


                ">\n  qqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq\n  qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq 111111111111111111111111\n   qqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqq\n",
                result);
    }

    public void testNoFoldedScalar() {
        DumperOptions options = new DumperOptions();
        options.setWidth(30);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(getData());
        // System.out.println(output);
        String etalon = Util.getLocalResource("representer/scalar-style1.yaml");
        assertEquals(etalon, output);
View Full Code Here

        list.add("This is an \"example\".");
        list.add("123");
        String output = dump(list);
        assertEquals("[This is an 'example'., This is an \"example\"., '123']\n", output);
        // single quoted
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(ScalarStyle.SINGLE_QUOTED);
        Yaml yaml = new Yaml(options);
        String output2 = yaml.dump(list);
        // System.out.println(output2);
        assertEquals("- 'This is an ''example''.'\n- 'This is an \"example\".'\n- '123'\n", output2);
        // double quoted
        DumperOptions options2 = new DumperOptions();
        options2.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
        yaml = new Yaml(options2);
        String output3 = yaml.dump(list);
        // System.out.println(output2);
        assertEquals("- \"This is an 'example'.\"\n- \"This is an \\\"example\\\".\"\n- \"123\"\n",
                output3);
View Full Code Here

        String etalon = Util.getLocalResource("representer/scalar-style1.yaml");
        assertEquals(etalon, output);
    }

    public void testCustomScalarStyle() {
        DumperOptions options = new DumperOptions();
        options.setWidth(30);
        Yaml yaml = new Yaml(new MyRepresenter(), options);
        String output = yaml.dump(getData());
        // System.out.println(output);
        String etalon = Util.getLocalResource("representer/scalar-style2.yaml");
        assertEquals(etalon, output);
View Full Code Here

        File file = new File(omapDirectory(), fileName);
        if (components.size() == 0) {
            logger.info("Nothing to save. skipping...");
            return;
        }
        DumperOptions options = new DumperOptions();
        options.setIndent(4);
        options.setDefaultFlowStyle(FlowStyle.AUTO);

        Representer representer = new Representer() {
            @Override protected Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException {
                Set<Property> properties = super.getProperties(type);
                Property parentProperty = null;
View Full Code Here

* @see <a
*      href="http://code.google.com/p/snakeyaml/issues/detail?id=52">Issue</a>
*/
public class LineBreakDooubleQuotedTest extends TestCase {
    public void testDoubleQuotedStyle() {
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
        options.setWidth(20);
        options.setIndent(4);
        Yaml yaml = new Yaml(options);
        String etalon = "12345678901234567890\n\n123  456";
        String output = yaml.dump(etalon);
        // System.out.println(output);
        assertEquals("\"12345678901234567890\\n\\\n    \\n123  456\"\n", output);
View Full Code Here

        }
    }

    public void save() throws IOException {
        FileWriter writer = new FileWriter(getConfigFile());
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(FlowStyle.AUTO);
        options.setIndent(4);
        Representer representer = new Representer();
        representer.getPropertyUtils().setBeanAccess(BeanAccess.DEFAULT);
        new Yaml(options).dump(this, writer);
    }
View Full Code Here

    /**
     * test block style
     */
    public void testBoolOutAsEmpty3() {
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(FlowStyle.BLOCK);
        Yaml yaml = new Yaml(new NullRepresenter(), options);
        Map<String, String> map = new HashMap<String, String>();
        map.put("aaa", "foo");
        map.put("bbb", null);
        String output = yaml.dump(map);
View Full Code Here

        if (!dirty) {
            logger.info("Object map is not modified. Skipping save.");
            return;
        }
        try {
            DumperOptions options = new DumperOptions();
            options.setIndent(4);
            options.setDefaultFlowStyle(FlowStyle.AUTO);

            Representer representer = new Representer() {
                @Override protected Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException {
                    Set<Property> properties = super.getProperties(type);
                    Property parentProperty = null;
View Full Code Here

        assertEquals(etalon, yaml.dump(person));
        assertEquals(etalon, yaml.dump(person));
    }

    public void test2beans() {
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        Person person = new Person("Alan", "Gutierrez", 9);
        String etalon = "!!org.yaml.snakeyaml.issues.issue8.Person {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
        assertEquals(etalon, yaml.dump(person));
        Horse horse = new Horse("Tom", person);
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.