home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / net / ProgressEntry.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.5 KB  |  77 lines

  1. package sun.net;
  2.  
  3. public class ProgressEntry {
  4.    public static final int HTML = 0;
  5.    public static final int IMAGE = 1;
  6.    public static final int CLASS = 2;
  7.    public static final int AUDIO = 3;
  8.    public static final int OTHER = 4;
  9.    public int need;
  10.    public int read;
  11.    public int what;
  12.    public int index;
  13.    public boolean connected = false;
  14.    public String label;
  15.    public int type;
  16.  
  17.    public ProgressEntry(String var1, String var2) {
  18.       this.label = var1;
  19.       this.type = 4;
  20.       this.need = 0;
  21.       this.setType(var1, var2);
  22.    }
  23.  
  24.    public void setType(String var1, String var2) {
  25.       if (var2 != null) {
  26.          if (var2.startsWith("image")) {
  27.             this.type = 1;
  28.          } else if (var2.startsWith("audio")) {
  29.             this.type = 3;
  30.          } else if (var2.equals("application/java-vm")) {
  31.             this.type = 2;
  32.          } else if (var2.startsWith("text/html")) {
  33.             this.type = 0;
  34.          }
  35.       }
  36.  
  37.       if (this.type == 4) {
  38.          if (var1.endsWith(".html") || var1.endsWith("/") || var1.endsWith(".htm")) {
  39.             this.type = 0;
  40.             return;
  41.          }
  42.  
  43.          if (var1.endsWith(".class")) {
  44.             this.type = 2;
  45.             return;
  46.          }
  47.  
  48.          if (var1.endsWith(".gif") || var1.endsWith(".xbm") || var1.endsWith(".jpeg") || var1.endsWith(".jpg") || var1.endsWith(".jfif")) {
  49.             this.type = 1;
  50.             return;
  51.          }
  52.  
  53.          if (var1.endsWith(".au")) {
  54.             this.type = 3;
  55.          }
  56.       }
  57.  
  58.    }
  59.  
  60.    public void update(int var1, int var2) {
  61.       if (this.need == 0) {
  62.          this.need = var2;
  63.       }
  64.  
  65.       this.read = var1;
  66.    }
  67.  
  68.    public synchronized boolean connected() {
  69.       if (!this.connected) {
  70.          this.connected = true;
  71.          return false;
  72.       } else {
  73.          return true;
  74.       }
  75.    }
  76. }
  77.