1 26 package net.sf.javaguard.classfile; 27 28 import java.io.*; 29 30 31 36 public class StringCpInfo extends CpInfo { 37 38 private int nameIndex; 39 40 41 42 43 45 protected StringCpInfo() { 46 super(CONSTANT_String); 47 } 48 49 50 51 52 56 protected void setNameIndex(int index) { 57 this.nameIndex = index; 58 } 59 60 61 65 protected int getNameIndex() { 66 return nameIndex; 67 } 68 69 70 71 72 75 protected void markUtf8Refs(ConstantPool pool) { 76 pool.incRefCount(getNameIndex()); 77 } 78 79 80 81 82 86 protected void readInfo(DataInput din) 87 throws IOException { 88 setNameIndex(din.readUnsignedShort()); 89 } 90 91 92 96 protected void writeInfo(DataOutput dout) 97 throws IOException { 98 dout.writeShort(getNameIndex()); 99 } 100 101 102 103 104 109 public void dump(PrintWriter pw, ClassFile cf, int index) { 110 pw.print('['); pw.print(index); pw.println("]: StringCpInfo"); 111 pw.print(" -> string name index: "); 112 pw.println(getNameIndex()); 113 pw.print(" string: '"); 114 pw.print( ((Utf8CpInfo) cf.getCpEntry(getNameIndex())).getString()); 115 pw.println('\''); 116 } 117 } 118 | Popular Tags |