// Remove ourself from any previous parent.
if (parent != null) {
// assert parent.kids != null;
for (Iterator iter = parent.kids.iterator(); iter.hasNext(); ) {
WeakReference ref = (WeakReference) iter.next();
Logger kid = (Logger) ref.get();
if (kid == this) {
iter.remove();
break;
}
}
// We have now removed ourself from our parents' kids.
}
// Set our new parent.
parent = newParent;
if (parent.kids == null) {
parent.kids = new ArrayList(2);
}
parent.kids.add(new WeakReference(this));
// As a result of the reparenting, the effective level
// may have changed for us and our children.
updateEffectiveLevel();