Beispiel #1
0
  /**
   * Do a deep clone of this walker, including next and previous walkers. If the this AxesWalker is
   * on the clone list, don't clone but return the already cloned version.
   *
   * @param cloneOwner non-null reference to the cloned location path iterator to which this clone
   *     will be added.
   * @param cloneList non-null vector of sources in odd elements, and the corresponding clones in
   *     even vectors.
   * @return non-null clone, which may be a new clone, or may be a clone contained on the cloneList.
   */
  AxesWalker cloneDeep(WalkingIterator cloneOwner, Vector cloneList)
      throws CloneNotSupportedException {
    AxesWalker clone = findClone(this, cloneList);
    if (null != clone) return clone;
    clone = (AxesWalker) this.clone();
    clone.setLocPathIterator(cloneOwner);
    if (null != cloneList) {
      cloneList.addElement(this);
      cloneList.addElement(clone);
    }

    if (wi().m_lastUsedWalker == this) cloneOwner.m_lastUsedWalker = clone;

    if (null != m_nextWalker) clone.m_nextWalker = m_nextWalker.cloneDeep(cloneOwner, cloneList);

    // If you don't check for the cloneList here, you'll go into an
    // recursive infinate loop.
    if (null != cloneList) {
      if (null != m_prevWalker) clone.m_prevWalker = m_prevWalker.cloneDeep(cloneOwner, cloneList);
    } else {
      if (null != m_nextWalker) clone.m_nextWalker.m_prevWalker = clone;
    }
    return clone;
  }