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 composeMappingNode(String anchor) { MappingStartEvent startEvent = (MappingStartEvent) parser.getEvent(); String tag = startEvent.getTag(); Tag nodeTag; boolean resolved = false; if (tag == null || tag.equals("!")) { nodeTag = resolver.resolve(NodeId.mapping, null, startEvent.getImplicit()); resolved = true; } else { nodeTag = new Tag(tag); } final List<NodeTuple> children = new ArrayList<NodeTuple>(); MappingNode node = new MappingNode( nodeTag, resolved, children, startEvent.getStartMark(), null, startEvent.getFlowStyle()); if (anchor != null) { anchors.put(anchor, node); } while (!parser.checkEvent(Event.ID.MappingEnd)) { composeMappingChildren(children, node); } Event endEvent = parser.getEvent(); node.setEndMark(endEvent.getEndMark()); return node; }
protected Node composeScalarNode(String anchor) { ScalarEvent ev = (ScalarEvent) parser.getEvent(); String tag = ev.getTag(); boolean resolved = false; Tag nodeTag; if (tag == null || tag.equals("!")) { nodeTag = resolver.resolve( NodeId.scalar, ev.getValue(), ev.getImplicit().canOmitTagInPlainScalar()); resolved = true; } else { nodeTag = new Tag(tag); } Node node = new ScalarNode( nodeTag, resolved, ev.getValue(), ev.getStartMark(), ev.getEndMark(), ev.getStyle()); if (anchor != null) { anchors.put(anchor, node); } return node; }