protected void constructSequenceStep2(SequenceNode node, Collection<Object> collection) { for (Node child : node.getValue()) { collection.add(constructObject(child)); } }
protected Node composeSequenceNode(String anchor) { SequenceStartEvent startEvent = (SequenceStartEvent) parser.getEvent(); String tag = startEvent.getTag(); Tag nodeTag; boolean resolved = false; if (tag == null || tag.equals("!")) { nodeTag = resolver.resolve(NodeId.sequence, null, startEvent.getImplicit()); resolved = true; } else { nodeTag = new Tag(tag); } final ArrayList<Node> children = new ArrayList<Node>(); SequenceNode node = new SequenceNode(nodeTag, resolved, children, startEvent.getStartMark(), null, startEvent.getFlowStyle()); if (anchor != null) { anchors.put(anchor, node); } while (!parser.checkEvent(Event.ID.SequenceEnd)) { children.add(composeNode(node)); } Event endEvent = parser.getEvent(); node.setEndMark(endEvent.getEndMark()); return node; }
protected Node representSequence(Tag tag, Iterable<?> sequence, DumperOptions.FlowStyle flowStyle) { int size = 10;// default for ArrayList if (sequence instanceof List<?>) { size = ((List<?>) sequence).size(); } List<Node> value = new ArrayList<Node>(size); SequenceNode node = new SequenceNode(tag, value, flowStyle); representedObjects.put(objectToRepresent, node); DumperOptions.FlowStyle bestStyle = FlowStyle.FLOW; for (Object item : sequence) { Node nodeItem = representData(item); if (!(nodeItem instanceof ScalarNode && ((ScalarNode) nodeItem).isPlain())) { bestStyle = FlowStyle.BLOCK; } value.add(nodeItem); } if (flowStyle == FlowStyle.AUTO) { if (defaultFlowStyle != FlowStyle.AUTO) { node.setFlowStyle(defaultFlowStyle); } else { node.setFlowStyle(bestStyle); } } return node; }
private SequenceNode cloneSequenceNode(SequenceNode node, Map<String, String> parameters) { List<Node> nodes = new ArrayList<Node>(); for (Node item : node.getValue()) { nodes.add(cloneNode(item, parameters)); } return new SequenceNode(node.getTag(), nodes, node.getFlowStyle()); }
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);
private void loopTemplateSequence(SequenceNode templateSequence, String templateType, List<ValidationResult> validationResults) for (int j = 0; j < templateSequence.getValue().size(); j++) Node template = resolveInclude(templateSequence.getValue().get(j)); if (template.getNodeId() != mapping) validationResults.add(createErrorResult("Mapping expected", templateSequence.getStartMark(), templateSequence.getEndMark())); break; updateIncludeTag(templateValue, templateSequence.getTag()); templateSequence.getValue().clear(); templateSequence.getValue().addAll(prunedTemplates);
if (listNode instanceof SequenceNode) { SequenceNode seq = (SequenceNode) listNode; seq.setType(List.class); seq.setListType(ACLPolicyDoc.TypeRule.class); List<Node> value = seq.getValue(); for (int x = 0; x < value.size(); x++) { Node node1 = value.get(x);
String projectVersion = null; List<Node> versionList = versionNode.getValue(); for (Node versionEntry : versionList) { requireNodeInstanceOf(MappingNode.class, versionEntry, filename, "The entry MUST be a mapping"); default: throw new InvalidParserConfigurationException( "Yaml config.(" + filename + ":" + versionNode.getStartMark().getLine() + "): " + "Found unexpected config entry: " + key + ", allowed are " + "'git_commit_id_describe_short', 'build_timestamp' and 'project_version'");
protected static NodeTuple createStrSeqTuple(final String key, final List<Node> value, final boolean flowStyle) { return new NodeTuple(createStrScalar(key), new SequenceNode(Tag.SEQ, value, flowStyle)); }
Class<?> t = arguments[0]; SequenceNode snode = (SequenceNode) valueNode; snode.setListType(t); } else if (Set.class.isAssignableFrom(valueNode.getType())) { Class<?> t = arguments[0];
@Override public boolean isJsonStyle() { return !((SequenceNode) getYamlNode()).getFlowStyle(); } }
private SequenceNode cloneSequenceNode(SequenceNode node, Map<String, String> parameters) { List<Node> nodes = new ArrayList<Node>(); for (Node item : node.getValue()) { nodes.add(cloneNode(item, parameters)); } return new SequenceNode(node.getTag(), nodes, node.getFlowStyle()); }
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);
protected Node representSequence(Tag tag, Iterable<?> sequence, DumperOptions.FlowStyle flowStyle) { int size = 10;// default for ArrayList if (sequence instanceof List<?>) { size = ((List<?>) sequence).size(); } List<Node> value = new ArrayList<Node>(size); SequenceNode node = new SequenceNode(tag, value, flowStyle); representedObjects.put(objectToRepresent, node); DumperOptions.FlowStyle bestStyle = FlowStyle.FLOW; for (Object item : sequence) { Node nodeItem = representData(item); if (!(nodeItem instanceof ScalarNode && ((ScalarNode) nodeItem).isPlain())) { bestStyle = FlowStyle.BLOCK; } value.add(nodeItem); } if (flowStyle == FlowStyle.AUTO) { if (defaultFlowStyle != FlowStyle.AUTO) { node.setFlowStyle(defaultFlowStyle); } else { node.setFlowStyle(bestStyle); } } return node; }
public static SequenceNode expectList(YamlReaderHelper config, FieldDescriptor field, Node node) { if (isEmpty(node)) { return new SequenceNode(Tag.SEQ, ImmutableList.<Node>of(), false); } else if (node instanceof ScalarNode) { // Allow a singleton as a list. return new SequenceNode(Tag.SEQ, ImmutableList.<Node>of(node), false); } else if (node instanceof SequenceNode) { return (SequenceNode) node; } else { config.error(node, "Expected a list for field '%s', found '%s'.", field.getFullName(), node.getNodeId()); return new SequenceNode(Tag.SEQ, ImmutableList.<Node>of(), false); } }
node.setTag(Tag.SEQ); node.setType(parameterTypes[0]); ((SequenceNode) node).setListType(((Class<?>) ((ParameterizedType) containedElementType).getActualTypeArguments()[0])); Object object = super.constructObject(node); return method.invoke(null, object);
public static ReconcileProblemImpl missingProperty(String msg, IDocument doc, Node parent, Node map) { DocumentRegion underline = NodeUtil.region(doc, map); if (parent instanceof MappingNode) { for (NodeTuple prop : ((MappingNode) parent).getValue()) { if (prop.getValueNode()==map) { underline = NodeUtil.region(doc, prop.getKeyNode()); } } } else if (parent instanceof SequenceNode) { Boolean flowStyle = ((SequenceNode) parent).getFlowStyle(); if (flowStyle!=null && !flowStyle) { Mark nodeStart = map.getStartMark(); underline = new DocumentRegion(doc, 0, nodeStart.getIndex()); underline = underline.trimEnd(); if (underline.endsWith("-")) { underline = underline.subSequence(underline.length()-1, underline.length()); } } } else { underline = underline.trimEnd().textAtEnd(1); } return problem(MISSING_PROPERTY, msg, underline); }