KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > lang > model > util > SimpleAnnotationValueVisitor6


1 /*
2  * @(#)SimpleAnnotationValueVisitor6.java 1.6 06/08/15
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.util;
9
10
11 import java.util.List JavaDoc;
12 import javax.lang.model.element.*;
13
14 import javax.lang.model.type.TypeMirror;
15 import static javax.lang.model.SourceVersion.*;
16 import javax.lang.model.SourceVersion;
17 import javax.annotation.processing.SupportedSourceVersion;
18
19 /**
20  * A simple visitor for annotation values with default behavior
21  * appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
22  * source version. Visit methods call {@link
23  * #defaultAction} passing their arguments to {@code defaultAction}'s
24  * corresponding parameters.
25  *
26  * <p> Methods in this class may be overridden subject to their
27  * general contract. Note that annotating methods in concrete
28  * subclasses with {@link java.lang.Override @Override} will help
29  * ensure that methods are overridden as intended.
30  *
31  * <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
32  * implemented by this class may have methods added to it in the
33  * future to accommodate new, currently unknown, language structures
34  * added to future versions of the Java&trade; programming language.
35  * Therefore, methods whose names begin with {@code "visit"} may be
36  * added to this class in the future; to avoid incompatibilities,
37  * classes which extend this class should not declare any instance
38  * methods with names beginning with {@code "visit"}.
39  *
40  * <p>When such a new visit method is added, the default
41  * implementation in this class will be to call the {@link
42  * #visitUnknown visitUnknown} method. A new simple annotation
43  * value visitor class will also be introduced to correspond to the
44  * new language level; this visitor will have different default
45  * behavior for the visit method in question. When the new visitor is
46  * introduced, all or portions of this visitor may be deprecated.
47  *
48  * @param <R> the return type of this visitor's methods
49  * @param <P> the type of the additional parameter to this visitor's methods.
50  *
51  * @author Joseph D. Darcy
52  * @author Scott Seligman
53  * @author Peter von der Ah&eacute;
54  * @version 1.6 06/08/15
55  * @since 1.6
56  */

