222 * Sets this item to an item that do not hold a primitive value. 223 * 224 * @param type 225 * the type of this item. 226 * @param strVal1 227 * first part of the value of this item. 228 * @param strVal2 229 * second part of the value of this item. 230 * @param strVal3 231 * third part of the value of this item. 232 */ 233 @SuppressWarnings("fallthrough") 234 void set(final int type, final String strVal1, final String strVal2, 235 final String strVal3) { 236 this.type = type; 237 this.strVal1 = strVal1; 238 this.strVal2 = strVal2; 239 this.strVal3 = strVal3; 240 switch (type) { 241 case ClassWriter.CLASS: 242 this.intVal = 0; // intVal of a class must be zero, see visitInnerClass 243 case ClassWriter.UTF8: 244 case ClassWriter.STR: 245 case ClassWriter.MTYPE: 246 case ClassWriter.TYPE_NORMAL: 247 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()); 248 return; 249 case ClassWriter.NAME_TYPE: { 250 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode() 251 * strVal2.hashCode()); 252 return; 253 } 254 // ClassWriter.FIELD: 255 // ClassWriter.METH: 256 // ClassWriter.IMETH: 257 // ClassWriter.HANDLE_BASE + 1..9 258 default: 259 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode() 260 * strVal2.hashCode() * strVal3.hashCode()); 261 } 294 this.type = ClassWriter.BSM; 295 this.intVal = position; 296 this.hashCode = hashCode; 297 } 298 299 /** 300 * Indicates if the given item is equal to this one. <i>This method assumes 301 * that the two items have the same {@link #type}</i>. 302 * 303 * @param i 304 * the item to be compared to this one. Both items must have the 305 * same {@link #type}. 306 * @return <tt>true</tt> if the given item if equal to this one, 307 * <tt>false</tt> otherwise. 308 */ 309 boolean isEqualTo(final Item i) { 310 switch (type) { 311 case ClassWriter.UTF8: 312 case ClassWriter.STR: 313 case ClassWriter.CLASS: 314 case ClassWriter.MTYPE: 315 case ClassWriter.TYPE_NORMAL: 316 return i.strVal1.equals(strVal1); 317 case ClassWriter.TYPE_MERGED: 318 case ClassWriter.LONG: 319 case ClassWriter.DOUBLE: 320 return i.longVal == longVal; 321 case ClassWriter.INT: 322 case ClassWriter.FLOAT: 323 return i.intVal == intVal; 324 case ClassWriter.TYPE_UNINIT: 325 return i.intVal == intVal && i.strVal1.equals(strVal1); 326 case ClassWriter.NAME_TYPE: 327 return i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2); 328 case ClassWriter.INDY: { 329 return i.longVal == longVal && i.strVal1.equals(strVal1) 330 && i.strVal2.equals(strVal2); 331 } 332 // case ClassWriter.FIELD: 333 // case ClassWriter.METH: | 222 * Sets this item to an item that do not hold a primitive value. 223 * 224 * @param type 225 * the type of this item. 226 * @param strVal1 227 * first part of the value of this item. 228 * @param strVal2 229 * second part of the value of this item. 230 * @param strVal3 231 * third part of the value of this item. 232 */ 233 @SuppressWarnings("fallthrough") 234 void set(final int type, final String strVal1, final String strVal2, 235 final String strVal3) { 236 this.type = type; 237 this.strVal1 = strVal1; 238 this.strVal2 = strVal2; 239 this.strVal3 = strVal3; 240 switch (type) { 241 case ClassWriter.CLASS: 242 case ClassWriter.MODULE: 243 case ClassWriter.PACKAGE: 244 this.intVal = 0; // intVal of a class must be zero, see visitInnerClass 245 case ClassWriter.UTF8: 246 case ClassWriter.STR: 247 case ClassWriter.MTYPE: 248 case ClassWriter.TYPE_NORMAL: 249 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()); 250 return; 251 case ClassWriter.NAME_TYPE: { 252 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode() 253 * strVal2.hashCode()); 254 return; 255 } 256 // ClassWriter.FIELD: 257 // ClassWriter.METH: 258 // ClassWriter.IMETH: 259 // ClassWriter.HANDLE_BASE + 1..9 260 default: 261 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode() 262 * strVal2.hashCode() * strVal3.hashCode()); 263 } 296 this.type = ClassWriter.BSM; 297 this.intVal = position; 298 this.hashCode = hashCode; 299 } 300 301 /** 302 * Indicates if the given item is equal to this one. <i>This method assumes 303 * that the two items have the same {@link #type}</i>. 304 * 305 * @param i 306 * the item to be compared to this one. Both items must have the 307 * same {@link #type}. 308 * @return <tt>true</tt> if the given item if equal to this one, 309 * <tt>false</tt> otherwise. 310 */ 311 boolean isEqualTo(final Item i) { 312 switch (type) { 313 case ClassWriter.UTF8: 314 case ClassWriter.STR: 315 case ClassWriter.CLASS: 316 case ClassWriter.MODULE: 317 case ClassWriter.PACKAGE: 318 case ClassWriter.MTYPE: 319 case ClassWriter.TYPE_NORMAL: 320 return i.strVal1.equals(strVal1); 321 case ClassWriter.TYPE_MERGED: 322 case ClassWriter.LONG: 323 case ClassWriter.DOUBLE: 324 return i.longVal == longVal; 325 case ClassWriter.INT: 326 case ClassWriter.FLOAT: 327 return i.intVal == intVal; 328 case ClassWriter.TYPE_UNINIT: 329 return i.intVal == intVal && i.strVal1.equals(strVal1); 330 case ClassWriter.NAME_TYPE: 331 return i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2); 332 case ClassWriter.INDY: { 333 return i.longVal == longVal && i.strVal1.equals(strVal1) 334 && i.strVal2.equals(strVal2); 335 } 336 // case ClassWriter.FIELD: 337 // case ClassWriter.METH: |