home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / INTERNET / COMMUNIC / NETCAST.Z / marimb10.jar / netscape / netcast / MappedFileCacheEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-25  |  1.5 KB  |  38 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 MappedFileCacheEnumeration implements Enumeration {
  8.    MappedFileCache cache;
  9.    File base;
  10.    File dir;
  11.    Object next;
  12.    int slot;
  13.  
  14.    MappedFileCacheEnumeration(MappedFileCache cache) {
  15.       this.cache = cache;
  16.       this.dir = cache.dir;
  17.       this.next = this.getNext();
  18.    }
  19.  
  20.    Object getNext() {
  21.       return this.slot < this.cache.count ? new MappedFileCacheFile(this.cache, this.dir, this.cache.makeName(this.cache.getName(this.slot)), -1L, this.cache.getChecksum(this.slot++)) : null;
  22.    }
  23.  
  24.    public boolean hasMoreElements() {
  25.       return this.next != null;
  26.    }
  27.  
  28.    public Object nextElement() {
  29.       Object file = this.next;
  30.       if (file == null) {
  31.          throw new NoSuchElementException();
  32.       } else {
  33.          this.next = this.getNext();
  34.          return file;
  35.       }
  36.    }
  37. }
  38.