home *** CD-ROM | disk | FTP | other *** search
- package sun.misc;
-
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- class ProxyGenerator$ConstantPool {
- private List pool;
- private Map map;
- private boolean readOnly;
-
- private ProxyGenerator$ConstantPool() {
- this.pool = new ArrayList(32);
- this.map = new HashMap(16);
- this.readOnly = false;
- }
-
- public short getUtf8(String var1) {
- if (var1 == null) {
- throw new NullPointerException();
- } else {
- return this.getValue(var1);
- }
- }
-
- public short getInteger(int var1) {
- return this.getValue(new Integer(var1));
- }
-
- public short getFloat(float var1) {
- return this.getValue(new Float(var1));
- }
-
- public short getLong(long var1) {
- return this.getValue(new Long(var1));
- }
-
- public short getDouble(double var1) {
- return this.getValue(new Double(var1));
- }
-
- public short getClass(String var1) {
- short var2 = this.getUtf8(var1);
- return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(7, var2));
- }
-
- public short getString(String var1) {
- short var2 = this.getUtf8(var1);
- return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(8, var2));
- }
-
- public short getFieldRef(String var1, String var2, String var3) {
- short var4 = this.getClass(var1);
- short var5 = this.getNameAndType(var2, var3);
- return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(9, var4, var5));
- }
-
- public short getMethodRef(String var1, String var2, String var3) {
- short var4 = this.getClass(var1);
- short var5 = this.getNameAndType(var2, var3);
- return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(10, var4, var5));
- }
-
- public short getInterfaceMethodRef(String var1, String var2, String var3) {
- short var4 = this.getClass(var1);
- short var5 = this.getNameAndType(var2, var3);
- return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(11, var4, var5));
- }
-
- public short getNameAndType(String var1, String var2) {
- short var3 = this.getUtf8(var1);
- short var4 = this.getUtf8(var2);
- return this.getIndirect(new ProxyGenerator.ConstantPool.IndirectEntry(12, var3, var4));
- }
-
- public void setReadOnly() {
- this.readOnly = true;
- }
-
- public void write(OutputStream var1) throws IOException {
- DataOutputStream var2 = new DataOutputStream(var1);
- var2.writeShort(this.pool.size() + 1);
-
- for(ProxyGenerator.ConstantPool.Entry var4 : this.pool) {
- var4.write(var2);
- }
-
- }
-
- private short addEntry(ProxyGenerator.ConstantPool.Entry var1) {
- this.pool.add(var1);
- return (short)this.pool.size();
- }
-
- private short getValue(Object var1) {
- Short var2 = (Short)this.map.get(var1);
- if (var2 != null) {
- return var2;
- } else if (this.readOnly) {
- throw new InternalError("late constant pool addition: " + var1);
- } else {
- short var3 = this.addEntry(new ProxyGenerator.ConstantPool.ValueEntry(var1));
- this.map.put(var1, new Short(var3));
- return var3;
- }
- }
-
- private short getIndirect(ProxyGenerator.ConstantPool.IndirectEntry var1) {
- Short var2 = (Short)this.map.get(var1);
- if (var2 != null) {
- return var2;
- } else if (this.readOnly) {
- throw new InternalError("late constant pool addition");
- } else {
- short var3 = this.addEntry(var1);
- this.map.put(var1, new Short(var3));
- return var3;
- }
- }
-
- // $FF: synthetic method
- ProxyGenerator$ConstantPool(ProxyGenerator.1 var1) {
- this();
- }
- }
-