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 / Ref.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  650 b   |  47 lines

  1. package sun.misc;
  2.  
  3. import java.lang.ref.Reference;
  4. import java.lang.ref.SoftReference;
  5.  
  6. public abstract class Ref {
  7.    private SoftReference soft = null;
  8.  
  9.    public synchronized Object get() {
  10.       Object var1 = this.check();
  11.       if (var1 == null) {
  12.          var1 = this.reconstitute();
  13.          this.setThing(var1);
  14.       }
  15.  
  16.       return var1;
  17.    }
  18.  
  19.    public abstract Object reconstitute();
  20.  
  21.    public synchronized void flush() {
  22.       SoftReference var1 = this.soft;
  23.       if (var1 != null) {
  24.          ((Reference)var1).clear();
  25.       }
  26.  
  27.       this.soft = null;
  28.    }
  29.  
  30.    public synchronized void setThing(Object var1) {
  31.       this.flush();
  32.       this.soft = new SoftReference(var1);
  33.    }
  34.  
  35.    public synchronized Object check() {
  36.       SoftReference var1 = this.soft;
  37.       return var1 == null ? null : var1.get();
  38.    }
  39.  
  40.    public Ref() {
  41.    }
  42.  
  43.    public Ref(Object var1) {
  44.       this.setThing(var1);
  45.    }
  46. }
  47.