Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.DumperOptions


   }

   public Yaml createYamlReader()
   {
      final Yaml yaml = new Yaml(new Constructor(), new Representer(), new DumperOptions(),
            new Resolver()
      {
         @Override
         protected void addImplicitResolvers()
         {
View Full Code Here


            }
            // whew.
            keyspaces.add(rks);
        }
       
        DumperOptions options = new DumperOptions();
        /* Use a block YAML arrangement */
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        SkipNullRepresenter representer = new SkipNullRepresenter();
        /* Use Tag.MAP to avoid the class name being included as global tag */
        representer.addClassTag(RawColumnFamily.class, Tag.MAP);
        representer.addClassTag(Keyspaces.class, Tag.MAP);
        representer.addClassTag(ColumnDefinition.class, Tag.MAP);
View Full Code Here

    public void testDumpMany() {
        List<Integer> docs = new ArrayList<Integer>();
        for (int i = 1; i < 4; i++) {
            docs.add(i);
        }
        DumperOptions options = new DumperOptions();
        options.setExplicitStart(true);
        Yaml yaml = new Yaml(options);
        String result = yaml.dumpAll(docs.iterator());
        assertNotNull(result);
        assertTrue(result.contains("--- 2"));
    }
View Full Code Here

        assertTrue(result.contains("--- 2"));
    }

    public void testDumpCustomJavaClass() {
        Hero hero = new Hero("Galain Ysseleg", -3, 2);
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(hero);
        assertEquals("!!examples.Hero {hp: -3, name: Galain Ysseleg, sp: 2}\n", output);
    }
View Full Code Here

        }
        Yaml yaml = new Yaml();
        String output = yaml.dump(data);
        assertTrue(output.contains("[0, 1, 2, 3, 4, 5, 6, 7, 8"));
        //
        DumperOptions options = new DumperOptions();
        options.setWidth(50);
        options.setIndent(4);
        yaml = new Yaml(options);
        output = yaml.dump(data);
        assertTrue(output.contains("1, 2"));
    }
View Full Code Here

    public void testDumperOptionsCanonical() {
        List<Integer> data = new ArrayList<Integer>();
        for (int i = 0; i < 5; i++) {
            data.add(i);
        }
        DumperOptions options = new DumperOptions();
        options.setCanonical(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(data);
        assertTrue(output.contains("---"));
        assertTrue(output.contains("!!seq ["));
        assertTrue(output.contains("!!int \"3\","));
View Full Code Here

    public void testDumperOptionsFlowStyle() {
        List<Integer> data = new ArrayList<Integer>();
        for (int i = 0; i < 5; i++) {
            data.add(i);
        }
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(data);
        assertTrue(output.contains("- 0\n"));
        assertTrue(output.contains("- 1\n"));
        assertTrue(output.contains("- 4\n"));
View Full Code Here

    public void testDumperOptionsStyle() {
        List<Integer> data = new ArrayList<Integer>();
        for (int i = 0; i < 5; i++) {
            data.add(i);
        }
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump(data);
        assertTrue(output.contains("- !!int \"0\""));
        assertTrue(output.contains("- !!int \"1\""));
        assertTrue(output.contains("- !!int \"4\""));
View Full Code Here

import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.immutable.Point;

public class VelocityTest extends TestCase {
    public void testNoTemplate() {
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dumpAsMap(createBean());
        // System.out.println(output);
        assertEquals(Util.getLocalResource("template/etalon1.yaml"), output);
    }
View Full Code Here

    }

    public void testBean2() {
        IncompleteBean bean = new IncompleteBean();
        bean.setName("lunch");
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals("id: 10\nname: lunch\n", output);
        //
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.