private Node composeSequenceNode(String anchor) { SequenceStartEvent startEvent = (SequenceStartEvent) this.parser.getEvent(); String tag = startEvent.getTag(); boolean resolved = false; Tag nodeTag; if ((tag == null) || (tag.equals("!"))) { Tag nodeTag = this.resolver.resolve(NodeId.sequence, null, startEvent.getImplicit()); resolved = true; } else { nodeTag = new Tag(tag); } ArrayList<Node> children = new ArrayList(); SequenceNode node = new SequenceNode( nodeTag, resolved, children, startEvent.getStartMark(), null, startEvent.getFlowStyle()); if (anchor != null) { this.anchors.put(anchor, node); } while (!this.parser.checkEvent(Event.ID.SequenceEnd)) { children.add(composeNode(node)); } Event endEvent = this.parser.getEvent(); node.setEndMark(endEvent.getEndMark()); return node; }
private Node composeMappingNode(String anchor) { MappingStartEvent startEvent = (MappingStartEvent) this.parser.getEvent(); String tag = startEvent.getTag(); boolean resolved = false; Tag nodeTag; if ((tag == null) || (tag.equals("!"))) { Tag nodeTag = this.resolver.resolve(NodeId.mapping, null, startEvent.getImplicit()); resolved = true; } else { nodeTag = new Tag(tag); } List<NodeTuple> children = new ArrayList(); MappingNode node = new MappingNode( nodeTag, resolved, children, startEvent.getStartMark(), null, startEvent.getFlowStyle()); if (anchor != null) { this.anchors.put(anchor, node); } while (!this.parser.checkEvent(Event.ID.MappingEnd)) { Node itemKey = composeNode(node); if (itemKey.getTag().equals(Tag.MERGE)) { node.setMerged(true); } Node itemValue = composeNode(node); children.add(new NodeTuple(itemKey, itemValue)); } Event endEvent = this.parser.getEvent(); node.setEndMark(endEvent.getEndMark()); return node; }