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 FieldRefCPInfo extends ConstantPoolEntry { 28 29 private String fieldClassName; 30 31 private String fieldName; 32 33 private String fieldType; 34 35 private int classIndex; 36 37 private int nameAndTypeIndex; 38 39 40 public FieldRefCPInfo() { 41 super(CONSTANT_FIELDREF, 1); 42 } 43 44 52 public void read(DataInputStream cpStream) throws IOException { 53 classIndex = cpStream.readUnsignedShort(); 54 nameAndTypeIndex = cpStream.readUnsignedShort(); 55 } 56 57 64 public void resolve(ConstantPool constantPool) { 65 ClassCPInfo fieldClass 66 = (ClassCPInfo) constantPool.getEntry(classIndex); 67 68 fieldClass.resolve(constantPool); 69 70 fieldClassName = fieldClass.getClassName(); 71 72 NameAndTypeCPInfo nt 73 = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex); 74 75 nt.resolve(constantPool); 76 77 fieldName = nt.getName(); 78 fieldType = nt.getType(); 79 80 super.resolve(constantPool); 81 } 82 83 88 public String toString() { 89 String value; 90 91 if (isResolved()) { 92 value = "Field : Class = " + fieldClassName + ", name = " 93 + fieldName + ", type = " + fieldType; 94 } else { 95 value = "Field : Class index = " + classIndex 96 + ", name and type index = " + nameAndTypeIndex; 97 } 98 99 return value; 100 } 101 102 107 public String getFieldClassName() { 108 return fieldClassName; 109 } 110 111 116 public String getFieldName() { 117 return fieldName; 118 } 119 120 125 public String getFieldType() { 126 return fieldType; 127 } 128 129 } 130 131 | Popular Tags |