KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > lang > model > element > AnnotationValueVisitor


1 /*
2  * @(#)AnnotationValueVisitor.java 1.6 06/07/31
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.lang.model.element;
9
10
11 import java.util.List JavaDoc;
12
13 import javax.lang.model.type.TypeMirror;
14
15
16 /**
17  * A visitor of the values of annotation type elements, using a
18  * variant of the visitor design pattern. Unlike a standard visitor
19  * which dispatches based on the concrete type of a member of a type
20  * hierarchy, this visitor dispatches based on the type of data
21  * stored; there are no distinct subclasses for storing, for example,
22  * {@code boolean} values versus {@code int} values. Classes
23  * implementing this interface are used to operate on a value when the
24  * type of that value is unknown at compile time. When a visitor is
25  * passed to a value's {@link AnnotationValue#accept accept} method,
26  * the <tt>visit<i>XYZ</i></tt> method applicable to that value is
27  * invoked.
28  *
29  * <p> Classes implementing this interface may or may not throw a
30  * {@code NullPointerException} if the additional parameter {@code p}
31  * is {@code null}; see documentation of the implementing class for
32  * details.
33  *
34  * <p> <b>WARNING:</b> It is possible that methods will be added to
35  * this interface to accommodate new, currently unknown, language
36  * structures added to future versions of the Java&trade; programming
37  * language. Therefore, visitor classes directly implementing this
38  * interface may be source incompatible with future versions of the
39  * platform. To avoid this source incompatibility, visitor
40  * implementations are encouraged to instead extend the appropriate
41  * abstract visitor class that implements this interface. However, an
42  * API should generally use this visitor interface as the type for
43  * parameters, return type, etc. rather than one of the abstract
44  * classes.
45  *
46  * @param <R> the return type of this visitor's methods
47  * @param <P> the type of the additional parameter to this visitor's methods.
48  * @author Joseph D. Darcy
49  * @author Scott Seligman
50  * @author Peter von der Ah&eacute;
51  * @version 1.6 06/07/31
52  * @since 1.6
53  */

54 public interface AnnotationValueVisitor<R, P> {
55     /**
56      * Visits an annotation value.
57      * @param av the value to visit
58      * @param p a visitor-specified parameter
59      * @return a visitor-specified result
60      */

61     R visit(AnnotationValue av, P p);
62
63     /**
64      * A convenience method equivalent to {@code v.visit(av, null)}.
65      * @param av the value to visit
66      * @return a visitor-specified result
67      */

68     R visit(AnnotationValue av);
69
70     /**
71      * Visits a {@code boolean} value in an annotation.
72      * @param b the value being visited
73      * @param p a visitor-specified parameter
74      * @return the result of the visit
75      */

76     R visitBoolean(boolean b, P p);
77
78     /**
79      * Visits a {@code byte} value in an annotation.
80      * @param b the value being visited
81      * @param p a visitor-specified parameter
82      * @return the result of the visit
83      */

84     R visitByte(byte b, P p);
85
86     /**
87      * Visits a {@code char} value in an annotation.
88      * @param c the value being visited
89      * @param p a visitor-specified parameter
90      * @return the result of the visit
91      */

92     R visitChar(char c, P p);
93
94     /**
95      * Visits a {@code double} value in an annotation.
96      * @param d the value being visited
97      * @param p a visitor-specified parameter
98      * @return the result of the visit
99      */

100     R visitDouble(double d, P p);
101
102     /**
103      * Visits a {@code float} value in an annotation.
104      * @param f the value being visited
105      * @param p a visitor-specified parameter
106      * @return the result of the visit
107      */

108     R visitFloat(float f, P p);
109
110     /**
111      * Visits an {@code int} value in an annotation.
112      * @param i the value being visited
113      * @param p a visitor-specified parameter
114      * @return the result of the visit
115      */

116     R visitInt(int i, P p);
117
118     /**
119      * Visits a {@code long} value in an annotation.
120      * @param i the value being visited
121      * @param p a visitor-specified parameter
122      * @return the result of the visit
123      */

124     R visitLong(long i, P p);
125
126     /**
127      * Visits a {@code short} value in an annotation.
128      * @param s the value being visited
129      * @param p a visitor-specified parameter
130      * @return the result of the visit
131      */

132     R visitShort(short s, P p);
133
134     /**
135      * Visits a string value in an annotation.
136      * @param s the value being visited
137      * @param p a visitor-specified parameter
138      * @return the result of the visit
139      */

140     R visitString(String JavaDoc s, P p);
141
142     /**
143      * Visits a type value in an annotation.
144      * @param t the value being visited
145      * @param p a visitor-specified parameter
146      * @return the result of the visit
147      */

148     R visitType(TypeMirror t, P p);
149
150     /**
151      * Visits an {@code enum} value in an annotation.
152      * @param c the value being visited
153      * @param p a visitor-specified parameter
154      * @return the result of the visit
155      */

156     R visitEnumConstant(VariableElement c, P p);
157
158     /**
159      * Visits an annotation value in an annotation.
160      * @param a the value being visited
161      * @param p a visitor-specified parameter
162      * @return the result of the visit
163      */

164     R visitAnnotation(AnnotationMirror a, P p);
165
166     /**
167      * Visits an array value in an annotation.
168      * @param vals the value being visited
169      * @param p a visitor-specified parameter
170      * @return the result of the visit
171      */

172     R visitArray(List JavaDoc<? extends AnnotationValue> vals, P p);
173
174     /**
175      * Visits an unknown kind of annotation value.
176      * This can occur if the language evolves and new kinds
177      * of value can be stored in an annotation.
178      * @param av the unknown value being visited
179      * @param p a visitor-specified parameter
180      * @return the result of the visit
181      * @throws UnknownAnnotationValueException
182      * a visitor implementation may optionally throw this exception
183      */

184     R visitUnknown(AnnotationValue av, P p);
185 }
186
Popular Tags