diff options
author | aclement <aclement> | 2005-02-26 15:20:51 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-02-26 15:20:51 +0000 |
commit | 13e4bfbf76d0caba1ca4f4d61901017fc800f6cb (patch) | |
tree | 6da171063aa7e1bfa27114e09e0c8524e8556917 | |
parent | 0549a5959680a171bdd89c9cd49e4042fab256df (diff) | |
download | aspectj-13e4bfbf76d0caba1ca4f4d61901017fc800f6cb.tar.gz aspectj-13e4bfbf76d0caba1ca4f4d61901017fc800f6cb.zip |
More accessors for the different types of value.
-rw-r--r-- | bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java | 50 |
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(); } |