01: package com.bm.ejb3metadata.annotations.analyzer;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.ejb3unit.asm.AnnotationVisitor;
07:
08: /**
09: * This class manages the handling of Array[] type like String[] value().
10: * @param <T> the type of annotation metadata.
11: * @param <V> the type of class / erasure (for values).
12: * @author Daniel Wiese
13: */
14: public abstract class ObjectArrayAnnotationVisitor<T, V> extends
15: AbsAnnotationVisitor<T> implements AnnotationVisitor,
16: AnnotationType {
17:
18: /**
19: * Array.
20: */
21: private List<V> arrayObjects = null;
22:
23: /**
24: * Init method.
25: */
26: public void init() {
27: this .arrayObjects = new ArrayList<V>();
28: }
29:
30: /**
31: * Constructor.
32: * @param annotationMetadata linked to an annotation metadata.
33: */
34: public ObjectArrayAnnotationVisitor(final T annotationMetadata) {
35: super (annotationMetadata);
36: init();
37: }
38:
39: /**
40: * Visits a primitive value of the annotation.
41: * @param name the value name.
42: * @param value the actual value, whose type must be {@link Byte},
43: * {@link Boolean}, {@link Character}, {@link Short},
44: * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
45: * {@link String} or {@link org.ejb3unit.asm.Type}.
46: */
47: @Override
48: @SuppressWarnings("unchecked")
49: public void visit(final String name, final Object value) {
50: this .arrayObjects.add((V) value);
51: }
52:
53: /**
54: * @return list of objects
55: */
56: public List<V> getArrayObjects() {
57: return this.arrayObjects;
58: }
59:
60: }
|