57 @SupportedSourceVersion(RELEASE_6)
58 public class SimpleAnnotationValueVisitor6<R, P>
59     extends AbstractAnnotationValueVisitor6<R, P> {
60
61     /**
62      * Default value to be returned; {@link #defaultAction
63      * defaultAction} returns this value unless the method is
64      * overridden.
65      */

66     protected final R DEFAULT_VALUE;
67
68     /**
69      * Constructor for concrete subclasses; uses {@code null} for the
70      * default value.
71      */

72     protected SimpleAnnotationValueVisitor6() {
73     super();
74     DEFAULT_VALUE = null;
75     }
76
77     /**
78      * Constructor for concrete subclasses; uses the argument for the
79      * default value.
80      *
81      * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
82      */

83     protected SimpleAnnotationValueVisitor6(R defaultValue) {
84     super();
85     DEFAULT_VALUE = defaultValue;
86     }
87
88     /**
89      * The default action for visit methods. The implementation in
90      * this class just returns {@link #DEFAULT_VALUE}; subclasses will
91      * commonly override this method.
92      *
93      * @param o the value of the annotation
94      * @param p a visitor-specified parameter
95      * @return {@code DEFAULT_VALUE} unless overridden
96      */

97     protected R defaultAction(Object JavaDoc o, P p) {
98     return DEFAULT_VALUE;
99     }
100
101     /**
102      * {@inheritDoc} This implementation calls {@code defaultAction}.
103      *
104      * @param b {@inheritDoc}
105      * @param p {@inheritDoc}
106      * @return the result of {@code defaultAction}
107      */

108     public R visitBoolean(boolean b, P p) {
109     return defaultAction(b, p);
110     }
111
112     /**
113      * {@inheritDoc} This implementation calls {@code defaultAction}.
114      *
115      * @param b {@inheritDoc}
116      * @param p {@inheritDoc}
117      * @return the result of {@code defaultAction}
118      */

119     public R visitByte(byte b, P p) {
120     return defaultAction(b, p);
121     }
122
123     /**
124      * {@inheritDoc} This implementation calls {@code defaultAction}.
125      *
126      * @param c {@inheritDoc}
127      * @param p {@inheritDoc}
128      * @return the result of {@code defaultAction}
129      */

130     public R visitChar(char c, P p) {
131     return defaultAction(c, p);
132     }
133
134     /**
135      * {@inheritDoc} This implementation calls {@code defaultAction}.
136      *
137      * @param d {@inheritDoc}
138      * @param p {@inheritDoc}
139      * @return the result of {@code defaultAction}
140      */

141     public R visitDouble(double d, P p) {
142     return defaultAction(d, p);
143     }
144
145     /**
146      * {@inheritDoc} This implementation calls {@code defaultAction}.
147      *
148      * @param f {@inheritDoc}
149      * @param p {@inheritDoc}
150      * @return the result of {@code defaultAction}
151      */

152     public R visitFloat(float f, P p) {
153     return defaultAction(f, p);
154     }
155
156     /**
157      * {@inheritDoc} This implementation calls {@code defaultAction}.
158      *
159      * @param i {@inheritDoc}
160      * @param p {@inheritDoc}
161      * @return the result of {@code defaultAction}
162      */

163     public R visitInt(int i, P p) {
164     return defaultAction(i, p);
165     }
166
167     /**
168      * {@inheritDoc} This implementation calls {@code defaultAction}.
169      *
170      * @param i {@inheritDoc}
171      * @param p {@inheritDoc}
172      * @return the result of {@code defaultAction}
173      */

174     public R visitLong(long i, P p) {
175     return defaultAction(i, p);
176     }
177
178     /**
179      * {@inheritDoc} This implementation calls {@code defaultAction}.
180      *
181      * @param s {@inheritDoc}
182      * @param p {@inheritDoc}
183      * @return the result of {@code defaultAction}
184      */

185     public R visitShort(short s, P p) {
186     return defaultAction(s, p);
187     }
188
189     /**
190      * {@inheritDoc} This implementation calls {@code defaultAction}.
191      *
192      * @param s {@inheritDoc}
193      * @param p {@inheritDoc}
194      * @return the result of {@code defaultAction}
195      */

196     public R visitString(String JavaDoc s, P p) {
197     return defaultAction(s, p);
198     }
199
200     /**
201      * {@inheritDoc} This implementation calls {@code defaultAction}.
202      *
203      * @param t {@inheritDoc}
204      * @param p {@inheritDoc}
205      * @return the result of {@code defaultAction}
206      */

207     public R visitType(TypeMirror t, P p) {
208     return defaultAction(t, p);
209     }
210
211     /**
212      * {@inheritDoc} This implementation calls {@code defaultAction}.
213      *
214      * @param c {@inheritDoc}
215      * @param p {@inheritDoc}
216      * @return the result of {@code defaultAction}
217      */

218     public R visitEnumConstant(VariableElement c, P p) {
219     return defaultAction(c, p);
220     }
221
222     /**
223      * {@inheritDoc} This implementation calls {@code defaultAction}.
224      *
225      * @param a {@inheritDoc}
226      * @param p {@inheritDoc}
227      * @return the result of {@code defaultAction}
228      */

229     public R visitAnnotation(AnnotationMirror a, P p) {
230     return defaultAction(a, p);
231     }
232
233     /**
234      * {@inheritDoc} This implementation calls {@code defaultAction}.
235      *
236      * @param vals {@inheritDoc}
237      * @param p {@inheritDoc}
238      * @return the result of {@code defaultAction}
239      */

240     public R visitArray(List JavaDoc<? extends AnnotationValue> vals, P p) {
241     return defaultAction(vals, p);
242     }
243 }
244
Popular Tags