home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / sun / misc / CompoundEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  612 b   |  38 lines

  1. package sun.misc;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.NoSuchElementException;
  5.  
  6. public class CompoundEnumeration implements Enumeration {
  7.    private Enumeration[] enums;
  8.    private int index = 0;
  9.  
  10.    public CompoundEnumeration(Enumeration[] var1) {
  11.       this.enums = var1;
  12.    }
  13.  
  14.    private boolean next() {
  15.       while(this.index < this.enums.length) {
  16.          if (this.enums[this.index] != null && this.enums[this.index].hasMoreElements()) {
  17.             return true;
  18.          }
  19.  
  20.          ++this.index;
  21.       }
  22.  
  23.       return false;
  24.    }
  25.  
  26.    public boolean hasMoreElements() {
  27.       return this.next();
  28.    }
  29.  
  30.    public Object nextElement() {
  31.       if (!this.next()) {
  32.          throw new NoSuchElementException();
  33.       } else {
  34.          return this.enums[this.index].nextElement();
  35.       }
  36.    }
  37. }
  38.