1.1 --- a/javap/src/main/java/org/apidesign/javap/AnnotationParser.java Tue Dec 04 12:23:06 2012 +0100
1.2 +++ b/javap/src/main/java/org/apidesign/javap/AnnotationParser.java Sun Feb 03 18:58:09 2013 +0100
1.3 @@ -35,9 +35,11 @@
1.4 */
1.5 public class AnnotationParser {
1.6 private final boolean textual;
1.7 + private final boolean iterateArray;
1.8
1.9 - protected AnnotationParser(boolean textual) {
1.10 + protected AnnotationParser(boolean textual, boolean iterateArray) {
1.11 this.textual = textual;
1.12 + this.iterateArray = iterateArray;
1.13 }
1.14
1.15 protected void visitAnnotationStart(String type) throws IOException {
1.16 @@ -45,6 +47,13 @@
1.17
1.18 protected void visitAnnotationEnd(String type) throws IOException {
1.19 }
1.20 +
1.21 + protected void visitValueStart(String attrName, char type) throws IOException {
1.22 + }
1.23 +
1.24 + protected void visitValueEnd(String attrName, char type) throws IOException {
1.25 + }
1.26 +
1.27
1.28 protected void visitAttr(
1.29 String annoType, String attr, String attrType, String value
1.30 @@ -89,9 +98,11 @@
1.31 }
1.32 }
1.33
1.34 - private void readValue(DataInputStream dis, ClassData cd, String typeName, String attrName)
1.35 - throws IOException {
1.36 + private void readValue(
1.37 + DataInputStream dis, ClassData cd, String typeName, String attrName
1.38 + ) throws IOException {
1.39 char type = (char)dis.readByte();
1.40 + visitValueStart(attrName, type);
1.41 if (type == '@') {
1.42 readAnno(dis, cd);
1.43 } else if ("CFJZsSIDB".indexOf(type) >= 0) { // NOI18N
1.44 @@ -112,13 +123,20 @@
1.45 } else if (type == '[') {
1.46 int cnt = dis.readUnsignedShort();
1.47 for (int i = 0; i < cnt; i++) {
1.48 - readValue(dis, cd, typeName, attrName);
1.49 + readValue(dis, cd, typeName, iterateArray ? attrName : null);
1.50 }
1.51 } else if (type == 'e') {
1.52 int enumT = dis.readUnsignedShort();
1.53 + String attrType = cd.stringValue(enumT, textual);
1.54 int enumN = dis.readUnsignedShort();
1.55 + String val = cd.stringValue(enumN, textual);
1.56 + if (textual) {
1.57 + val = '"' + val + '"';
1.58 + }
1.59 + visitAttr(typeName, attrName, attrType, val);
1.60 } else {
1.61 throw new IOException("Unknown type " + type);
1.62 }
1.63 + visitValueEnd(attrName, type);
1.64 }
1.65 }