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$PathBetweenNodesEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-19  |  2.4 KB  |  47 lines

  1. package javax.awt.swing.tree;
  2.  
  3. import java.util.EmptyStackException;
  4. import java.util.Enumeration;
  5. import java.util.NoSuchElementException;
  6. import java.util.Stack;
  7.  
  8. final class DefaultMutableTreeNode$PathBetweenNodesEnumeration implements Enumeration {
  9.    // $FF: synthetic field
  10.    private final DefaultMutableTreeNode this$0;
  11.    protected Stack stack;
  12.  
  13.    public DefaultMutableTreeNode$PathBetweenNodesEnumeration(DefaultMutableTreeNode this$0, TreeNode ancestor, TreeNode descendant) {
  14.       this.this$0 = this$0;
  15.       this.this$0 = this$0;
  16.       if (ancestor != null && descendant != null) {
  17.          this.stack = new Stack();
  18.          this.stack.push(descendant);
  19.          TreeNode current = descendant;
  20.  
  21.          while(current != ancestor) {
  22.             current = current.getParent();
  23.             if (current == null && descendant != ancestor) {
  24.                throw new IllegalArgumentException("node " + ancestor + " is not an ancestor of " + descendant);
  25.             }
  26.  
  27.             this.stack.push(current);
  28.          }
  29.  
  30.       } else {
  31.          throw new IllegalArgumentException("argument is null");
  32.       }
  33.    }
  34.  
  35.    public boolean hasMoreElements() {
  36.       return this.stack.size() > 0;
  37.    }
  38.  
  39.    public Object nextElement() {
  40.       try {
  41.          return this.stack.pop();
  42.       } catch (EmptyStackException var1) {
  43.          throw new NoSuchElementException("No more elements");
  44.       }
  45.    }
  46. }
  47.