1 23 24 25 package com.sun.jdo.api.persistence.enhancer.classfile; 26 27 import java.io.*; 28 29 33 34 public class ConstNameAndType extends ConstBasic { 35 36 public static final int MyTag = CONSTANTNameAndType; 37 38 39 private ConstUtf8 theName; 40 41 43 private int theNameIndex; 44 45 46 private ConstUtf8 typeSignature; 47 48 50 private int typeSignatureIndex; 51 52 53 54 57 public int tag () { return MyTag; } 58 59 62 public ConstUtf8 name() { 63 return theName; 64 } 65 66 69 public ConstUtf8 signature() { 70 return typeSignature; 71 } 72 73 76 public void changeSignature(ConstUtf8 newSig) { 77 typeSignature = newSig; 78 } 79 80 83 public String toString () { 84 return "CONSTANTNameAndType(" + indexAsString() + "): " + "name(" + theName.toString() + ") " + " type(" + typeSignature.toString() + ")"; } 88 89 90 91 ConstNameAndType (ConstUtf8 n, ConstUtf8 sig) { 92 theName = n; typeSignature = sig; 93 } 94 95 ConstNameAndType (int n, int sig) { 96 theNameIndex = n; typeSignatureIndex = sig; 97 } 98 99 void formatData (DataOutputStream b) throws IOException { 100 b.writeShort(theName.getIndex()); 101 b.writeShort(typeSignature.getIndex()); 102 } 103 104 static ConstNameAndType read (DataInputStream input) throws IOException { 105 int cname = input.readUnsignedShort(); 106 int sig = input.readUnsignedShort(); 107 108 return new ConstNameAndType (cname, sig); 109 } 110 111 void resolve (ConstantPool p) { 112 theName = (ConstUtf8) p.constantAt(theNameIndex); 113 typeSignature = (ConstUtf8) p.constantAt(typeSignatureIndex); 114 } 115 } 116 117 118 | Popular Tags |