*/
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;
}
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;
+ }
}
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() {