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