protected void setParent(Node newParent, boolean removeDep) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "setParent entry: new parent will be: " + newParent + " for node: " + this);
        }

        Node oldParent = parent;

        parent = newParent;
        if (newParent != null) {
            parent.addDependent(this);
        }

        // removing dependents can cause ConcurrentModificationException if calling is iterating over a list of dependent nodes
        // therefore removeDep should be false if setParent is being called while iterating or looping over a list of
        // dependent nodes.
        if (removeDep) {
            // remove this node from the old parents list of dependents.
            if (oldParent != null) {
                if (newParent == null) {
                    oldParent.removeDependent(this);
                } else if (oldParent.getStreamID() != parent.getStreamID()) {
                    oldParent.removeDependent(this);
                }
            }
        }
    }
protected void setParent ( Node newParent , boolean removeDep ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "setParent entry: new parent will be: " + newParent + " for node: " + this ) ; } Node oldParent = parent ; parent = newParent ; if ( newParent != null ) { parent . addDependent ( this ) ; } if ( removeDep ) { if ( oldParent != null ) { if ( newParent == null ) { oldParent . removeDependent ( this ) ; } else if ( oldParent . getStreamID ( ) != parent . getStreamID ( ) ) { oldParent . removeDependent ( this ) ; } } } }
Give this node a new parent.
Remove this node as a dependent of the old parent
Add this node as a dependent of the new parent.

@param newParent The new parent for this node. Null is allowed is is basically removing this node from the tree.