Package org.yaml.snakeyaml.nodes

Examples of org.yaml.snakeyaml.nodes.Node


    // Code borrowed from snakeyaml (http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBeanTest.java)
    @Override
    protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, Tag customTag) {
        NodeTuple tuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
        Node valueNode = tuple.getValueNode();
        if (valueNode instanceof CollectionNode) {
            // Removed null check
            if (Tag.SEQ.equals(valueNode.getTag())) {
                SequenceNode seq = (SequenceNode) valueNode;
                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
                }
            }
View Full Code Here


                    fail("The value of the !select-engine tag must be a map" + "\nGot: " + node);
                }
                String matchingKey = null;
                Object result = null;
                for(NodeTuple tuple : ((MappingNode)node).getValue()) {
                    Node keyNode = tuple.getKeyNode();
                    if(!(keyNode instanceof ScalarNode)) {
                        fail("The key in a !select-engine map must be a scalar" + "\nGot: " + constructObject(keyNode));
                    }
                    String key = ((ScalarNode)keyNode).getValue();
                    if(IT_ENGINE.equals(key) || (matchingKey == null && ALL_ENGINE.equals(key))) {
View Full Code Here

    // Code borrowed from snakeyaml (http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBeanTest.java)
    @Override
    protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, Tag customTag) {
        NodeTuple tuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
        Node valueNode = tuple.getValueNode();
        if (valueNode instanceof CollectionNode) {
            // Removed null check
            if (Tag.SEQ.equals(valueNode.getTag())) {
                SequenceNode seq = (SequenceNode) valueNode;
                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
                }
            }
View Full Code Here

        MappingNode node = new MappingNode(tag, value, flowStyle);
        representedObjects.put(objectToRepresent, node);
        boolean bestStyle = true;
        for (Object itemKey : mapping.keySet()) {
            Object itemValue = mapping.get(itemKey);
            Node nodeKey = representData(itemKey);
            Node nodeValue = representData(itemValue);

            // If the node value is null (see above) then skip
            if (nodeValue == null) {
                continue;
            }
View Full Code Here

            if ( representedObjects.containsKey( memberValue ) )
            {
                // the first occurrence of the node must keep the tag
                hasAlias = true;
            }
            Node nodeValue = representData( memberValue );

            // TODO: The impl seems not to allow to skip certain values
            if ( nodeValue == null )
            {
                continue;
            }

            // if possible try to avoid a global tag with a class name
            if ( nodeValue instanceof MappingNode && !hasAlias )
            {
                // the node is a map, set or JavaBean
                if ( !Map.class.isAssignableFrom( memberValue.getClass() ) )
                {
                    // the node is set or JavaBean
                    if ( property.getType() == memberValue.getClass() )
                    {
                        // we do not need global tag because the property
                        // Class is the same as the runtime class
                        nodeValue.setTag( Tags.MAP );
                    }
                }
            }
            else if ( memberValue != null && Enum.class.isAssignableFrom( memberValue.getClass() ) )
            {
                nodeValue.setTag( Tags.STR );
            }
            if ( nodeKey.getStyle() != null )
            {
                bestStyle = false;
            }
View Full Code Here

            }
            catch ( IntrospectionException e )
            {
                throw new YAMLException( e );
            }
            Node node = representJavaBean( properties, data );
            return node;
        }
View Full Code Here

TOP

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

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.