Adds a number or string constant to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. @param cst the value of the constant to be added to the constant pool. This parameter must be an java.lang.Integer Integer, a {@link j
(final Object cst)
| 646 | */ |
| 647 | |
| 648 | Item newCst (final Object cst) { |
| 649 | if (cst instanceof Integer) { |
| 650 | int val = ((Integer)cst).intValue(); |
| 651 | return newInteger(val); |
| 652 | } else if (cst instanceof Float) { |
| 653 | float val = ((Float)cst).floatValue(); |
| 654 | return newFloat(val); |
| 655 | } else if (cst instanceof Long) { |
| 656 | long val = ((Long)cst).longValue(); |
| 657 | return newLong(val); |
| 658 | } else if (cst instanceof Double) { |
| 659 | double val = ((Double)cst).doubleValue(); |
| 660 | return newDouble(val); |
| 661 | } else if (cst instanceof String) { |
| 662 | return newString((String)cst); |
| 663 | } else { |
| 664 | throw new IllegalArgumentException("value " + cst); |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | /** |
| 669 | * Adds an UTF string to the constant pool of the class being build. Does |