aboutsummaryrefslogtreecommitdiffstats
path: root/bcel-builder
diff options
context:
space:
mode:
Diffstat (limited to 'bcel-builder')
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java
index 339365e54..452f15199 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java
@@ -56,6 +56,56 @@ public class SimpleElementValue extends ElementValue {
return c.getBytes();
}
+ public byte getValueByte() {
+ if (type != PRIMITIVE_BYTE)
+ throw new RuntimeException("Dont call getValueByte() on a non BYTE ElementValue");
+ ConstantInteger c = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer);
+ return (byte)c.getBytes();
+ }
+
+ public char getValueChar() {
+ if (type != PRIMITIVE_CHAR)
+ throw new RuntimeException("Dont call getValueChar() on a non CHAR ElementValue");
+ ConstantInteger c = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer);
+ return (char)c.getBytes();
+ }
+
+ public long getValueLong() {
+ if (type != PRIMITIVE_LONG)
+ throw new RuntimeException("Dont call getValueLong() on a non LONG ElementValue");
+ ConstantLong j = (ConstantLong)cpool.getConstant(idx);
+ return j.getBytes();
+ }
+
+ public float getValueFloat() {
+ if (type != PRIMITIVE_FLOAT)
+ throw new RuntimeException("Dont call getValueFloat() on a non FLOAT ElementValue");
+ ConstantFloat f = (ConstantFloat)cpool.getConstant(idx);
+ return f.getBytes();
+ }
+
+
+ public double getValueDouble() {
+ if (type != PRIMITIVE_DOUBLE)
+ throw new RuntimeException("Dont call getValueDouble() on a non DOUBLE ElementValue");
+ ConstantDouble d = (ConstantDouble)cpool.getConstant(idx);
+ return d.getBytes();
+ }
+
+ public boolean getValueBoolean() {
+ if (type != PRIMITIVE_BOOLEAN)
+ throw new RuntimeException("Dont call getValueBoolean() on a non BOOLEAN ElementValue");
+ ConstantInteger bo = (ConstantInteger)cpool.getConstant(idx);
+ return (bo.getBytes()!=0);
+ }
+
+ public short getValueShort() {
+ if (type != PRIMITIVE_SHORT)
+ throw new RuntimeException("Dont call getValueShort() on a non SHORT ElementValue");
+ ConstantInteger s = (ConstantInteger)cpool.getConstant(idx);
+ return (short)s.getBytes();
+ }
+
public String toString() {
return stringifyValue();
}