home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / INTERNET / COMMUNIC / NETCAST.Z / marimb10.jar / netscape / netcast / FileCacheEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-25  |  1.5 KB  |  54 lines

  1. package netscape.netcast;
  2.  
  3. import java.io.File;
  4. import java.util.Enumeration;
  5. import java.util.NoSuchElementException;
  6.  
  7. final class FileCacheEnumeration implements Enumeration {
  8.    FileCache cache;
  9.    File base;
  10.    File dir;
  11.    // $FF: renamed from: i int
  12.    int field_0;
  13.    // $FF: renamed from: j int
  14.    int field_1;
  15.    String[] dirs;
  16.    String[] files;
  17.    Object next;
  18.  
  19.    FileCacheEnumeration(FileCache cache, File base) {
  20.       this.cache = cache;
  21.       this.base = base;
  22.       this.dirs = base.list();
  23.       this.next = this.getNext();
  24.    }
  25.  
  26.    Object getNext() {
  27.       while(this.dirs != null && this.field_0 < this.dirs.length) {
  28.          if (this.files != null && this.field_1 < this.files.length) {
  29.             return new FileCacheFile(this.cache, this.dir, this.files[this.field_1++], -1L);
  30.          }
  31.  
  32.          this.dir = new File(this.base, this.dirs[this.field_0++]);
  33.          this.files = this.dir.list();
  34.          this.field_1 = 0;
  35.       }
  36.  
  37.       return null;
  38.    }
  39.  
  40.    public boolean hasMoreElements() {
  41.       return this.next != null;
  42.    }
  43.  
  44.    public Object nextElement() {
  45.       Object file = this.next;
  46.       if (file == null) {
  47.          throw new NoSuchElementException();
  48.       } else {
  49.          this.next = this.getNext();
  50.          return file;
  51.       }
  52.    }
  53. }
  54.