if ( levelIter.hasChildren() ) { levelIter=levelIter.nextLevel(); } Object nextElt=null; // if there are more siblings at the current level if ( levelIter.hasMoreElements() ) nextElt=levelIter.nextElement(); // the entire level has been processed--go to the parent level else if (levelIter.hasParent() ) { levelIter=levelIter.toParent(); nextElt=levelIter.nextElement(); } return nextElt;
Example 1: Using LevelIterator to implement the tree iterator's next method.