1 7 8 package org.gjt.jclasslib.structures.constants; 9 10 import org.gjt.jclasslib.structures.CPInfo; 11 import org.gjt.jclasslib.structures.InvalidByteCodeException; 12 13 import java.io.*; 14 15 21 public class ConstantClassInfo extends CPInfo { 22 23 24 public static final int SIZE = 2; 25 26 private int nameIndex; 27 28 public byte getTag() { 29 return CONSTANT_CLASS; 30 } 31 32 public String getTagVerbose() { 33 return CONSTANT_CLASS_VERBOSE; 34 } 35 36 public String getVerbose() throws InvalidByteCodeException { 37 return getName(); 38 } 39 40 44 public int getNameIndex() { 45 return nameIndex; 46 } 47 48 52 public void setNameIndex(int nameIndex) { 53 this.nameIndex = nameIndex; 54 } 55 56 61 public String getName() throws InvalidByteCodeException { 62 return classFile.getConstantPoolUtf8Entry(nameIndex).getString(); 63 } 64 65 public void read(DataInput in) 66 throws InvalidByteCodeException, IOException { 67 68 nameIndex = in.readUnsignedShort(); 69 if (debug) debug("read "); 70 } 71 72 public void write(DataOutput out) 73 throws InvalidByteCodeException, IOException { 74 75 out.writeByte(CONSTANT_CLASS); 76 out.writeShort(nameIndex); 77 if (debug) debug("wrote "); 78 } 79 80 public boolean equals(Object object) { 81 if (!(object instanceof ConstantClassInfo)) { 82 return false; 83 } 84 ConstantClassInfo constantClassInfo = (ConstantClassInfo)object; 85 return super.equals(object) && constantClassInfo.nameIndex == nameIndex; 86 } 87 88 public int hashCode() { 89 return super.hashCode() ^ nameIndex; 90 } 91 92 protected void debug(String message) { 93 super.debug(message + getTagVerbose() + " with name_index " + nameIndex); 94 } 95 96 } 97 | Popular Tags |