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 / ProxyGenerator$ConstantPool.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.4 KB  |  130 lines

  1. package sun.misc;
  2.  
  3. import java.io.DataOutputStream;
  4. import java.io.IOException;
  5. import java.io.OutputStream;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10.  
  11. class ProxyGenerator$ConstantPool {
  12.    private List pool;
  13.    private Map map;
  14.    private boolean readOnly;
  15.  
  16.    private ProxyGenerator$ConstantPool() {
  17.       this.pool = new ArrayList(32);
  18.       this.map = new HashMap(16);
  19.       this.readOnly = false;
  20.    }
  21.  
  22.    public short getUtf8(String var1) {
  23.       if (var1 == null) {
  24.          throw new NullPointerException();
  25.       } else {
  26.          return this.getValue(var1);
  27.       }
  28.    }
  29.  
  30.    public short getInteger(int var1) {
  31.       return this.getValue(new Integer(var1));
  32.    }
  33.  
  34.    public short getFloat(float var1) {
  35.       return this.getValue(new Float(var1));
  36.    }
  37.  
  38.    public short getLong(long var1) {
  39.       return this.getValue(new Long(var1));
  40.    }
  41.  
  42.    public short getDouble(double var1) {
  43.       return this.getValue(new Double(var1));
  44.    }
  45.  
  46.    public short getClass(String var1) {
  47.       short var2 = this.getUtf8(var1);
  48.       return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(7, var2));
  49.    }
  50.  
  51.    public short getString(String var1) {
  52.       short var2 = this.getUtf8(var1);
  53.       return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(8, var2));
  54.    }
  55.  
  56.    public short getFieldRef(String var1, String var2, String var3) {
  57.       short var4 = this.getClass(var1);
  58.       short var5 = this.getNameAndType(var2, var3);
  59.       return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(9, var4, var5));
  60.    }
  61.  
  62.    public short getMethodRef(String var1, String var2, String var3) {
  63.       short var4 = this.getClass(var1);
  64.       short var5 = this.getNameAndType(var2, var3);
  65.       return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(10, var4, var5));
  66.    }
  67.  
  68.    public short getInterfaceMethodRef(String var1, String var2, String var3) {
  69.       short var4 = this.getClass(var1);
  70.       short var5 = this.getNameAndType(var2, var3);
  71.       return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(11, var4, var5));
  72.    }
  73.  
  74.    public short getNameAndType(String var1, String var2) {
  75.       short var3 = this.getUtf8(var1);
  76.       short var4 = this.getUtf8(var2);
  77.       return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(12, var3, var4));
  78.    }
  79.  
  80.    public void setReadOnly() {
  81.       this.readOnly = true;
  82.    }
  83.  
  84.    public void write(OutputStream var1) throws IOException {
  85.       DataOutputStream var2 = new DataOutputStream(var1);
  86.       var2.writeShort(this.pool.size() + 1);
  87.  
  88.       for(ProxyGenerator.ConstantPool.Entry var4 : this.pool) {
  89.          var4.write(var2);
  90.       }
  91.  
  92.    }
  93.  
  94.    private short addEntry(ProxyGenerator.ConstantPool.Entry var1) {
  95.       this.pool.add(var1);
  96.       return (short)this.pool.size();
  97.    }
  98.  
  99.    private short getValue(Object var1) {
  100.       Short var2 = (Short)this.map.get(var1);
  101.       if (var2 != null) {
  102.          return var2;
  103.       } else if (this.readOnly) {
  104.          throw new InternalError("late constant pool addition: " + var1);
  105.       } else {
  106.          short var3 = this.addEntry(new ProxyGenerator.ConstantPool.ValueEntry(var1));
  107.          this.map.put(var1, new Short(var3));
  108.          return var3;
  109.       }
  110.    }
  111.  
  112.    private short getIndirect(ProxyGenerator.ConstantPool.IndirectEntry var1) {
  113.       Short var2 = (Short)this.map.get(var1);
  114.       if (var2 != null) {
  115.          return var2;
  116.       } else if (this.readOnly) {
  117.          throw new InternalError("late constant pool addition");
  118.       } else {
  119.          short var3 = this.addEntry(var1);
  120.          this.map.put(var1, new Short(var3));
  121.          return var3;
  122.       }
  123.    }
  124.  
  125.    // $FF: synthetic method
  126.    ProxyGenerator$ConstantPool(ProxyGenerator.1 var1) {
  127.       this();
  128.    }
  129. }
  130.