예제 #1
0
파일: Node.java 프로젝트: saeg/experiments
  protected Node doClone(Node parent) {
    Node clone;
    try {
      clone = (Node) super.clone();
    } catch (CloneNotSupportedException e) {
      throw new RuntimeException(e);
    }

    clone.parentNode = parent; // can be null, to create an orphan split
    clone.siblingIndex = parent == null ? 0 : siblingIndex;
    clone.attributes = attributes != null ? attributes.clone() : null;
    clone.baseUri = baseUri;
    clone.childNodes = new ArrayList<Node>(childNodes.size());
    for (Node child : childNodes)
      clone.childNodes.add(child.doClone(clone)); // clone() creates orphans, doClone() keeps parent

    return clone;
  }