Package org.yaml.snakeyaml.nodes

Examples of org.yaml.snakeyaml.nodes.MappingNode


        }

        private class ConstructLine extends AbstractConstruct {
            @SuppressWarnings("unchecked")
            public Object construct(Node node) {
                MappingNode mnode = (MappingNode) node;
                Map<Object, Object> values = constructMapping(mnode);
                Line line = new Line((Map<String, Integer>) values.get("start"),
                        (Map<String, Integer>) values.get("finish"));
                return line;
            }
View Full Code Here


        }

        private class ConstructLabel extends AbstractConstruct {
            @SuppressWarnings("unchecked")
            public Object construct(Node node) {
                MappingNode mnode = (MappingNode) node;
                Map<Object, Object> values = constructMapping(mnode);
                Label label = new Label((Map<String, Integer>) values.get("start"),
                        (Integer) values.get("color"), (String) values.get("text"));
                return label;
            }
View Full Code Here

        }
    }

    public void testComposeFromReader() {
        Yaml yaml = new Yaml();
        MappingNode node = (MappingNode) yaml.compose(new StringReader("abc: 56"));
        ScalarNode node1 = (ScalarNode) node.getValue().get(0).getKeyNode();
        assertEquals("abc", node1.getValue());
        ScalarNode node2 = (ScalarNode) node.getValue().get(0).getValueNode();
        assertEquals("56", node2.getValue());
    }
View Full Code Here

                if (seq.getValue().isEmpty()) {
                    return null; // skip empty lists
                }
            }
            if (Tag.MAP.equals(valueNode.getTag())) {
                MappingNode seq = (MappingNode) valueNode;
                if (seq.getValue().isEmpty()) {
                    return null; // skip empty maps
                }
            }
        }
        return tuple;
View Full Code Here

            try
            {
                Field value = tuple.getClass().getDeclaredField("valueNode");
                value.setAccessible(true);
                Node valueNode = tuple.getValueNode();
                MappingNode mappingNode = new MappingNode(Tag.MAP, false, new ArrayList<NodeTuple>(),
                                                          valueNode.getStartMark(), valueNode.getEndMark(), false);
                value.set(tuple, mappingNode);
                return mappingNode;
            }
            catch (Exception e)
View Full Code Here

                if (actionName == null)
                {
                    for (Map.Entry<String, Node> actionEntry : actionNodes.entrySet())
                    {
                        currentAction = actionEntry.getKey();
                        MappingNode templateNode = cloneTemplate(ref, TemplateType.TRAIT);
                        if (templateNode != null)
                        {
                            mergeNodes(actionEntry.getValue(), templateNode, new MergeContext(Action.class, templateNode.getTag()));
                        }
                    }
                }
                else
                {
                    currentAction = actionName;
                    MappingNode templateNode = cloneTemplate(ref, TemplateType.TRAIT);
                    if (templateNode != null)
                    {
                        mergeNodes(actionNodes.get(actionName), templateNode, new MergeContext(Action.class, templateNode.getTag()));
                    }
                }
            }
        }
View Full Code Here

                templateMap = getTraitsMap();
                label = "trait";
                defaultParameters.put("methodName", currentAction);
            }

            MappingNode templateNode = templateMap.get(templateName);
            if (templateNode == null)
            {
                addError(label + " not defined: " + templateName, reference);
                return null;
            }
View Full Code Here

                }
                Node key = cloneScalarNode((ScalarNode) tuple.getKeyNode(), parameters);
                Node value = cloneNode(tuple.getValueNode(), parameters);
                tuples.add(new NodeTuple(key, value));
            }
            return new MappingNode(node.getTag(), tuples, node.getFlowStyle());
        }
View Full Code Here

            result.add(new DefaultSuggestion(RamlEmitter.VERSION, 0));
            return result;
        }
        Yaml yamlParser = new Yaml();
        NodeVisitor nodeVisitor = new NodeVisitor(this, new DefaultResourceLoader());
        MappingNode rootNode = null;
        Node compose = yamlParser.compose(new StringReader(suggestRaml));
        if (compose != null && compose.getNodeId() == NodeId.mapping)
        {
            rootNode = (MappingNode) compose;
        }
View Full Code Here

    public boolean onTupleStart(NodeTuple nodeTuple)
    {
        try
        {
            builder.onTupleStart(nodeTuple);
            MappingNode mapping = nodeTuple.getValueNode().getNodeId() == NodeId.mapping ? (MappingNode) nodeTuple.getValueNode() : null;
            pushNode(nodeTuple.getKeyNode(), mapping);
        }
        catch (Exception e)
        {
            return false;
View Full Code Here

TOP

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

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.