static void applyToNodes ( List < NodeInfo > order , Element compViewParent ) { // first set up a bogus node to assist with inserting Node insertPoint = compViewParent . getOwnerDocument ( ) . createElement ( "bogus" ) ; Node first = compViewParent . getFirstChild ( ) ; if ( first != null ) compViewParent . insertBefore ( insertPoint , first ) ; else compViewParent . appendChild ( insertPoint ) ; // now pass through the order list inserting the nodes as you go for ( int i = 0 ; i < order . size ( ) ; i ++ ) compViewParent . insertBefore ( order . get ( i ) . getNode ( ) , insertPoint ) ; compViewParent . removeChild ( insertPoint ) ; }
This method applies the ordering specified in the passed in order list to the child nodes of the compViewParent . Nodes specified in the list but located elsewhere are pulled in .