01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: ObjectArrayAnnotationVisitor.java 2059 2007-11-22 17:22:33Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.deployment.annotations.analyzer;
25:
26: import java.util.ArrayList;
27: import java.util.List;
28:
29: import org.ow2.easybeans.asm.AnnotationVisitor;
30:
31: /**
32: * This class manages the handling of Array[] type like String[] value().
33: * @param <T> the type of annotation metadata.
34: * @param <V> the type of class / erasure (for values).
35: * @author Florent Benoit
36: */
37: public abstract class ObjectArrayAnnotationVisitor<T, V> extends
38: AbsAnnotationVisitor<T> implements AnnotationVisitor,
39: AnnotationType {
40:
41: /**
42: * Array.
43: */
44: private List<V> arrayObjects = null;
45:
46: /**
47: * Init method.
48: */
49: public void init() {
50: this .arrayObjects = new ArrayList<V>();
51: }
52:
53: /**
54: * Constructor.
55: * @param annotationMetadata linked to an annotation metadata.
56: */
57: public ObjectArrayAnnotationVisitor(final T annotationMetadata) {
58: super (annotationMetadata);
59: init();
60: }
61:
62: /**
63: * Visits a primitive value of the annotation.
64: * @param name the value name.
65: * @param value the actual value, whose type must be {@link Byte},
66: * {@link Boolean}, {@link Character}, {@link Short},
67: * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
68: * {@link String} or {@link org.ow2.easybeans.asm.Type}.
69: */
70: @Override
71: @SuppressWarnings("unchecked")
72: public void visit(final String name, final Object value) {
73: this .arrayObjects.add((V) value);
74: }
75:
76: /**
77: * @return list of objects
78: */
79: public List<V> getArrayObjects() {
80: return this.arrayObjects;
81: }
82:
83: }
|