1 4 package gnu.bytecode; 5 import java.io.*; 6 7 8 9 public class CpoolClass extends CpoolEntry { 10 CpoolUtf8 name; 11 12 CpoolClass () { } 13 14 CpoolClass (ConstantPool cpool, int hash, CpoolUtf8 n) 15 { 16 super (cpool, hash); 17 name = n; 18 } 19 20 public int getTag() { return ConstantPool.CLASS; } 21 22 public final CpoolUtf8 getName() 23 { 24 return name; 25 } 26 27 28 public final String getStringName() 29 { 30 return name.string; 31 } 32 33 34 public final ObjectType getClassType () 35 { 36 String name = this.name.string; 37 if (name.charAt (0) == '[') 38 return (ObjectType)Type.signatureToType (name); 39 else 40 return ClassType.make (name.replace ('/', '.')); 41 } 42 43 final static int hashCode (CpoolUtf8 name) 44 { 45 return name.hashCode() ^ 0xF0F; 46 } 47 48 public int hashCode () 49 { 50 if (hash == 0) 51 hash = hashCode(name); 52 return hash; 53 } 54 55 void write (DataOutputStream dstr) throws java.io.IOException 56 { 57 dstr.writeByte (ConstantPool.CLASS); 58 dstr.writeShort (name.index); 59 } 60 61 public void print (ClassTypeWriter dst, int verbosity) 62 { 63 if (verbosity == 1) 64 dst.print("Class "); 65 else if (verbosity > 1) 66 { 67 dst.print("Class name: "); 68 dst.printOptionalIndex(name); 69 } 70 dst.print(name.string.replace('/', '.')); 71 } 72 } 73 | Popular Tags |