1 52 53 package com.go.trove.classfile; 54 55 import java.io.*; 56 57 65 public class ConstantStringInfo extends ConstantInfo { 66 private String mStr; 67 68 private ConstantUTFInfo mStringConstant; 69 70 75 static ConstantStringInfo make(ConstantPool cp, String str) { 76 ConstantInfo ci = new ConstantStringInfo(cp, str); 77 return (ConstantStringInfo)cp.addConstant(ci); 78 } 79 80 ConstantStringInfo(ConstantUTFInfo constant) { 81 super(TAG_STRING); 82 mStr = constant.getValue(); 83 mStringConstant = constant; 84 } 85 86 private ConstantStringInfo(ConstantPool cp, String str) { 87 super(TAG_STRING); 88 mStr = str; 89 mStringConstant = ConstantUTFInfo.make(cp, str); 90 } 91 92 public String getValue() { 93 return mStr; 94 } 95 96 public int hashCode() { 97 return mStr.hashCode(); 98 } 99 100 public boolean equals(Object obj) { 101 if (obj instanceof ConstantStringInfo) { 102 ConstantStringInfo other = (ConstantStringInfo)obj; 103 return mStr.equals(other.mStr); 104 } 105 106 return false; 107 } 108 109 boolean hasPriority() { 110 return true; 111 } 112 113 public void writeTo(DataOutput dout) throws IOException { 114 super.writeTo(dout); 115 dout.writeShort(mStringConstant.getIndex()); 116 } 117 118 public String toString() { 119 return "CONSTANT_String_info: " + getValue(); 120 } 121 } 122 | Popular Tags |