1 21 22 package org.apache.derby.iapi.services.classfile; 23 24 import org.apache.derby.iapi.services.classfile.VMDescriptor; 25 import java.io.IOException ; 26 27 28 29 30 public final class CONSTANT_Utf8_info extends ConstantPoolEntry { 31 private final String value; 32 private int asString; 33 private int asCode; 34 35 CONSTANT_Utf8_info(String value) { 36 super(VMDescriptor.CONSTANT_Utf8); 37 this.value = value; 38 } 39 40 Object getKey() { 41 return value; 42 } 43 44 48 int classFileSize() { 49 return 1 + 2 + value.length(); 51 } 52 53 public String toString() { 54 return value; 55 } 56 57 int setAsCode() { 60 if (ClassHolder.isExternalClassName(value)) 61 { 62 if (asString == 0) { 63 asCode = getIndex(); 65 } 66 67 return asCode; 68 } 69 return getIndex(); 72 } 73 74 int setAsString() { 75 if (ClassHolder.isExternalClassName(value)) 76 { 77 78 if (asCode == 0) { 79 asString = getIndex(); 81 } 82 return asString; 83 } 84 85 return getIndex(); 88 } 89 90 void setAlternative(int index) { 91 92 if (asCode == 0) 93 asCode = index; 94 else 95 asString = index; 96 } 97 98 void put(ClassFormatOutput out) throws IOException { 99 super.put(out); 100 101 if (getIndex() == asCode) 102 { 103 out.writeUTF(ClassHolder.convertToInternalClassName(value)); 104 } 105 else 106 out.writeUTF(value); 107 } 108 } 109 | Popular Tags |