本文整理汇总了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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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'");
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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));
}
}
}