Package org.yaml.snakeyaml.nodes

Examples of org.yaml.snakeyaml.nodes.Tag


        }
    }

    protected class RepresentEnum implements Represent {
        public Node representData(Object data) {
            Tag tag = new Tag(data.getClass());
            return representScalar(getTag(data.getClass(), tag), ((Enum<?>) data).name());
        }
View Full Code Here


        //
        String carYaml1 = new Yaml().dump(car);
        assertTrue(carYaml1.startsWith("!!org.yaml.snakeyaml.constructor.Car"));
        //
        Representer representer = new Representer();
        representer.addClassTag(Car.class, new Tag("!car"));
        yaml = new Yaml(representer);
        String carYaml2 = yaml.dump(car);
        assertEquals(Util.getLocalResource("constructor/car-without-tags.yaml"), carYaml2);
    }
View Full Code Here

            // define tags which begin with !org.yaml.
            String prefix = "!org.yaml.";
            this.yamlMultiConstructors.put(prefix, new PrefixConstruct(prefix,
                    CustomConstructor.this));
            this.yamlConstructors.put(null, new ConstructUnknown(CustomConstructor.this));
            this.yamlConstructors.put(new Tag("!org.yaml.Exact"), new ExactConstruct(
                    CustomConstructor.this));
        }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void testJavaBeanWithTypeDescription() {
        Constructor c = new CustomBeanConstructor();
        TypeDescription descr = new TypeDescription(CodeBean.class, new Tag(
                "!de.oddb.org,2007/ODDB::Util::Code"));
        c.addTypeDescription(descr);
        Yaml yaml = new Yaml(c);
        String input = Util.getLocalResource("issues/issue56-1.yaml");
        int counter = 0;
View Full Code Here

            String prefix = "!de.oddb.org,2007/ODDB";
            this.yamlMultiConstructors.put(prefix, new ConstructYamlMap());
        }

        protected Construct getConstructor(Node node) {
            if (node.getTag().equals(new Tag("!de.oddb.org,2007/ODDB::Util::Code"))) {
                node.setUseClassConstructor(true);
                node.setType(CodeBean.class);
            }
            return super.getConstructor(node);
        }
View Full Code Here

            wheel.setId(i);
            wheels.add(wheel);
        }
        car.setWheels(wheels);
        Representer representer = new Representer();
        representer.addClassTag(Car.class, new Tag("!car"));
        representer.addClassTag(Wheel.class, Tag.MAP);
        Yaml yaml = new Yaml(representer);
        String output = yaml.dump(car);
        assertEquals(Util.getLocalResource("constructor/car-without-tags.yaml"), output);
    }
View Full Code Here

     *            new tag to be used for every instance of the specified
     *            <code>Class</code>
     * @return the previous tag associated with the <code>Class</code>
     */
    public Tag addClassTag(Class<? extends Object> clazz, String tag) {
        return addClassTag(clazz, new Tag(tag));
    }
View Full Code Here

    public static Pattern MULTILINE_PATTERN = Pattern.compile("\n|\u0085|\u2028|\u2029");

    protected class RepresentString implements Represent {
        public Node representData(Object data) {
            Tag tag = Tag.STR;
            Character style = null;
            String value = data.toString();
            if (StreamReader.NON_PRINTABLE.matcher(value).find()) {
                tag = Tag.BINARY;
                char[] binary;
View Full Code Here

        }
    }

    protected class RepresentNumber implements Represent {
        public Node representData(Object data) {
            Tag tag;
            String value;
            if (data instanceof Byte || data instanceof Short || data instanceof Integer
                    || data instanceof Long || data instanceof BigInteger) {
                tag = Tag.INT;
                value = data.toString();
View Full Code Here

    public void testDumpCustomTag() {
        Académico obj = new Académico();
        obj.setId(123);
        obj.setName("Foo bar 123");
        Representer repr = new Representer();
        repr.addClassTag(Académico.class, new Tag("!foo"));
        Yaml yaml = new Yaml(repr);
        String result = yaml.dump(obj);
        assertEquals("!foo {id: 123, name: Foo bar 123}\n", result);
    }
View Full Code Here

TOP

Related Classes of org.yaml.snakeyaml.nodes.Tag

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.