当前位置: 首页>>代码示例>>Java>>正文


Java MappingNode.getValue方法代码示例

本文整理汇总了Java中org.yaml.snakeyaml.nodes.MappingNode.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java MappingNode.getValue方法的具体用法?Java MappingNode.getValue怎么用?Java MappingNode.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.yaml.snakeyaml.nodes.MappingNode的用法示例。


在下文中一共展示了MappingNode.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constructSet2ndStep

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
protected void constructSet2ndStep(MappingNode node, Set<Object> set) {
    List<NodeTuple> nodeValue = (List<NodeTuple>) node.getValue();
    for (NodeTuple tuple : nodeValue) {
        Node keyNode = tuple.getKeyNode();
        Object key = constructObject(keyNode);
        if (key != null) {
            try {
                key.hashCode();// check circular dependencies
            } catch (Exception e) {
                throw new ConstructorException("while constructing a Set", node.getStartMark(),
                        "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e);
            }
        }
        if (keyNode.isTwoStepsConstruction()) {
            /*
             * if keyObject is created it 2 steps we should postpone putting
             * it into the set because it may have different hash after
             * initialization compared to clean just created one. And set of
             * course does not observe value hashCode changes.
             */
            sets2fill.add(0, new RecursiveTuple<Set<Object>, Object>(set, key));
        } else {
            set.add(key);
        }
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:27,代码来源:BaseConstructor.java

示例2: constructSet2ndStep

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
protected void constructSet2ndStep(MappingNode node, Set<Object> set) {
    List<NodeTuple> nodeValue = node.getValue();
    for (NodeTuple tuple : nodeValue) {
        Node keyNode = tuple.getKeyNode();
        Object key = constructObject(keyNode);
        if (key != null) {
            try {
                key.hashCode();// check circular dependencies
            } catch (Exception e) {
                throw new ConstructorException("while constructing a Set", node.getStartMark(),
                        "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e);
            }
        }
        if (keyNode.isTwoStepsConstruction()) {
            /*
             * if keyObject is created it 2 steps we should postpone putting
             * it into the set because it may have different hash after
             * initialization compared to clean just created one. And set of
             * course does not observe value hashCode changes.
             */
            sets2fill.add(0, new RecursiveTuple<Set<Object>, Object>(set, key));
        } else {
            set.add(key);
        }
    }
}
 
开发者ID:RoccoDev,项目名称:5zig-TIMV-Plugin,代码行数:27,代码来源:BaseConstructor.java

示例3: getMap

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <K, T, M extends Map<K, T>> void getMap(String key, Function<String, K> keyMapper, Class<T> type, M map)
{
    Node node = this.getNode(this.node, key);
    if (! (node instanceof MappingNode))
    {
        throw new DeserializationException(type, this, "Can't find valid value for key: " + key);
    }
    MappingNode mappingNode = (MappingNode) node;
    Tag typeTag = new Tag(type);
    for (NodeTuple tuple : mappingNode.getValue())
    {
        Node keyNode = tuple.getKeyNode();
        keyNode.setTag(Tag.STR);
        K keyObj = keyMapper.apply(this.constructor.constructObject(keyNode).toString());

        Node valueNode = tuple.getValueNode();
        if (type != Object.class)
        {
            valueNode.setTag(typeTag);
        }

        map.put(keyObj, (T) this.constructor.constructObject(valueNode));
    }
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:27,代码来源:YamlDeserializationData.java

示例4: constructMapping2ndStep

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
@Override
protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) {
    List<NodeTuple> nodeValue = (List<NodeTuple>) node.getValue();
    for (NodeTuple tuple : nodeValue) {
        Node keyNode = tuple.getKeyNode();
        Node valueNode = tuple.getValueNode();
        Object key = constructObject(keyNode);
        if (key != null) {
            key.hashCode();// check circular dependencies
        }
        Object value = constructObject(valueNode);
        Object old = mapping.put(key, value);
        if (old != null) {
            throw new YAMLException("The key is not unique " + key);
        }
    }
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:18,代码来源:UniqueKeyTest.java

示例5: construct

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Car construct(Node node) {
    Car car = new Car();
    MappingNode mapping = (MappingNode) node;
    List<NodeTuple> list = mapping.getValue();
    for (NodeTuple tuple : list) {
        String field = toScalarString(tuple.getKeyNode());
        if ("plate".equals(field)) {
            car.setPlate(toScalarString(tuple.getValueNode()));
        }
        if ("wheels".equals(field)) {
            SequenceNode snode = (SequenceNode) tuple.getValueNode();
            List<Wheel> wheels = (List<Wheel>) constructSequence(snode);
            car.setWheels(wheels);
        }
    }
    return car;
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:19,代码来源:YamlLoadAsIssueTest.java

示例6: getSingleNode

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
@Override
public Node getSingleNode() {
    Node node = super.getSingleNode();
    if (!MappingNode.class.isAssignableFrom(node.getClass())) {
        throw new RuntimeException(
                "Document is not structured as expected.  Root element should be a map!");
    }
    MappingNode root = (MappingNode) node;
    for (NodeTuple tuple : root.getValue()) {
        Node keyNode = tuple.getKeyNode();
        if (ScalarNode.class.isAssignableFrom(keyNode.getClass())) {
            if (((ScalarNode) keyNode).getValue().equals(nodeName)) {
                return tuple.getValueNode();
            }
        }
    }
    throw new RuntimeException("Did not find key \"" + nodeName + "\" in document-level map");
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:19,代码来源:FragmentComposer.java

示例7: loadYamlLookupSets

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
private void loadYamlLookupSets(MappingNode entry, String filename) {
//        LOG.info("Loading lookupSet.({}:{})", filename, entry.getStartMark().getLine());
        String name = null;
        Set<String> lookupSet = new HashSet<>();

        for (NodeTuple tuple : entry.getValue()) {
            switch (getKeyAsString(tuple, filename)) {
                case "name":
                    name = getValueAsString(tuple, filename);
                    break;
                case "values":
                    SequenceNode node = getValueAsSequenceNode(tuple, filename);
                    List<String> values = getStringValues(node, filename);
                    for (String value: values) {
                        lookupSet.add(value.toLowerCase(Locale.ENGLISH));
                    }
                    break;
                default:
                    break;
            }
        }

        lookupSets.put(name, lookupSet);
    }
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:25,代码来源:UserAgentAnalyzerDirect.java

示例8: calculatePositions

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
protected List<Position> calculatePositions(MappingNode mapping) {
    List<Position> positions = new ArrayList<>();
    int start;
    int end = -1;

    for (NodeTuple tuple : mapping.getValue()) {
        start = tuple.getKeyNode().getStartMark().getLine();
        end = tuple.getValueNode().getEndMark().getLine();

        if ((end - start) > 0) {
            try {
                int startOffset = document.getLineOffset(start);
                int endOffset = document.getLineOffset(end);

                positions.add(new Position(startOffset, (endOffset - startOffset)));
            } catch (BadLocationException e) {
            }
        }

        if (tuple.getValueNode() instanceof MappingNode) {
            positions.addAll(calculatePositions((MappingNode) tuple.getValueNode()));
        }
    }

    return positions;
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:27,代码来源:JsonReconcilingStrategy.java

示例9: typeCheck

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
@Override
public void typeCheck(Node node) throws ConfigTypeErrorException {
    if (YamlUtils.isNull(node)) {
        return;
    }
    if (!(node instanceof MappingNode)) {
        throw new ConfigTypeErrorException(node, format("Expected %s, found %s",
                configInterface.getCanonicalName(),
                node.getNodeId()));
    }
    MappingNode mNode = (MappingNode)node;
    for (NodeTuple field : mNode.getValue()) {
        String key = key(field);
        if (!fields.containsKey(key)) {
            throw new ConfigTypeErrorException(field.getKeyNode(), format("Unknown field: %s", key));
        }
        typeCheckField(field);
    }
    typeCheckMethods(mNode, mNode.getValue());
}
 
开发者ID:wtetzner,项目名称:kurgan,代码行数:21,代码来源:ConfigInterface.java

示例10: constructSet2ndStep

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
protected void constructSet2ndStep(final MappingNode node, final Set<Object> set) {
	List<NodeTuple> nodeValue = node.getValue();
	for (NodeTuple tuple : nodeValue) {
		Node keyNode = tuple.getKeyNode();
		Object key = constructObject(keyNode);
		if (key != null) {
			try {
				key.hashCode();// check circular dependencies
			} catch (Exception e) {
				throw new ConstructorException("while constructing a Set", node.getStartMark(), "found unacceptable key " + key, tuple
						.getKeyNode().getStartMark(), e);
			}
		}
		if (keyNode.isTwoStepsConstruction()) {
			/*
			 * if keyObject is created it 2 steps we should postpone putting
			 * it into the set because it may have different hash after
			 * initialization compared to clean just created one. And set of
			 * course does not observe value hashCode changes.
			 */
			sets2fill.add(0, new RecursiveTuple<Set<Object>, Object>(set, key));
		} else {
			set.add(key);
		}
	}
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:27,代码来源:BaseConstructor.java

示例11: constructMapping2ndStep

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) {
    List<NodeTuple> nodeValue = (List<NodeTuple>) node.getValue();
    for (NodeTuple tuple : nodeValue) {
        Node keyNode = tuple.getKeyNode();
        Node valueNode = tuple.getValueNode();
        Object key = constructObject(keyNode);
        if (key != null) {
            try {
                key.hashCode();// check circular dependencies
            } catch (Exception e) {
                throw new ConstructorException("while constructing a mapping",
                        node.getStartMark(), "found unacceptable key " + key, tuple
                                .getKeyNode().getStartMark(), e);
            }
        }
        Object value = constructObject(valueNode);
        if (keyNode.isTwoStepsConstruction()) {
            /*
             * if keyObject is created it 2 steps we should postpone putting
             * it in map because it may have different hash after
             * initialization compared to clean just created one. And map of
             * course does not observe key hashCode changes.
             */
            maps2fill.add(0,
                    new RecursiveTuple<Map<Object, Object>, RecursiveTuple<Object, Object>>(
                            mapping, new RecursiveTuple<Object, Object>(key, value)));
        } else {
            mapping.put(key, value);
        }
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:32,代码来源:BaseConstructor.java

示例12: constructMapping2ndStep

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) {
    List<NodeTuple> nodeValue = node.getValue();
    for (NodeTuple tuple : nodeValue) {
        Node keyNode = tuple.getKeyNode();
        Node valueNode = tuple.getValueNode();
        Object key = constructObject(keyNode);
        if (key != null) {
            try {
                key.hashCode();// check circular dependencies
            } catch (Exception e) {
                throw new ConstructorException("while constructing a mapping",
                        node.getStartMark(), "found unacceptable key " + key,
                        tuple.getKeyNode().getStartMark(), e);
            }
        }
        Object value = constructObject(valueNode);
        if (keyNode.isTwoStepsConstruction()) {
            /*
             * if keyObject is created it 2 steps we should postpone putting
             * it in map because it may have different hash after
             * initialization compared to clean just created one. And map of
             * course does not observe key hashCode changes.
             */
            maps2fill.add(0,
                    new RecursiveTuple<Map<Object, Object>, RecursiveTuple<Object, Object>>(
                            mapping, new RecursiveTuple<Object, Object>(key, value)));
        } else {
            mapping.put(key, value);
        }
    }
}
 
开发者ID:RoccoDev,项目名称:5zig-TIMV-Plugin,代码行数:32,代码来源:BaseConstructor.java

示例13: processDuplicateKeys

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
protected void processDuplicateKeys(MappingNode node) {
    List<NodeTuple> nodeValue = node.getValue();
    Map<Object, Integer> keys = new HashMap<Object, Integer>(nodeValue.size());
    Deque<Integer> toRemove = new ArrayDeque<Integer>();
    int i = 0;
    for (NodeTuple tuple : nodeValue) {
        Node keyNode = tuple.getKeyNode();
        if (!keyNode.getTag().equals(Tag.MERGE)) {
            Object key = constructObject(keyNode);
            if (key != null) {
                try {
                    key.hashCode();// check circular dependencies
                } catch (Exception e) {
                    throw new ConstructorException("while constructing a mapping",
                            node.getStartMark(), "found unacceptable key " + key,
                            tuple.getKeyNode().getStartMark(), e);
                }
            }

            Integer prevIndex = keys.put(key, i);
            if (prevIndex != null) {
                if (!isAllowDuplicateKeys()) {
                    throw new IllegalStateException("duplicate key: " + key);
                }
                toRemove.add(prevIndex);
            }
        }
        i = i + 1;
    }

    Iterator<Integer> indicies2remove = toRemove.descendingIterator();
    while (indicies2remove.hasNext()) {
        nodeValue.remove(indicies2remove.next().intValue());
    }
}
 
开发者ID:RoccoDev,项目名称:5zig-TIMV-Plugin,代码行数:36,代码来源:SafeConstructor.java

示例14: getAsCollection

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
@Override
public <T, C extends Collection<T>> void getAsCollection(String key, Class<T> type, C collection)
{
    Node node = this.getNode(this.node, key);
    if (node == null)
    {
        throw new DeserializationException(type, this, "Can't find valid value for key: " + key);
    }
    if (node instanceof SequenceNode)
    {
        SequenceNode sequenceNode = (SequenceNode) node;
        for (Node nodeValue : sequenceNode.getValue())
        {
            collection.add(this.deserializeSpecial(type, nodeValue, null));
        }
    }
    else if (node instanceof MappingNode)
    {
        MappingNode mappingNode = (MappingNode) node;
        for (NodeTuple tuple : mappingNode.getValue())
        {
            collection.add(this.deserializeSpecial(type, tuple.getValueNode(), null));
        }
    }
    else
    {
        throw new DeserializationException(type, this, "Can't find valid value for key: " + key);
    }
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:30,代码来源:YamlDeserializationData.java

示例15: representJavaBean

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
@Override
protected MappingNode representJavaBean(Set<Property> properties, Object javaBean) {
    MappingNode node = super.representJavaBean(properties, javaBean);
    if (javaBean instanceof JavaBeanWithStaticState) {
        List<NodeTuple> value = node.getValue();
        value.add(new NodeTuple(representData("color"),
                representData(JavaBeanWithStaticState.color)));
        value.add(new NodeTuple(representData("type"),
                representData(JavaBeanWithStaticState.getType())));
    }
    return node;
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:13,代码来源:StaticFieldsTest.java


注:本文中的org.yaml.snakeyaml.nodes.MappingNode.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。