Package org.yaml.snakeyaml.nodes

Examples of org.yaml.snakeyaml.nodes.Tag


    class RepresentColor implements Represent {

        public Node representData(Object data) {
            java.awt.Color color = (java.awt.Color) data;
            return representSequence(
                    getTag(data.getClass(), new Tag(data.getClass())),
                    Arrays.asList(new Integer[] { color.getRed(), color.getGreen(),
                            color.getBlue(), color.getAlpha() }), true);
        }
View Full Code Here


import org.yaml.snakeyaml.nodes.Tag;

public class ResolverTupleTest extends TestCase {

    public void testToString() {
        ResolverTuple tuple = new ResolverTuple(new Tag("dice"), Pattern.compile("\\d+"));
        assertEquals("Tuple tag=dice regexp=\\d+", tuple.toString());
    }
View Full Code Here

        assertEquals((byte) 'F', picture[2]);
    }

    class SomethingConstructor extends Constructor {
        public SomethingConstructor() {
            this.yamlConstructors.put(new Tag("!something"), new ConstructSomething());
        }
View Full Code Here

    @SuppressWarnings("unchecked")
    public void testAddImplicitResolver() {
        Yaml yaml = new Yaml(new MyConstructor(), new MyRepresenter());
        Pattern regexp = Pattern.compile("\\d\\d-\\d\\d-\\d\\d\\d");
        yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Phone"), regexp, "0123456789");
        Phone phone1 = new Phone("12-34-567");
        Phone phone2 = new Phone("11-22-333");
        Phone phone3 = new Phone("44-55-777");
        List<Phone> etalonList = new ArrayList<Phone>();
        etalonList.add(phone1);
View Full Code Here

    }

    public void testAddImplicitResolver2() {
        Yaml yaml = new Yaml(new PointRepresenter());
        Pattern regexp = Pattern.compile("\\d\\d-\\d\\d-\\d\\d\\d");
        yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Phone"), regexp, "\0");
        Pattern regexp2 = Pattern.compile("x\\d_y\\d");
        // try any scalar, and not only those which start with 'x'
        yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Point"), regexp2, null);
        Map<String, Object> map = new LinkedHashMap<String, Object>();
        map.put("a", new Phone("12-34-567"));
        map.put("b", new Point(1, 5));
        String output = yaml.dump(map);
        assertEquals("{a: 12-34-567, b: x1_y5}\n", output);
View Full Code Here

        private class RepresentPhone implements Represent {
            public Node representData(Object data) {
                Phone phone = (Phone) data;
                String value = phone.getNumber();
                return representScalar(new Tag(Tag.PREFIX + "Phone"), value);
            }
View Full Code Here

        }
    }

    class MyConstructor extends Constructor {
        public MyConstructor() {
            this.yamlConstructors.put(new Tag(Tag.PREFIX + "Phone"), new ConstructPhone());
        }
View Full Code Here

        private class RepresentPoint implements Represent {
            public Node representData(Object data) {
                Point phone = (Point) data;
                String value = "x" + (int) phone.getX() + "_y" + (int) phone.getY();
                return representScalar(new Tag(Tag.PREFIX + "Point"), value);
            }
View Full Code Here

        private class RepresentPhone implements Represent {
            public Node representData(Object data) {
                Phone phone = (Phone) data;
                String value = phone.getNumber();
                return representScalar(new Tag(Tag.PREFIX + "Phone"), value);
            }
View Full Code Here

public class TypeDescriptionTest extends TestCase {

    public void testSetTag() {
        TypeDescription descr = new TypeDescription(TypeDescriptionTest.class);
        descr.setTag("!bla");
        assertEquals(new Tag("!bla"), descr.getTag());
        descr.setTag(new Tag("!foo"));
        assertEquals(new Tag("!foo"), descr.getTag());
    }
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.