home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / debug / databind.jar / javax / awt / swing / tree / DefaultMutableTreeNode$PreorderEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-19  |  2.1 KB  |  40 lines

  1. package javax.awt.swing.tree;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.Stack;
  5. import java.util.Vector;
  6.  
  7. final class DefaultMutableTreeNode$PreorderEnumeration implements Enumeration {
  8.    // $FF: synthetic field
  9.    private final DefaultMutableTreeNode this$0;
  10.    protected Stack stack;
  11.  
  12.    public DefaultMutableTreeNode$PreorderEnumeration(DefaultMutableTreeNode this$0, TreeNode rootNode) {
  13.       this.this$0 = this$0;
  14.       this.this$0 = this$0;
  15.       Vector v = new Vector(1);
  16.       v.addElement(rootNode);
  17.       this.stack = new Stack();
  18.       this.stack.push(v.elements());
  19.    }
  20.  
  21.    public boolean hasMoreElements() {
  22.       return !this.stack.empty() && ((Enumeration)this.stack.peek()).hasMoreElements();
  23.    }
  24.  
  25.    public Object nextElement() {
  26.       Enumeration enumer = (Enumeration)this.stack.peek();
  27.       TreeNode node = (TreeNode)enumer.nextElement();
  28.       Enumeration children = node.children();
  29.       if (!enumer.hasMoreElements()) {
  30.          this.stack.pop();
  31.       }
  32.  
  33.       if (children.hasMoreElements()) {
  34.          this.stack.push(children);
  35.       }
  36.  
  37.       return node;
  38.    }
  39. }
  40.