Package org.yaml.snakeyaml.nodes

Examples of org.yaml.snakeyaml.nodes.Tag


    class RepresentPrimitives implements Represent {
        public Node representData(Object data) {
            BunchOfPrimitives bunch = (BunchOfPrimitives) data;
            return representSequence(
                    getTag(data.getClass(), new Tag(data.getClass())),
                    Arrays.asList(new Object[] { bunch.getPrimitiveInt(),
                            bunch.getPrimitiveDouble(), bunch.primitiveBoolean }), true);
        }
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

     * Define a local tag to ignore all the white spaces to be able to use
     * literal scalar
     */
    @SuppressWarnings("unchecked")
    public void testLocalBinaryTag() throws IOException {
        Yaml yaml = new Yaml(new SpecialContructor(new Tag("!beautiful")));
        InputStream inputStream = YamlBase64Test.class
                .getResourceAsStream("/issues/issue99-base64_literal_custom_tag.yaml");
        Map<String, Object> bean = (Map<String, Object>) yaml.load(inputStream);
        byte[] jpeg = (byte[]) bean.get("jpegPhoto");
        checkBytes(jpeg);
View Full Code Here

    public void testEmitWithTags() {
        TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
        DumperOptions options = new DumperOptions();
        options.setExplicitStart(true);
        Representer repr = new Representer();
        repr.addClassTag(TestObject.class, new Tag("!ruby/object:Test::Module::Object"));
        repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
        repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
        Yaml yaml2 = new Yaml(repr, options);
        String output = yaml2.dump(result);
        // System.out.println(output);
        assertTrue("Tags must be present.",
                output.startsWith("--- !ruby/object:Test::Module::Object"));
View Full Code Here

    public void testEmitWithTags2WithoutTagForParentJavabean() {
        TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
        DumperOptions options = new DumperOptions();
        options.setExplicitStart(true);
        Representer repr = new Representer();
        repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
        repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
        Yaml yaml2 = new Yaml(repr, options);
        String output = yaml2.dump(result);
        // System.out.println(output);
        assertTrue("Tags must be present.",
                output.startsWith("--- !!org.yaml.snakeyaml.ruby.TestObject"));
View Full Code Here

            return mockInclude(node);
        }
        //retag node with included resource info
        String markInfo = node.getStartMark().getLine() + SEPARATOR + node.getStartMark().getColumn()
                          + SEPARATOR + node.getEndMark().getColumn();
        includeNode.setTag(new Tag(INCLUDE_APPLIED_TAG + resourceName + SEPARATOR + markInfo));
        return includeNode;
    }
View Full Code Here

        if (rootNode == null)
        {
            throw new IllegalArgumentException("rootNode is null");
        }
        DumperOptions dumperOptions = new DumperOptions();
        Tag rootTag = dumperOptions.getExplicitRoot();
        Serializer serializer = new Serializer(new Emitter(output, dumperOptions), new Resolver(),
                                               dumperOptions, rootTag);
        try
        {
            serializer.open();
View Full Code Here

        for (NodeTuple nodeTuple : tuples)
        {
            Node keyNode = nodeTuple.getKeyNode();
            Node originalValueNode = nodeTuple.getValueNode();

            Tag tag = originalValueNode.getTag();
            TagResolver currentTagResolver = getTagResolver(tag);
            Node resolvedNode = resolveTag(tag, currentTagResolver, originalValueNode);
            if (originalValueNode != resolvedNode)
            {
                nodeTuple = new NodeTuple(keyNode, resolvedNode);
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.