home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / misc / CompoundEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  714 b   |  38 lines

  1. package sun.misc;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.NoSuchElementException;
  5.  
  6. public class CompoundEnumeration<E> implements Enumeration<E> {
  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 E nextElement() {
  31.       if (!this.next()) {
  32.          throw new NoSuchElementException();
  33.       } else {
  34.          return (E)this.enums[this.index].nextElement();
  35.       }
  36.    }
  37. }
  38.