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 ConstantUtf8Info extends CPInfo { 22 23 private String string; 24 25 public byte getTag() { 26 return CONSTANT_UTF8; 27 } 28 29 public String getTagVerbose() { 30 return CONSTANT_UTF8_VERBOSE; 31 } 32 33 public String getVerbose() throws InvalidByteCodeException { 34 return string; 35 } 36 37 42 public byte[] getBytes() { 43 return string.getBytes(); 44 } 45 46 51 public String getString() { 52 return string; 53 } 54 55 61 public void setBytes(byte[] bytes) { 62 string = new String (bytes); 63 } 64 65 70 public void setString(String string) { 71 this.string = string; 72 } 73 74 public void read(DataInput in) 75 throws InvalidByteCodeException, IOException { 76 77 string = in.readUTF(); 78 79 if (debug) debug("read "); 80 } 81 82 public void write(DataOutput out) 83 throws InvalidByteCodeException, IOException { 84 85 out.writeByte(CONSTANT_UTF8); 86 out.writeUTF(string); 87 if (debug) debug("wrote "); 88 } 89 90 protected void debug(String message) { 91 super.debug(message + getTagVerbose() + " with length " + string.length() + 92 " (\"" + string + "\")"); 93 } 94 95 public boolean equals(Object object) { 96 if (!(object instanceof ConstantUtf8Info)) { 97 return false; 98 } 99 ConstantUtf8Info constantUtf8Info = (ConstantUtf8Info)object; 100 return super.equals(object) && constantUtf8Info.string.equals(string); 101 } 102 103 public int hashCode() { 104 return super.hashCode() ^ string.hashCode(); 105 } 106 107 108 } 109 | Popular Tags |