KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)AbstractTypeVisitor6.java 1.4 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.util;
9
10 import javax.lang.model.type.*;
11
12 /**
13  * A skeletal visitor of types with default behavior appropriate for
14  * the version 6 language level.
15  *
16  * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
17  * by this class may have methods added to it in the future to
18  * accommodate new, currently unknown, language structures added to
19  * future versions of the Java&trade; programming language.
20  * Therefore, methods whose names begin with {@code "visit"} may be
21  * added to this class in the future; to avoid incompatibilities,
22  * classes which extend this class should not declare any instance
23  * methods with names beginning with {@code "visit"}.
24  *
25  * <p>When such a new visit method is added, the default
26  * implementation in this class will be to call the {@link
27  * #visitUnknown visitUnknown} method. A new abstract type visitor
28  * class will also be introduced to correspond to the new language
29  * level; this visitor will have different default behavior for the
30  * visit method in question. When the new visitor is introduced, all
31  * or portions of this visitor may be deprecated.
32  *
33  * @param <R> the return type of this visitor's methods. Use {@link
34  * Void} for visitors that do not need to return results.
35  * @param <P> the type of the additional parameter to this visitor's
36  * methods. Use {@code Void} for visitors that do not need an
37  * additional parameter.
38  *
39  * @author Joseph D. Darcy
40  * @author Scott Seligman
41  * @author Peter von der Ah&eacute;
42  * @version 1.4 06/07/31
43  * @since 1.6
44  */

45 public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
46     /**
47      * Constructor for concrete subclasses to call.
48      */

49     protected AbstractTypeVisitor6() {}
50
51     /**
52      * Visits any type mirror as if by passing itself to that type
53      * mirror's {@link TypeMirror#accept accept} method. The
54      * invocation {@code v.visit(t, p)} is equivalent to {@code
55      * t.accept(v, p)}.
56      *
57      * @param t the type to visit
58      * @param p a visitor-specified parameter
59      * @return a visitor-specified result
60      */

61     public final R visit(TypeMirror t, P p) {
62     return t.accept(this, p);
63     }
64
65     /**
66      * Visits any type mirror as if by passing itself to that type
67      * mirror's {@link TypeMirror#accept accept} method and passing
68      * {@code null} for the additional parameter. The invocation
69      * {@code v.visit(t)} is equivalent to {@code t.accept(v, null)}.
70      *
71      * @param t the type to visit
72      * @return a visitor-specified result
73      */

74     public final R visit(TypeMirror t) {
75     return t.accept(this, null);
76     }
77
78     /**
79      * {@inheritDoc}
80      *
81      * <p> The default implementation of this method in {@code
82      * AbstractTypeVisitor6} will always throw {@code
83      * UnknownTypeException}. This behavior is not required of a
84      * subclass.
85      *
86      * @param t the type to visit
87      * @return a visitor-specified result
88      * @throws UnknownTypeException
89      * a visitor implementation may optionally throw this exception
90      */

91     public R visitUnknown(TypeMirror t, P p) {
92     throw new UnknownTypeException(t, p);
93     }
94 }
95
Popular Tags