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


Java MappingNode.getStartMark方法代码示例

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


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

示例4: 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

示例5: construct

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
public Object construct(Node node) {
    // Note: we do not check for duplicate keys, because it's too
    // CPU-expensive.
    Map<Object, Object> omap = new LinkedHashMap<Object, Object>();
    if (!(node instanceof SequenceNode)) {
        throw new ConstructorException("while constructing an ordered map",
                node.getStartMark(), "expected a sequence, but found " + node.getNodeId(),
                node.getStartMark());
    }
    SequenceNode snode = (SequenceNode) node;
    for (Node subnode : snode.getValue()) {
        if (!(subnode instanceof MappingNode)) {
            throw new ConstructorException("while constructing an ordered map",
                    node.getStartMark(), "expected a mapping of length 1, but found "
                            + subnode.getNodeId(), subnode.getStartMark());
        }
        MappingNode mnode = (MappingNode) subnode;
        if (mnode.getValue().size() != 1) {
            throw new ConstructorException("while constructing an ordered map",
                    node.getStartMark(), "expected a single mapping item, but found "
                            + mnode.getValue().size() + " items", mnode.getStartMark());
        }
        Node keyNode = mnode.getValue().get(0).getKeyNode();
        Node valueNode = mnode.getValue().get(0).getValueNode();
        Object key = constructObject(keyNode);
        Object value = constructObject(valueNode);
        omap.put(key, value);
    }
    return omap;
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:31,代码来源:SafeConstructor.java

示例6: 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

示例7: 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

示例8: construct

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
public Object construct(Node node) {
    // Note: we do not check for duplicate keys, because it's too
    // CPU-expensive.
    Map<Object, Object> omap = new LinkedHashMap<Object, Object>();
    if (!(node instanceof SequenceNode)) {
        throw new ConstructorException("while constructing an ordered map",
                node.getStartMark(), "expected a sequence, but found " + node.getNodeId(),
                node.getStartMark());
    }
    SequenceNode snode = (SequenceNode) node;
    for (Node subnode : snode.getValue()) {
        if (!(subnode instanceof MappingNode)) {
            throw new ConstructorException("while constructing an ordered map",
                    node.getStartMark(),
                    "expected a mapping of length 1, but found " + subnode.getNodeId(),
                    subnode.getStartMark());
        }
        MappingNode mnode = (MappingNode) subnode;
        if (mnode.getValue().size() != 1) {
            throw new ConstructorException("while constructing an ordered map",
                    node.getStartMark(), "expected a single mapping item, but found "
                            + mnode.getValue().size() + " items",
                    mnode.getStartMark());
        }
        Node keyNode = mnode.getValue().get(0).getKeyNode();
        Node valueNode = mnode.getValue().get(0).getValueNode();
        Object key = constructObject(keyNode);
        Object value = constructObject(valueNode);
        omap.put(key, value);
    }
    return omap;
}
 
开发者ID:RoccoDev,项目名称:5zig-TIMV-Plugin,代码行数:33,代码来源:SafeConstructor.java

示例9: constructMapping

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
@Override
protected Map<Object, Object> constructMapping(MappingNode node) {
	try {
		return super.constructMapping(node);
	}
	catch (IllegalStateException ex) {
		throw new ParserException("while parsing MappingNode",
				node.getStartMark(), ex.getMessage(), node.getEndMark());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:YamlProcessor.java

示例10: constructMapping2ndStep

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
protected void constructMapping2ndStep(final MappingNode node, final 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:OpenNTF,项目名称:org.openntf.domino,代码行数:30,代码来源:BaseConstructor.java

示例11: construct

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
@Override
public Object construct(final Node node) {
	// Note: we do not check for duplicate keys, because it's too
	// CPU-expensive.
	Map<Object, Object> omap = new LinkedHashMap<Object, Object>();
	if (!(node instanceof SequenceNode)) {
		throw new ConstructorException("while constructing an ordered map", node.getStartMark(), "expected a sequence, but found "
				+ node.getNodeId(), node.getStartMark());
	}
	SequenceNode snode = (SequenceNode) node;
	for (Node subnode : snode.getValue()) {
		if (!(subnode instanceof MappingNode)) {
			throw new ConstructorException("while constructing an ordered map", node.getStartMark(),
					"expected a mapping of length 1, but found " + subnode.getNodeId(), subnode.getStartMark());
		}
		MappingNode mnode = (MappingNode) subnode;
		if (mnode.getValue().size() != 1) {
			throw new ConstructorException("while constructing an ordered map", node.getStartMark(),
					"expected a single mapping item, but found " + mnode.getValue().size() + " items", mnode.getStartMark());
		}
		Node keyNode = mnode.getValue().get(0).getKeyNode();
		Node valueNode = mnode.getValue().get(0).getValueNode();
		Object key = constructObject(keyNode);
		Object value = constructObject(valueNode);
		omap.put(key, value);
	}
	return omap;
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:29,代码来源:SafeConstructor.java

示例12: mergeNode

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
/**
 * Does merge for supplied mapping node.
 * 
 * @param node
 *            where to merge
 * @param isPreffered
 *            true if keys of node should take precedence over others...
 * @param key2index
 *            maps already merged keys to index from values
 * @param values
 *            collects merged NodeTuple
 * @return list of the merged NodeTuple (to be set as value for the
 *         MappingNode)
 */
private List<NodeTuple> mergeNode(MappingNode node, boolean isPreffered,
        Map<Object, Integer> key2index, List<NodeTuple> values) {
    List<NodeTuple> nodeValue = node.getValue();
    // reversed for http://code.google.com/p/snakeyaml/issues/detail?id=139
    Collections.reverse(nodeValue);
    for (Iterator<NodeTuple> iter = nodeValue.iterator(); iter.hasNext();) {
        final NodeTuple nodeTuple = iter.next();
        final Node keyNode = nodeTuple.getKeyNode();
        final Node valueNode = nodeTuple.getValueNode();
        if (keyNode.getTag().equals(Tag.MERGE)) {
            iter.remove();
            switch (valueNode.getNodeId()) {
            case mapping:
                MappingNode mn = (MappingNode) valueNode;
                mergeNode(mn, false, key2index, values);
                break;
            case sequence:
                SequenceNode sn = (SequenceNode) valueNode;
                List<Node> vals = sn.getValue();
                for (Node subnode : vals) {
                    if (!(subnode instanceof MappingNode)) {
                        throw new ConstructorException("while constructing a mapping",
                                node.getStartMark(),
                                "expected a mapping for merging, but found "
                                        + subnode.getNodeId(), subnode.getStartMark());
                    }
                    MappingNode mnode = (MappingNode) subnode;
                    mergeNode(mnode, false, key2index, values);
                }
                break;
            default:
                throw new ConstructorException("while constructing a mapping",
                        node.getStartMark(),
                        "expected a mapping or list of mappings for merging, but found "
                                + valueNode.getNodeId(), valueNode.getStartMark());
            }
        } else {
            // we need to construct keys to avoid duplications
            Object key = constructObject(keyNode);
            if (!key2index.containsKey(key)) { // 1st time merging key
                values.add(nodeTuple);
                // keep track where tuple for the key is
                key2index.put(key, values.size() - 1);
            } else if (isPreffered) { // there is value for the key, but we
                                      // need to override it
                // change value for the key using saved position
                values.set(key2index.get(key), nodeTuple);
            }
        }
    }
    return values;
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:67,代码来源:SafeConstructor.java

示例13: mergeNode

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
/**
 * Does merge for supplied mapping node.
 *
 * @param node
 *            where to merge
 * @param isPreffered
 *            true if keys of node should take precedence over others...
 * @param key2index
 *            maps already merged keys to index from values
 * @param values
 *            collects merged NodeTuple
 * @return list of the merged NodeTuple (to be set as value for the
 *         MappingNode)
 */
private List<NodeTuple> mergeNode(MappingNode node, boolean isPreffered,
        Map<Object, Integer> key2index, List<NodeTuple> values) {
    Iterator<NodeTuple> iter = node.getValue().iterator();
    while (iter.hasNext()) {
        final NodeTuple nodeTuple = iter.next();
        final Node keyNode = nodeTuple.getKeyNode();
        final Node valueNode = nodeTuple.getValueNode();
        if (keyNode.getTag().equals(Tag.MERGE)) {
            iter.remove();
            switch (valueNode.getNodeId()) {
            case mapping:
                MappingNode mn = (MappingNode) valueNode;
                mergeNode(mn, false, key2index, values);
                break;
            case sequence:
                SequenceNode sn = (SequenceNode) valueNode;
                List<Node> vals = sn.getValue();
                for (Node subnode : vals) {
                    if (!(subnode instanceof MappingNode)) {
                        throw new ConstructorException("while constructing a mapping",
                                node.getStartMark(),
                                "expected a mapping for merging, but found "
                                        + subnode.getNodeId(),
                                subnode.getStartMark());
                    }
                    MappingNode mnode = (MappingNode) subnode;
                    mergeNode(mnode, false, key2index, values);
                }
                break;
            default:
                throw new ConstructorException("while constructing a mapping",
                        node.getStartMark(),
                        "expected a mapping or list of mappings for merging, but found "
                                + valueNode.getNodeId(),
                        valueNode.getStartMark());
            }
        } else {
            // we need to construct keys to avoid duplications
            Object key = constructObject(keyNode);
            if (!key2index.containsKey(key)) { // 1st time merging key
                values.add(nodeTuple);
                // keep track where tuple for the key is
                key2index.put(key, values.size() - 1);
            } else if (isPreffered) { // there is value for the key, but we
                                      // need to override it
                // change value for the key using saved position
                values.set(key2index.get(key), nodeTuple);
            }
        }
    }
    return values;
}
 
开发者ID:RoccoDev,项目名称:5zig-TIMV-Plugin,代码行数:67,代码来源:SafeConstructor.java

示例14: mergeNode

import org.yaml.snakeyaml.nodes.MappingNode; //导入方法依赖的package包/类
/**
 * Does merge for supplied mapping node.
 * 
 * @param node
 *            where to merge
 * @param isPreffered
 *            true if keys of node should take precedence over others...
 * @param key2index
 *            maps already merged keys to index from values
 * @param values
 *            collects merged NodeTuple
 * @return list of the merged NodeTuple (to be set as value for the MappingNode)
 */
private List<NodeTuple> mergeNode(final MappingNode node, final boolean isPreffered, final Map<Object, Integer> key2index,
		final List<NodeTuple> values) {
	List<NodeTuple> nodeValue = node.getValue();
	// reversed for http://code.google.com/p/snakeyaml/issues/detail?id=139
	Collections.reverse(nodeValue);
	for (Iterator<NodeTuple> iter = nodeValue.iterator(); iter.hasNext();) {
		final NodeTuple nodeTuple = iter.next();
		final Node keyNode = nodeTuple.getKeyNode();
		final Node valueNode = nodeTuple.getValueNode();
		if (keyNode.getTag().equals(Tag.MERGE)) {
			iter.remove();
			switch (valueNode.getNodeId()) {
			case mapping:
				MappingNode mn = (MappingNode) valueNode;
				mergeNode(mn, false, key2index, values);
				break;
			case sequence:
				SequenceNode sn = (SequenceNode) valueNode;
				List<Node> vals = sn.getValue();
				for (Node subnode : vals) {
					if (!(subnode instanceof MappingNode)) {
						throw new ConstructorException("while constructing a mapping", node.getStartMark(),
								"expected a mapping for merging, but found " + subnode.getNodeId(), subnode.getStartMark());
					}
					MappingNode mnode = (MappingNode) subnode;
					mergeNode(mnode, false, key2index, values);
				}
				break;
			default:
				throw new ConstructorException("while constructing a mapping", node.getStartMark(),
						"expected a mapping or list of mappings for merging, but found " + valueNode.getNodeId(),
						valueNode.getStartMark());
			}
		} else {
			// we need to construct keys to avoid duplications
			Object key = constructObject(keyNode);
			if (!key2index.containsKey(key)) { // 1st time merging key
				values.add(nodeTuple);
				// keep track where tuple for the key is
				key2index.put(key, values.size() - 1);
			} else if (isPreffered) { // there is value for the key, but we
										// need to override it
				// change value for the key using saved position
				values.set(key2index.get(key), nodeTuple);
			}
		}
	}
	return values;
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:63,代码来源:SafeConstructor.java


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