home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / tree / DefaultMutableTreeNode$PathBetweenNodesEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  2.2 KB  |  47 lines

  1. package com.sun.java.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 var1, TreeNode var2, TreeNode var3) {
  14.       this.this$0 = var1;
  15.       this.this$0 = var1;
  16.       if (var2 != null && var3 != null) {
  17.          this.stack = new Stack();
  18.          this.stack.push(var3);
  19.          TreeNode var4 = var3;
  20.  
  21.          while(var4 != var2) {
  22.             var4 = var4.getParent();
  23.             if (var4 == null && var3 != var2) {
  24.                throw new IllegalArgumentException("node " + var2 + " is not an ancestor of " + var3);
  25.             }
  26.  
  27.             this.stack.push(var4);
  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.