Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.TypeDescription


    public void testMain() {
        Map<String, String> config = new HashMap<String, String>();
        config.put("user.home", "HOME");
        Constructor constructor = new ConfigurationConstructor(config);
        constructor.addTypeDescription(new TypeDescription(TestBean.class, "!testbean"));
        Yaml yaml = new Yaml(constructor);
        yaml.addImplicitResolver(CFG, Pattern.compile("\\$\\([a-zA-Z\\d\\u002E\\u005F]+\\)"), "$");
        TestBean bean = (TestBean) yaml.load("!testbean {myval: !cfg $(user.home)}");
        // System.out.println(bean.toString());
        assertEquals("Explicit tag must be respected", "HOME", bean.getMyval());
View Full Code Here


        Yaml beanDumper = new Yaml();
        String output = beanDumper.dumpAsMap(son);
        // System.out.println(output);
        String etalon = Util.getLocalResource("recursive/with-children.yaml");
        assertEquals(etalon, output);
        TypeDescription humanDescription = new TypeDescription(Human.class);
        humanDescription.putMapPropertyType("children", Human.class, Object.class);
        Yaml beanLoader = new Yaml(new Constructor(humanDescription));
        //
        Human son2 = beanLoader.loadAs(output, Human.class);
        assertNotNull(son2);
        assertEquals("Son", son.getName());
View Full Code Here

public class GlobalDirectivesTest extends TestCase {
    public void testOneDocument() {
        String input = Util.getLocalResource("issues/issue149-one-document.yaml");
        // System.out.println(input);
        Constructor constr = new Constructor();
        TypeDescription description = new TypeDescription(ComponentBean.class, new Tag(
                "tag:ualberta.ca,2012:29"));
        constr.addTypeDescription(description);
        Yaml yaml = new Yaml(constr);
        Iterator<Object> parsed = yaml.loadAll(input).iterator();
        ComponentBean bean = (ComponentBean) parsed.next();
View Full Code Here

    public void testDirectives() {
        String input = Util.getLocalResource("issues/issue149-losing-directives.yaml");
        // System.out.println(input);
        Constructor constr = new Constructor();
        TypeDescription description = new TypeDescription(ComponentBean.class, new Tag(
                "tag:ualberta.ca,2012:" + 29));
        constr.addTypeDescription(description);
        Yaml yaml = new Yaml(constr);
        Iterator<Object> parsed = yaml.loadAll(input).iterator();
        ComponentBean bean1 = (ComponentBean) parsed.next();
View Full Code Here

    public void testDirectives2() {
        String input = Util.getLocalResource("issues/issue149-losing-directives-2.yaml");
        // System.out.println(input);
        Constructor constr = new Constructor();
        TypeDescription description = new TypeDescription(ComponentBean.class, new Tag(
                "tag:ualberta.ca,2012:" + 29));
        constr.addTypeDescription(description);
        Yaml yaml = new Yaml(constr);
        Iterator<Object> parsed = yaml.loadAll(input).iterator();
        ComponentBean bean1 = (ComponentBean) parsed.next();
View Full Code Here

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

    private TestObject parseObject(String input) {
        Constructor con = new Constructor(TestObject.class);
        con.addTypeDescription(new TypeDescription(TestObject.class,
                "!ruby/object:Test::Module::Object"));
        con.addTypeDescription(new TypeDescription(Sub1.class, "!ruby/object:Test::Module::Sub1"));
        con.addTypeDescription(new TypeDescription(Sub2.class, "!ruby/object:Test::Module::Sub2"));

        Yaml yaml = new Yaml(con);
        return (TestObject) yaml.load(input);
    }
View Full Code Here

        assert is != null;

        try
        {
            final Constructor constructor = new Constructor(CliUserHelp.class);
            TypeDescription desc = new TypeDescription(CliUserHelp.class);
            desc.putListPropertyType("commands", CliCommandHelp.class);
            final Yaml yaml = new Yaml(new Loader(constructor));
            return (CliUserHelp) yaml.load(is);
        }
        finally
        {
View Full Code Here

        assert is != null;

        try
        {
            final Constructor constructor = new Constructor(CliUserHelp.class);
            TypeDescription desc = new TypeDescription(CliUserHelp.class);
            desc.putListPropertyType("commands", CliCommandHelp.class);
            final Yaml yaml = new Yaml(new Loader(constructor));
            return (CliUserHelp)yaml.load(is);
        }
        finally
        {
View Full Code Here

        assert is != null;

        try
        {
            final Constructor constructor = new Constructor(NodeToolHelp.class);
            TypeDescription desc = new TypeDescription(NodeToolHelp.class);
            desc.putListPropertyType("commands", NodeToolHelp.NodeToolCommand.class);
            final Yaml yaml = new Yaml(new Loader(constructor));
            return (NodeToolHelp)yaml.load(is);
        }
        finally
        {
View Full Code Here

            {
                // getStorageConfigURL should have ruled this out
                throw new AssertionError(e);
            }
            org.yaml.snakeyaml.constructor.Constructor constructor = new org.yaml.snakeyaml.constructor.Constructor(Config.class);
            TypeDescription seedDesc = new TypeDescription(SeedProviderDef.class);
            seedDesc.putMapPropertyType("parameters", String.class, String.class);
            constructor.addTypeDescription(seedDesc);
            Yaml yaml = new Yaml(new Loader(constructor));
            conf = (Config)yaml.load(input);

            if (!System.getProperty("os.arch").contains("64"))
View Full Code Here

TOP

Related Classes of org.yaml.snakeyaml.TypeDescription

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.