public final boolean addChild ( int index , N newChild ) { if ( newChild == null ) { return false ; } final int count = ( this . children == null ) ? 0 : this . children . size ( ) ; final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this && oldParent != null ) { newChild . removeFromParent ( ) ; } final int insertionIndex ; if ( this . children == null ) { this . children = newInternalList ( index + 1 ) ; } if ( index < count ) { // set the element insertionIndex = Math . max ( index , 0 ) ; this . children . add ( insertionIndex , newChild ) ; } else { // Resize the array insertionIndex = this . children . size ( ) ; this . children . add ( newChild ) ; } ++ this . notNullChildCount ; newChild . setParentNodeReference ( toN ( ) , true ) ; firePropertyChildAdded ( insertionIndex , newChild ) ; return true ; }
Add a child node at the specified index .