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 / Service$LazyIterator.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.4 KB  |  86 lines

  1. package sun.misc;
  2.  
  3. import java.io.IOException;
  4. import java.net.URL;
  5. import java.util.Enumeration;
  6. import java.util.Iterator;
  7. import java.util.NoSuchElementException;
  8. import java.util.Set;
  9. import java.util.TreeSet;
  10.  
  11. class Service$LazyIterator implements Iterator {
  12.    Class service;
  13.    ClassLoader loader;
  14.    Enumeration configs;
  15.    Iterator pending;
  16.    Set returned;
  17.    String nextName;
  18.  
  19.    private Service$LazyIterator(Class var1, ClassLoader var2) {
  20.       this.configs = null;
  21.       this.pending = null;
  22.       this.returned = new TreeSet();
  23.       this.nextName = null;
  24.       this.service = var1;
  25.       this.loader = var2;
  26.    }
  27.  
  28.    public boolean hasNext() throws ServiceConfigurationError {
  29.       if (this.nextName != null) {
  30.          return true;
  31.       } else {
  32.          if (this.configs == null) {
  33.             try {
  34.                String var1 = "META-INF/services/" + this.service.getName();
  35.                if (this.loader == null) {
  36.                   this.configs = ClassLoader.getSystemResources(var1);
  37.                } else {
  38.                   this.configs = this.loader.getResources(var1);
  39.                }
  40.             } catch (IOException var2) {
  41.                Service.access$000(this.service, ": " + var2);
  42.             }
  43.          }
  44.  
  45.          while(this.pending == null || !this.pending.hasNext()) {
  46.             if (!this.configs.hasMoreElements()) {
  47.                return false;
  48.             }
  49.  
  50.             this.pending = Service.access$100(this.service, (URL)this.configs.nextElement(), this.returned);
  51.          }
  52.  
  53.          this.nextName = (String)this.pending.next();
  54.          return true;
  55.       }
  56.    }
  57.  
  58.    public Object next() throws ServiceConfigurationError {
  59.       if (!this.hasNext()) {
  60.          throw new NoSuchElementException();
  61.       } else {
  62.          String var1 = this.nextName;
  63.          this.nextName = null;
  64.  
  65.          try {
  66.             return Class.forName(var1, true, this.loader).newInstance();
  67.          } catch (ClassNotFoundException var4) {
  68.             Service.access$000(this.service, "Provider " + var1 + " not found");
  69.          } catch (Exception var5) {
  70.             Service.access$000(this.service, "Provider " + var1 + " could not be instantiated: " + var5);
  71.          }
  72.  
  73.          return null;
  74.       }
  75.    }
  76.  
  77.    public void remove() {
  78.       throw new UnsupportedOperationException();
  79.    }
  80.  
  81.    // $FF: synthetic method
  82.    Service$LazyIterator(Class var1, ClassLoader var2, Service.1 var3) {
  83.       this(var1, var2);
  84.    }
  85. }
  86.