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


Java SequenceNode.getValue方法代码示例

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


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

示例1: getNode

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
@Nullable
private Node getNode(Node node, String key)
{
    if (key.isEmpty())
    {
        return node;
    }
    if (node instanceof SequenceNode)
    {
        SequenceNode sequenceNode = (SequenceNode) node;
        List<Node> sequenceNodeValue = sequenceNode.getValue();
        int i = DioriteMathUtils.asInt(key, - 1);
        if ((i == - 1) || (i < sequenceNodeValue.size()))
        {
            return null;
        }
        return sequenceNodeValue.get(i);
    }
    if (node instanceof MappingNode)
    {
        return this.getNode((MappingNode) node, key);
    }
    return null;
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:25,代码来源:YamlDeserializationData.java

示例2: typeCheck

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
@Override
public void typeCheck(Node node) throws ConfigTypeErrorException {
    if (YamlUtils.isNull(node)) {
        return;
    }
    if (!(node instanceof SequenceNode)) {
        throw new ConfigTypeErrorException(node, format("Expected a %s, found %s", this.toString(), node.getTag()));
    } else {
        SequenceNode listNode = (SequenceNode)node;
        Set<Object> results = new HashSet<>();
        for (Node innerNode : listNode.getValue()) {
            innerType.typeCheck(innerNode);
            Object obj = innerType.coerce(innerNode);
            if (results.contains(obj)) {
                throw new ConfigTypeErrorException(innerNode, "Duplicate entry in set");
            }
            results.add(obj);
        }
    }
}
 
开发者ID:wtetzner,项目名称:kurgan,代码行数:21,代码来源:ConfigSet.java

示例3: construct

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
@Override
public List<OpenShiftCluster> construct(Node node) {
    List<OpenShiftCluster> clusters = new ArrayList<>();
    SequenceNode sequenceNode = (SequenceNode) node;
    for (Node n : sequenceNode.getValue()) {
        MappingNode mapNode = (MappingNode) n;
        Map<Object, Object> valueMap = constructMapping(mapNode);
        String id = (String) valueMap.get("id");
        String apiUrl = (String) valueMap.get("apiUrl");
        String consoleUrl = (String) valueMap.get("consoleUrl");
        clusters.add(new OpenShiftCluster(id, apiUrl, consoleUrl));
    }
    return clusters;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:15,代码来源:OpenShiftClusterConstructor.java

示例4: construct

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的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

示例5: construct

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的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

示例6: getAsCollection

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的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

示例7: loadResource

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
private void loadResource(Yaml yaml, InputStream yamlStream, String filename) {
    Node loadedYaml = yaml.compose(new UnicodeReader(yamlStream));

    if (loadedYaml == null) {
        throw new InvalidParserConfigurationException("The file " + filename + " is empty");
    }

    // Get and check top level config
    if (!(loadedYaml instanceof MappingNode)) {
        fail(loadedYaml, filename, "File must be a Map");
    }

    MappingNode rootNode = (MappingNode) loadedYaml;

    NodeTuple configNodeTuple = null;
    for (NodeTuple tuple : rootNode.getValue()) {
        String name = getKeyAsString(tuple, filename);
        if ("config".equals(name)) {
            configNodeTuple = tuple;
            break;
        }
    }

    if (configNodeTuple == null) {
        fail(loadedYaml, filename, "The top level entry MUST be 'config'.");
    }

    SequenceNode configNode = getValueAsSequenceNode(configNodeTuple, filename);
    List<Node> configList = configNode.getValue();

    for (Node configEntry : configList) {
        if (!(configEntry instanceof MappingNode)) {
            fail(loadedYaml, filename, "The entry MUST be a mapping");
        }

        NodeTuple entry = getExactlyOneNodeTuple((MappingNode) configEntry, filename);
        MappingNode actualEntry = getValueAsMappingNode(entry, filename);
        String entryType = getKeyAsString(entry, filename);
        switch (entryType) {
            case "lookup":
                loadYamlLookup(actualEntry, filename);
                break;
            case "set":
                loadYamlLookupSets(actualEntry, filename);
                break;
            case "matcher":
                loadYamlMatcher(actualEntry, filename);
                break;
            case "test":
                if (loadTests) {
                    loadYamlTestcase(actualEntry, filename);
                }
                break;
            default:
                throw new InvalidParserConfigurationException(
                    "Yaml config.(" + filename + ":" + actualEntry.getStartMark().getLine() + "): " +
                        "Found unexpected config entry: " + entryType + ", allowed are 'lookup', 'set', 'matcher' and 'test'");
        }
    }
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:61,代码来源:UserAgentAnalyzerDirect.java

示例8: handleMessageField

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
private void handleMessageField(ConfigSource.Builder builder, FieldDescriptor field, Node value,
    String path){
  if (field.isMapField()) {
    MappingNode map = NodeConverterUtils.expectMap(helper, field, value);
    FieldDescriptor keyField = field.getMessageType().getFields().get(0);
    FieldDescriptor valueField = field.getMessageType().getFields().get(1);
    boolean isNested =
        field.getMessageType().getFields().get(1).getType() == FieldDescriptor.Type.MESSAGE;
    for (NodeTuple entry : map.getValue()) {

      Object keyObj = NodeConverterUtils.convert(helper, keyField, entry.getKeyNode());
      if (keyObj == null) {
        continue;
      }
      if (isNested) {
        String nestedPath = appendToPath(path, keyObj);
        helper.checkAndAddPath(nestedPath, value, field);
        builder.withBuilder(field, keyObj, new ReadNodeBuildAction(helper, entry.getValueNode(),
            appendToPath(nestedPath, keyObj)));
      } else {
        Object valueObj = NodeConverterUtils.convert(helper, valueField, entry.getValueNode());
        if (valueObj != null) {
          builder.setValue(field, keyObj, valueObj, helper.getLocation(entry.getValueNode()));
        }
      }
    }
  } else if (field.isRepeated()) {
    SequenceNode list = NodeConverterUtils.expectList(helper, field, value);
    int index = 0;
    for (Node elem : list.getValue()) {
      String indexedPath = String.format("%s[%s]", path, index++);
      builder.withAddedBuilder(field, new ReadNodeBuildAction(helper, elem, indexedPath));
    }
  } else {
    builder.withBuilder(field, new ReadNodeBuildAction(helper, value, path));
  }
  addExplicitLocationField(builder, field, value);
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:39,代码来源:YamlNodeReader.java

示例9: constructArrayStep2

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
protected Object constructArrayStep2(SequenceNode node, Object array) {
    int index = 0;
    for (Node child : node.getValue()) {
        Array.set(array, index++, constructObject(child));
    }
    return array;
}
 
开发者ID:timvisee,项目名称:TestTheTeacher,代码行数:8,代码来源:BaseConstructor.java

示例10: construct

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
public Object construct(Node node)
{
	node.setType(SmartTypingPairsElement.class);
	String path = getPath(node);
	SmartTypingPairsElement be = new SmartTypingPairsElement(path);
	MappingNode mapNode = (MappingNode) node;
	List<NodeTuple> tuples = mapNode.getValue();
	for (NodeTuple tuple : tuples)
	{
		ScalarNode keyNode = (ScalarNode) tuple.getKeyNode();
		String key = keyNode.getValue();
		// "pairs", "scope", "displayName" are required
		if ("pairs".equals(key)) //$NON-NLS-1$
		{
			SequenceNode pairsValueNode = (SequenceNode) tuple.getValueNode();
			List<Character> pairs = new ArrayList<Character>();
			List<Node> pairsValues = pairsValueNode.getValue();
			for (Node pairValue : pairsValues)
			{
				ScalarNode blah = (ScalarNode) pairValue;
				String pairCharacter = blah.getValue();
				pairs.add(Character.valueOf(pairCharacter.charAt(0)));
			}
			be.setPairs(pairs);
		}
		else if ("scope".equals(key)) //$NON-NLS-1$
		{
			ScalarNode scopeValueNode = (ScalarNode) tuple.getValueNode();
			be.setScope(scopeValueNode.getValue());
		}
		else if ("displayName".equals(key)) //$NON-NLS-1$
		{
			ScalarNode displayNameNode = (ScalarNode) tuple.getValueNode();
			be.setDisplayName(displayNameNode.getValue());
		}
	}
	return be;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:39,代码来源:BundleCacher.java

示例11: coerce

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
@Override
public Object coerce(Node node) {
    SequenceNode listNode = (SequenceNode)node;
    List<Node> nodes = listNode.getValue();
    Set<Object> results = new HashSet<>();
    for (Node innerNode : nodes) {
        results.add(innerType.coerce(innerNode));
    }
    return Collections.unmodifiableSet(results);
}
 
开发者ID:wtetzner,项目名称:kurgan,代码行数:11,代码来源:ConfigSet.java

示例12: coerce

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
@Override
public Object coerce(Node node) {
    SequenceNode listNode = (SequenceNode)node;
    List<Node> nodes = listNode.getValue();
    List<Object> results = new ArrayList<>();
    for (Node innerNode : nodes) {
        results.add(innerType.coerce(innerNode));
    }
    return Collections.unmodifiableList(results);
}
 
开发者ID:wtetzner,项目名称:kurgan,代码行数:11,代码来源:ConfigList.java

示例13: typeCheck

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
@Override
public void typeCheck(Node node) throws ConfigTypeErrorException {
    if (YamlUtils.isNull(node)) {
        return;
    }
    if (!(node instanceof SequenceNode)) {
        throw new ConfigTypeErrorException(node, String.format("Expected a %s, found %s", this.toString(), node.getTag()));
    } else {
        SequenceNode listNode = (SequenceNode)node;
        for (Node innerNode : listNode.getValue()) {
            innerType.typeCheck(innerNode);
        }
    }
}
 
开发者ID:wtetzner,项目名称:kurgan,代码行数:15,代码来源:ConfigList.java

示例14: construct

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的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

示例15: serializeNode

import org.yaml.snakeyaml.nodes.SequenceNode; //导入方法依赖的package包/类
private void serializeNode(Node node, Node parent) throws IOException {
    if (node.getNodeId() == NodeId.anchor) {
        node = ((AnchorNode) node).getRealNode();
    }
    String tAlias = this.anchors.get(node);
    if (this.serializedNodes.contains(node)) {
        this.emitter.emit(new AliasEvent(tAlias, null, null));
    } else {
        this.serializedNodes.add(node);
        switch (node.getNodeId()) {
        case scalar:
            ScalarNode scalarNode = (ScalarNode) node;
            Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
            Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
            ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node
                    .getTag().equals(defaultTag));
            ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple,
                    scalarNode.getValue(), null, null, scalarNode.getStyle());
            this.emitter.emit(event);
            break;
        case sequence:
            SequenceNode seqNode = (SequenceNode) node;
            boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence,
                    null, true));
            this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(),
                    implicitS, null, null, seqNode.getFlowStyle()));
            List<Node> list = seqNode.getValue();
            for (Node item : list) {
                serializeNode(item, node);
            }
            this.emitter.emit(new SequenceEndEvent(null, null));
            break;
        default:// instance of MappingNode
            Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
            boolean implicitM = node.getTag().equals(implicitTag);
            this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(),
                    implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
            MappingNode mnode = (MappingNode) node;
            List<NodeTuple> map = mnode.getValue();
            for (NodeTuple row : map) {
                Node key = row.getKeyNode();
                Node value = row.getValueNode();
                serializeNode(key, mnode);
                serializeNode(value, mnode);
            }
            this.emitter.emit(new MappingEndEvent(null, null));
        }
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:50,代码来源:Serializer.java


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