public void addChild ( Node node ) throws ChildNodeException { if ( node != null ) { if ( ! allowChildren ) { throw new ChildNodeException ( ) ; } if ( getFirstChild ( ) == null ) { setFirstChild ( node ) ; getFirstChild ( ) . setPrevSibling ( firstChild ) ; getFirstChild ( ) . setNextSibling ( firstChild ) ; } else { // Add it to the end of the list Node lastChild = getFirstChild ( ) . getPrevSibling ( ) ; if ( lastChild != null ) { lastChild . setNextSibling ( node ) ; } node . setNextSibling ( getFirstChild ( ) ) ; } node . setParent ( this ) ; } }
This function adds a child to the linked - list of children for this node . It adds the child to the end of the list .