]> source.dussan.org Git - aspectj.git/commitdiff
More accessors for the different types of value.
authoraclement <aclement>
Sat, 26 Feb 2005 15:20:51 +0000 (15:20 +0000)
committeraclement <aclement>
Sat, 26 Feb 2005 15:20:51 +0000 (15:20 +0000)
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java

index 339365e54070bc9d67844e0797125c0e3f2dd0e1..452f15199b6bc9614f086f79df09397889c02fd3 100644 (file)
@@ -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();
     }