KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > examples > visitor > template > _Visitor_


1 package spoon.examples.visitor.template;
2
3 /**
4  * This intermediate type is used to represent the visitor type in a generic
5  * manner. Every reference to it in a template code will be substituted by a
6  * reference to the type defined by a type template parameter named "_Visitor_".
7  *
8  * <p>
9  * When progamming templates, using intermediate types that act like shadows for
10  * concrete type is often required. In several case, they can be avoided by
11  * using a type parameter (aka generics) that stands for a concrete type and
12  * that will be substituted. However, in this case, since we want to precise
13  * that the type holds a parameterized method, we need to define it as an
14  * intermediate interface.
15  */

16 interface _Visitor_ {
17     /**
18      * This method stands for the visitation methods of the visitor. Here,
19      * "_target_" is a string template parameter that contains the simple name
20      * of a visited class. The visited element passed as a parameter is of an
21      * unknown type and is hence set to <code>Object</code>.
22      */

23     void visit_target_(Object JavaDoc e);
24 }
Popular Tags