1 18 package org.apache.tools.ant.taskdefs.optional.depend.constantpool; 19 20 import java.io.DataInputStream ; 21 import java.io.IOException ; 22 23 27 public class MethodRefCPInfo extends ConstantPoolEntry { 28 29 private String methodClassName; 30 31 private String methodName; 32 33 private String methodType; 34 35 private int classIndex; 36 40 private int nameAndTypeIndex; 41 42 43 public MethodRefCPInfo() { 44 super(CONSTANT_METHODREF, 1); 45 } 46 47 55 public void read(DataInputStream cpStream) throws IOException { 56 classIndex = cpStream.readUnsignedShort(); 57 nameAndTypeIndex = cpStream.readUnsignedShort(); 58 } 59 60 65 public String toString() { 66 String value; 67 68 if (isResolved()) { 69 value = "Method : Class = " + methodClassName + ", name = " 70 + methodName + ", type = " + methodType; 71 } else { 72 value = "Method : Class index = " + classIndex 73 + ", name and type index = " + nameAndTypeIndex; 74 } 75 76 return value; 77 } 78 79 86 public void resolve(ConstantPool constantPool) { 87 ClassCPInfo methodClass 88 = (ClassCPInfo) constantPool.getEntry(classIndex); 89 90 methodClass.resolve(constantPool); 91 92 methodClassName = methodClass.getClassName(); 93 94 NameAndTypeCPInfo nt 95 = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex); 96 97 nt.resolve(constantPool); 98 99 methodName = nt.getName(); 100 methodType = nt.getType(); 101 102 super.resolve(constantPool); 103 } 104 105 110 public String getMethodClassName() { 111 return methodClassName; 112 } 113 114 119 public String getMethodName() { 120 return methodName; 121 } 122 123 128 public String getMethodType() { 129 return methodType; 130 } 131 132 } 133 134 | Popular Tags |