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: ObjectAnnotationVisitor.java 2059 2007-11-22 17:22:33Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.deployment.annotations.analyzer;
25:
26: import org.ow2.easybeans.asm.AnnotationVisitor;
27:
28: /**
29: * This class manages the handling of single type like String name().
30: * @param <T> the type of annotation metadata.
31: * @param <V> the type of class / erasure (for values).
32: * @author Florent Benoit
33: */
34: public abstract class ObjectAnnotationVisitor<T, V> extends
35: AbsAnnotationVisitor<T> implements AnnotationVisitor,
36: AnnotationType {
37:
38: /**
39: * Internal value in the given type.
40: */
41: private V value = null;
42:
43: /**
44: * Constructor.
45: * @param annotationMetadata linked to a metadata.
46: */
47: public ObjectAnnotationVisitor(final T annotationMetadata) {
48: super (annotationMetadata);
49: }
50:
51: /**
52: * Visits a primitive value of the annotation.
53: * @param name the value name.
54: * @param value the actual value, whose type must be {@link Byte},
55: * {@link Boolean}, {@link Character}, {@link Short},
56: * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
57: * {@link String} or {@link org.ow2.easybeans.asm.Type}.
58: */
59: @Override
60: @SuppressWarnings("unchecked")
61: public void visit(final String name, final Object value) {
62: this .value = (V) value;
63: }
64:
65: /**
66: * @return value of the object
67: */
68: public V getValue() {
69: return this.value;
70: }
71:
72: }
|