1 30 31 package oracle.toplink.libraries.asm; 32 33 39 40 final class Item { 41 42 45 46 short index; 47 48 54 55 int type; 56 57 60 61 int intVal; 62 63 66 67 long longVal; 68 69 72 73 float floatVal; 74 75 78 79 double doubleVal; 80 81 85 86 String strVal1; 87 88 92 93 String strVal2; 94 95 99 100 String strVal3; 101 102 105 106 int hashCode; 107 108 112 113 Item next; 114 115 118 119 Item () { 120 } 121 122 128 129 Item (final short index, final Item i) { 130 this.index = index; 131 type = i.type; 132 intVal = i.intVal; 133 longVal = i.longVal; 134 floatVal = i.floatVal; 135 doubleVal = i.doubleVal; 136 strVal1 = i.strVal1; 137 strVal2 = i.strVal2; 138 strVal3 = i.strVal3; 139 hashCode = i.hashCode; 140 } 141 142 147 148 void set (final int intVal) { 149 this.type = ClassWriter.INT; 150 this.intVal = intVal; 151 this.hashCode = 0x7FFFFFFF & (type + intVal); 152 } 153 154 159 160 void set (final long longVal) { 161 this.type = ClassWriter.LONG; 162 this.longVal = longVal; 163 this.hashCode = 0x7FFFFFFF & (type + (int)longVal); 164 } 165 166 171 172 void set (final float floatVal) { 173 this.type = ClassWriter.FLOAT; 174 this.floatVal = floatVal; 175 this.hashCode = 0x7FFFFFFF & (type + (int)floatVal); 176 } 177 178 183 184 void set (final double doubleVal) { 185 this.type = ClassWriter.DOUBLE; 186 this.doubleVal = doubleVal; 187 this.hashCode = 0x7FFFFFFF & (type + (int)doubleVal); 188 } 189 190 198 199 void set ( 200 final int type, 201 final String strVal1, 202 final String strVal2, 203 final String strVal3) 204 { 205 this.type = type; 206 this.strVal1 = strVal1; 207 this.strVal2 = strVal2; 208 this.strVal3 = strVal3; 209 switch (type) { 210 case ClassWriter.UTF8: 211 case ClassWriter.STR: 212 case ClassWriter.CLASS: 213 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()); 214 return; 215 case ClassWriter.NAME_TYPE: 216 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()*strVal2.hashCode()); 217 return; 218 default: 222 hashCode = 0x7FFFFFFF & (type + 223 strVal1.hashCode()*strVal2.hashCode()*strVal3.hashCode()); 224 } 225 } 226 227 234 235 boolean isEqualTo (final Item i) { 236 if (i.type == type) { 237 switch (type) { 238 case ClassWriter.INT: 239 return i.intVal == intVal; 240 case ClassWriter.LONG: 241 return i.longVal == longVal; 242 case ClassWriter.FLOAT: 243 return i.floatVal == floatVal; 244 case ClassWriter.DOUBLE: 245 return i.doubleVal == doubleVal; 246 case ClassWriter.UTF8: 247 case ClassWriter.STR: 248 case ClassWriter.CLASS: 249 return i.strVal1.equals(strVal1); 250 case ClassWriter.NAME_TYPE: 251 return i.strVal1.equals(strVal1) && 252 i.strVal2.equals(strVal2); 253 default: 257 return i.strVal1.equals(strVal1) && 258 i.strVal2.equals(strVal2) && 259 i.strVal3.equals(strVal3); 260 } 261 } 262 return false; 263 } 264 } 265 | Popular Tags |