1 25 26 package org.netbeans.modules.classfile; 27 28 33 abstract class CPName extends CPEntry { 34 35 final static int INVALID_INDEX = -1; 36 37 int index; 38 private String name; 39 40 CPName(ConstantPool pool,int index) { 41 super(pool); 42 this.index = index; 43 } 44 45 CPName(ConstantPool pool) { 46 super(pool); 47 index = INVALID_INDEX; 48 } 49 50 public String getName() { 51 if (index == INVALID_INDEX) { 52 return null; 53 } 54 if (name == null) { 55 name = ((CPName)pool.cpEntries[index]).getName(); 56 } 57 return name; 58 } 59 60 public Object getValue() { 61 return getName(); 62 } 63 64 void setNameIndex(int index) { 65 this.index = index; 66 name = null; 67 } 68 69 public String toString() { 70 return getClass().getName() + ": name=" + 71 (index == INVALID_INDEX ? "<unresolved>" : ((CPName)pool.cpEntries[index]).getName()); 73 } 74 } 75 | Popular Tags |