protected int disconnect ( final boolean iForceDirty , final int iLevel ) { if ( dataProvider == null ) // DIRTY NODE, JUST REMOVE IT return 1 ; int totalDisconnected = 0 ; final ORID rid = dataProvider . getIdentity ( ) ; boolean disconnectedFromParent = false ; if ( parent != null ) { // DISCONNECT RECURSIVELY THE PARENT NODE if ( canDisconnectFrom ( parent ) || iForceDirty ) { if ( parent . left == this ) { parent . left = null ; } else if ( parent . right == this ) { parent . right = null ; } else OLogManager . instance ( ) . warn ( this , "Node " + rid + " has the parent (" + parent + ") unlinked to itself. It links to " + parent ) ; totalDisconnected += parent . disconnect ( iForceDirty , iLevel + 1 ) ; parent = null ; disconnectedFromParent = true ; } } else { disconnectedFromParent = true ; } boolean disconnectedFromLeft = false ; if ( left != null ) { // DISCONNECT RECURSIVELY THE LEFT NODE if ( canDisconnectFrom ( left ) || iForceDirty ) { if ( left . parent == this ) left . parent = null ; else OLogManager . instance ( ) . warn ( this , "Node " + rid + " has the left (" + left + ") unlinked to itself. It links to " + left . parent ) ; totalDisconnected += left . disconnect ( iForceDirty , iLevel + 1 ) ; left = null ; disconnectedFromLeft = true ; } } else { disconnectedFromLeft = true ; } boolean disconnectedFromRight = false ; if ( right != null ) { // DISCONNECT RECURSIVELY THE RIGHT NODE if ( canDisconnectFrom ( right ) || iForceDirty ) { if ( right . parent == this ) right . parent = null ; else OLogManager . instance ( ) . warn ( this , "Node " + rid + " has the right (" + right + ") unlinked to itself. It links to " + right . parent ) ; totalDisconnected += right . disconnect ( iForceDirty , iLevel + 1 ) ; right = null ; disconnectedFromRight = true ; } } else { disconnectedFromLeft = true ; } if ( disconnectedFromParent && disconnectedFromLeft && disconnectedFromRight ) if ( ( ! dataProvider . isEntryDirty ( ) && ! dataProvider . getIdentity ( ) . isTemporary ( ) || iForceDirty ) && ! pTree . isNodeEntryPoint ( this ) ) { totalDisconnected ++ ; pTree . removeNodeFromMemory ( this ) ; clear ( ) ; } return totalDisconnected ; }
Disconnect the current node from others .