home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / misc / SoftCache.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  2.5 KB  |  116 lines

  1. package sun.misc;
  2.  
  3. import java.lang.ref.ReferenceQueue;
  4. import java.util.AbstractMap;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. import java.util.Set;
  8.  
  9. public class SoftCache extends AbstractMap implements Map {
  10.    private Map hash;
  11.    private ReferenceQueue queue = new ReferenceQueue();
  12.    private Set entrySet = null;
  13.  
  14.    private void processQueue() {
  15.       ValueCell var1;
  16.       while((var1 = (ValueCell)this.queue.poll()) != null) {
  17.          if (sun.misc.SoftCache.ValueCell.access$000(var1)) {
  18.             this.hash.remove(sun.misc.SoftCache.ValueCell.access$100(var1));
  19.          } else {
  20.             sun.misc.SoftCache.ValueCell.access$210();
  21.          }
  22.       }
  23.  
  24.    }
  25.  
  26.    public SoftCache(int var1, float var2) {
  27.       this.hash = new HashMap(var1, var2);
  28.    }
  29.  
  30.    public SoftCache(int var1) {
  31.       this.hash = new HashMap(var1);
  32.    }
  33.  
  34.    public SoftCache() {
  35.       this.hash = new HashMap();
  36.    }
  37.  
  38.    public int size() {
  39.       return this.entrySet().size();
  40.    }
  41.  
  42.    public boolean isEmpty() {
  43.       return this.entrySet().isEmpty();
  44.    }
  45.  
  46.    public boolean containsKey(Object var1) {
  47.       return sun.misc.SoftCache.ValueCell.access$300(this.hash.get(var1), false) != null;
  48.    }
  49.  
  50.    protected Object fill(Object var1) {
  51.       return null;
  52.    }
  53.  
  54.    public Object get(Object var1) {
  55.       this.processQueue();
  56.       Object var2 = this.hash.get(var1);
  57.       if (var2 == null) {
  58.          var2 = this.fill(var1);
  59.          if (var2 != null) {
  60.             this.hash.put(var1, sun.misc.SoftCache.ValueCell.access$400(var1, var2, this.queue));
  61.             return var2;
  62.          }
  63.       }
  64.  
  65.       return sun.misc.SoftCache.ValueCell.access$300(var2, false);
  66.    }
  67.  
  68.    public Object put(Object var1, Object var2) {
  69.       this.processQueue();
  70.       ValueCell var3 = sun.misc.SoftCache.ValueCell.access$400(var1, var2, this.queue);
  71.       return sun.misc.SoftCache.ValueCell.access$300(this.hash.put(var1, var3), true);
  72.    }
  73.  
  74.    public Object remove(Object var1) {
  75.       this.processQueue();
  76.       return sun.misc.SoftCache.ValueCell.access$300(this.hash.remove(var1), true);
  77.    }
  78.  
  79.    public void clear() {
  80.       this.processQueue();
  81.       this.hash.clear();
  82.    }
  83.  
  84.    private static boolean valEquals(Object var0, Object var1) {
  85.       return var0 == null ? var1 == null : var0.equals(var1);
  86.    }
  87.  
  88.    public Set entrySet() {
  89.       if (this.entrySet == null) {
  90.          this.entrySet = new EntrySet(this, (1)null);
  91.       }
  92.  
  93.       return this.entrySet;
  94.    }
  95.  
  96.    // $FF: synthetic method
  97.    static ReferenceQueue access$500(SoftCache var0) {
  98.       return var0.queue;
  99.    }
  100.  
  101.    // $FF: synthetic method
  102.    static boolean access$600(Object var0, Object var1) {
  103.       return valEquals(var0, var1);
  104.    }
  105.  
  106.    // $FF: synthetic method
  107.    static Map access$700(SoftCache var0) {
  108.       return var0.hash;
  109.    }
  110.  
  111.    // $FF: synthetic method
  112.    static void access$800(SoftCache var0) {
  113.       var0.processQueue();
  114.    }
  115. }
  116.