Esempio n. 1
0
  private Node composeNode(Node parent) {
    this.recursiveNodes.add(parent);
    if (this.parser.checkEvent(Event.ID.Alias)) {
      AliasEvent event = (AliasEvent) this.parser.getEvent();
      String anchor = event.getAnchor();
      if (!this.anchors.containsKey(anchor)) {
        throw new ComposerException(
            null, null, "found undefined alias " + anchor, event.getStartMark());
      }
      Node result = (Node) this.anchors.get(anchor);
      if (this.recursiveNodes.remove(result)) {
        result.setTwoStepsConstruction(true);
      }
      return result;
    }
    NodeEvent event = (NodeEvent) this.parser.peekEvent();
    String anchor = null;
    anchor = event.getAnchor();

    Node node = null;
    if (this.parser.checkEvent(Event.ID.Scalar)) {
      node = composeScalarNode(anchor);
    } else if (this.parser.checkEvent(Event.ID.SequenceStart)) {
      node = composeSequenceNode(anchor);
    } else {
      node = composeMappingNode(anchor);
    }
    this.recursiveNodes.remove(parent);
    return node;
  }