KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > deployment > annotations > analyzer > ObjectArrayAnnotationVisitor


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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 9 2006-02-19 18:53:32Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.deployment.annotations.analyzer;
27
28 import java.util.ArrayList JavaDoc;
29 import java.util.List JavaDoc;
30
31 import org.objectweb.asm.AnnotationVisitor;
32
33 /**
34  * This class manages the handling of Array[] type like String[] value().
35  * @param <T> the type of annotation metadata.
36  * @param <V> the type of class / erasure (for values).
37  * @author Florent Benoit
38  */

39 public abstract class ObjectArrayAnnotationVisitor<T, V>
40                  extends AbsAnnotationVisitor<T>
41                  implements AnnotationVisitor, AnnotationType {
42
43     /**
44      * Array.
45      */

46     private List JavaDoc<V> arrayObjects = null;
47
48     /**
49      * Init method.
50      */

51     public void init() {
52         this.arrayObjects = new ArrayList JavaDoc<V>();
53     }
54
55     /**
56      * Constructor.
57      * @param annotationMetadata linked to an annotation metadata.
58      */

59     public ObjectArrayAnnotationVisitor(final T annotationMetadata) {
60         super(annotationMetadata);
61         init();
62     }
63
64
65     /**
66      * Visits a primitive value of the annotation.
67      * @param name the value name.
68      * @param value the actual value, whose type must be {@link Byte},
69      * {@link Boolean}, {@link Character}, {@link Short},
70      * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
71      * {@link String} or {@link org.objectweb.asm.Type}.
72      */

73     @Override JavaDoc
74     @SuppressWarnings JavaDoc("unchecked")
75     public void visit(final String JavaDoc name, final Object JavaDoc value) {
76         this.arrayObjects.add((V) value);
77     }
78
79     /**
80      * @return list of objects
81      */

82     public List JavaDoc<V> getArrayObjects() {
83         return this.arrayObjects;
84     }
85
86 }
87
Popular Tags