Package org.yaml.snakeyaml

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


        item.put("modifiers", sh.getModifiers());
        item.put("commands", sh.getCommands());
        item.put("delay", sh.getDelay());
        shsave.add(item);
      }
      yaml.dump(shsave, writer);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here


        representer.addClassTag(ColumnDefinition.class, Tag.MAP);
        Dumper dumper = new Dumper(representer, options);
        Yaml yaml = new Yaml(dumper);
        Keyspaces ks = new Keyspaces();
        ks.keyspaces = keyspaces;
        return yaml.dump(ks);
    }
   
    public class Keyspaces
    {
        public List<RawKeyspace> keyspaces;
View Full Code Here

        Map<String, Object> data = new HashMap<String, Object>();
        data.put("name", "Silenthand Olleander");
        data.put("race", "Human");
        data.put("traits", new String[] { "ONE_HAND", "ONE_EYE" });
        Yaml yaml = new Yaml();
        String output = yaml.dump(data);
        assertTrue(output.contains("name: Silenthand Olleander"));
        assertTrue(output.contains("race: Human"));
        assertTrue(output.contains("traits: [ONE_HAND, ONE_EYE]"));
    }
View Full Code Here

        data.put("name", "Silenthand Olleander");
        data.put("race", "Human");
        data.put("traits", new String[] { "ONE_HAND", "ONE_EYE" });
        Yaml yaml = new Yaml();
        StringWriter writer = new StringWriter();
        yaml.dump(data, writer);
        assertTrue(writer.toString().contains("name: Silenthand Olleander"));
        assertTrue(writer.toString().contains("race: Human"));
        assertTrue(writer.toString().contains("traits: [ONE_HAND, ONE_EYE]"));
    }
View Full Code Here

    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);
    }

    public void testDumperOptions() {
        List<Integer> data = new ArrayList<Integer>();
View Full Code Here

        List<Integer> data = new ArrayList<Integer>();
        for (int i = 0; i < 50; i++) {
            data.add(i);
        }
        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);
View Full Code Here

        //
        DumperOptions options = new DumperOptions();
        options.setWidth(50);
        options.setIndent(4);
        yaml = new Yaml(options);
        output = yaml.dump(data);
        assertTrue(output.contains("1, 2"));
    }

    public void testDumperOptionsCanonical() {
        List<Integer> data = new ArrayList<Integer>();
View Full Code Here

    public void testAsStandalone() {
        Parameterized<Integer> parm = new Parameterized<Integer>();
        parm.t = 3;
        Yaml yaml = new Yaml();
        String result = yaml.dump(parm);
        assertEquals("!!org.yaml.snakeyaml.issues.issue115.Parameterized {t: 3}\n", result);
        @SuppressWarnings("unchecked")
        // load
        Parameterized<Integer> parmParsed = (Parameterized<Integer>) yaml.load(result);
        assertEquals(new Integer(3), parmParsed.t);
View Full Code Here

        Yaml yaml = new Yaml();
        Issue issue = new Issue();
        Parameterized<Integer> parm = new Parameterized<Integer>();
        parm.t = 555;
        issue.parm = parm;
        String result = yaml.dump(issue);
        assertEquals("!!org.yaml.snakeyaml.issues.issue115.Issue\nparm: {t: 555}\n", result);
        // load
        Issue issueParsed = (Issue) yaml.load(result);
        assertEquals(new Integer(555), issueParsed.parm.t);
    }
View Full Code Here

    public void testTemplate1() throws Exception {
        VelocityContext context = new VelocityContext();
        MyBean bean = createBean();
        context.put("bean", bean);
        Yaml yaml = new Yaml();
        context.put("list", yaml.dump(bean.getList()));
        VelocityEngine ve = new VelocityEngine();
        ve.setProperty("file.resource.loader.class", ClasspathResourceLoader.class.getName());
        ve.init();
        Template t = ve.getTemplate("template/mybean1.vm");
        StringWriter writer = new StringWriter();
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.