コード例 #1
0
ファイル: Dom.java プロジェクト: hk2-project/hk2
 /** Removes an existing {@link NodeChild} */
 public synchronized void removeChild(final Dom reference) {
   ListIterator<Child> itr = children.listIterator();
   while (itr.hasNext()) {
     Child child = itr.next();
     if (child instanceof NodeChild) {
       NodeChild nc = (NodeChild) child;
       if (nc.dom == reference) {
         itr.remove();
         reference.release();
         return;
       }
     }
   }
   throw new IllegalArgumentException(
       reference + " is not a valid child of " + this + ". Children=" + children);
 }
コード例 #2
0
ファイル: Dom.java プロジェクト: hk2-project/hk2
  /**
   * Replaces an existing {@link NodeChild} with another one.
   *
   * @see #insertAfter(Dom, String, Dom)
   */
  public synchronized void replaceChild(Dom reference, String name, Dom newNode) {
    ListIterator<Child> itr = children.listIterator();
    while (itr.hasNext()) {
      Child child = itr.next();
      if (child instanceof NodeChild) {
        NodeChild nc = (NodeChild) child;
        if (nc.dom == reference) {
          reference.release();
          newNode.domDescriptor =
              addWithAlias(getHabitat(), newNode, newNode.getProxyType(), newNode.getKey());

          itr.set(new NodeChild(name, newNode));
          return;
        }
      }
    }
    throw new IllegalArgumentException(
        reference + " is not a valid child of " + this + ". Children=" + children);
  }