summaryrefslogtreecommitdiffstats
path: root/bcel-builder
diff options
context:
space:
mode:
authoraclement <aclement>2008-02-25 21:26:01 +0000
committeraclement <aclement>2008-02-25 21:26:01 +0000
commit4cb79c2713f8c039d89419d4441de5895f304e95 (patch)
tree8f9048baaf8a799277cb8fc638e57b660ddd9a59 /bcel-builder
parentffa12d32408bae510865d0923efe8cd3cfc4d96a (diff)
downloadaspectj-4cb79c2713f8c039d89419d4441de5895f304e95.tar.gz
aspectj-4cb79c2713f8c039d89419d4441de5895f304e95.zip
annoValMatch: able to ask annotation about its values and their settings
Diffstat (limited to 'bcel-builder')
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java25
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java11
2 files changed, 34 insertions, 2 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java
index 4b609fd06..ac81ec805 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java
@@ -30,6 +30,7 @@ import org.aspectj.apache.bcel.classfile.Utility;
*/
public class Annotation {
private int typeIndex;
+ // OPTIMIZE don't need a new list instance for every annotation instance!
private List /* ElementNameValuePair */ evs = new ArrayList();
private ConstantPool cpool;
private boolean isRuntimeVisible;
@@ -127,4 +128,28 @@ public class Annotation {
}
return result.toString();
}
+
+ /**
+ * Return true if the annotation has a value with the specified name (n) and value (v)
+ */
+ public boolean hasNameValuePair(String n, String v) {
+ for (int i=0;i<evs.size();i++) {
+ ElementNameValuePair pair = (ElementNameValuePair)evs.get(i);
+ if (pair.getNameString().equals(n)) {
+ if (pair.getValue().stringifyValue().equals(v)) return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Return true if the annotation has a value with the specified name (n)
+ */
+ public boolean hasNamedValue(String n) {
+ for (int i=0;i<evs.size();i++) {
+ ElementNameValuePair pair = (ElementNameValuePair)evs.get(i);
+ if (pair.getNameString().equals(n)) return true;
+ }
+ return false;
+ }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java
index c08418cc8..4960949e5 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java
@@ -40,9 +40,16 @@ public class EnumElementValue extends ElementValue {
dos.writeShort(valueIdx); // u2
}
+ /**
+ * return signature and value, something like Lp/Color;RED
+ */
public String stringifyValue() {
- ConstantUtf8 cu8 = (ConstantUtf8)cpool.getConstant(valueIdx,Constants.CONSTANT_Utf8);
- return cu8.getBytes();
+ StringBuffer sb = new StringBuffer();
+ ConstantUtf8 cu8 = (ConstantUtf8)cpool.getConstant(typeIdx,Constants.CONSTANT_Utf8);
+ sb.append(cu8.getBytes());
+ cu8 = (ConstantUtf8)cpool.getConstant(valueIdx,Constants.CONSTANT_Utf8);
+ sb.append(cu8.getBytes());
+ return sb.toString();
}
public String getEnumTypeString() {