Examples of addTypeDescription()


Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        Constructor constructor = new Constructor(Human_WithArrayOfChildren.class);
        TypeDescription HumanWithChildrenArrayDescription = new TypeDescription(
                Human_WithArrayOfChildren.class);
        HumanWithChildrenArrayDescription.putListPropertyType("children",
                Human_WithArrayOfChildren.class);
        constructor.addTypeDescription(HumanWithChildrenArrayDescription);
        Yaml yaml = new Yaml(constructor);
        String doc = Util.getLocalResource("recursive/with-childrenArray-no-root-tag.yaml");
        Human_WithArrayOfChildren son2 = (Human_WithArrayOfChildren) yaml.load(doc);
        checkSon(son2);
    }
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        customerAB.bGeneral = general;

        Constructor constructor = new Constructor();
        Representer representer = new Representer();
        Tag generalAccountTag = new Tag("!GA");
        constructor
                .addTypeDescription(new TypeDescription(GeneralAccount.class, generalAccountTag));
        representer.addClassTag(GeneralAccount.class, generalAccountTag);

        Yaml yaml = new Yaml(constructor, representer);
        String dump = yaml.dump(customerAB);
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        Constructor constructor = new Constructor();
        Representer representer = new Representer();

        Tag generalAccountTag = new Tag("!GA");
        constructor
                .addTypeDescription(new TypeDescription(GeneralAccount.class, generalAccountTag));
        representer.addClassTag(GeneralAccount.class, generalAccountTag);

        Yaml yaml = new Yaml(constructor, representer);
        String dump = yaml.dump(customerAB_property);
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        // System.out.println(output);
        assertEquals("!mybean {age: -47, color: Violet, name: Bahrack, type: Type3}\n", output);
        // parse back to instance
        Constructor constr = new Constructor();
        TypeDescription description = new TypeDescription(Wrapper.class, new Tag("!mybean"));
        constr.addTypeDescription(description);
        yaml = new Yaml(constr);
        Wrapper wrapper = (Wrapper) yaml.load(output);
        JavaBeanWithStaticState bean2 = wrapper.createBean();
        assertEquals(-47, bean2.getAge());
        assertEquals("Bahrack", bean2.getName());
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

    public void testLoadEnumBean2() {
        Constructor c = new Constructor();
        TypeDescription td = new TypeDescription(EnumBean.class);
        td.putMapPropertyType("map", Suit.class, Object.class);
        c.addTypeDescription(td);
        Yaml yaml = new Yaml(c);
        EnumBean bean = (EnumBean) yaml
                .load("!!org.yaml.snakeyaml.EnumBean\nid: 174\nmap:\n  CLUBS: 1\n  DIAMONDS: 2\nsuit: CLUBS");

        LinkedHashMap<Suit, Integer> map = new LinkedHashMap<Suit, Integer>();
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        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();
        assertEquals(0, bean.getProperty1());
        assertEquals("aaa", bean.getProperty2());
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        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();
        assertEquals(0, bean1.getProperty1());
        assertEquals("aaa", bean1.getProperty2());
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        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();
        assertEquals(0, bean1.getProperty1());
        assertEquals("aaa", bean1.getProperty2());
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        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);
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

    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
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.