1 /*
   2  * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Sun designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Sun in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  22  * CA 95054 USA or visit www.sun.com if you need additional information or
  23  * have any questions.
  24  */
  25 
  26 package com.sun.mirror.util;
  27 
  28 
  29 import com.sun.mirror.type.*;
  30 
  31 
  32 /**
  33  * A simple visitor for types.
  34  *
  35  * <p> The implementations of the methods of this class do nothing but
  36  * delegate up the type hierarchy.  A subclass should override the
  37  * methods that correspond to the kinds of types on which it will
  38  * operate.
  39  *
  40  * @author Joseph D. Darcy
  41  * @author Scott Seligman
  42  * @since 1.5
  43  */
  44 
  45 public class SimpleTypeVisitor implements TypeVisitor {
  46 
  47     /**
  48      * Creates a new <tt>SimpleTypeVisitor</tt>.
  49      */
  50     public SimpleTypeVisitor() {}
  51 
  52     /**
  53      * Visits a type mirror.
  54      * The implementation does nothing.
  55      * @param t the type to visit
  56      */
  57     public void visitTypeMirror(TypeMirror t) {
  58     }
  59 
  60     /**
  61      * Visits a primitive type.
  62      * The implementation simply invokes
  63      * {@link #visitTypeMirror visitTypeMirror}.
  64      * @param t the type to visit
  65      */
  66     public void visitPrimitiveType(PrimitiveType t) {
  67         visitTypeMirror(t);
  68     }
  69 
  70     /**
  71      * Visits a void type.
  72      * The implementation simply invokes
  73      * {@link #visitTypeMirror visitTypeMirror}.
  74      * @param t the type to visit
  75      */
  76     public void visitVoidType(VoidType t) {
  77         visitTypeMirror(t);
  78     }
  79 
  80     /**
  81      * Visits a reference type.
  82      * The implementation simply invokes
  83      * {@link #visitTypeMirror visitTypeMirror}.
  84      * @param t the type to visit
  85      */
  86     public void visitReferenceType(ReferenceType t) {
  87         visitTypeMirror(t);
  88     }
  89 
  90     /**
  91      * Visits a declared type.
  92      * The implementation simply invokes
  93      * {@link #visitReferenceType visitReferenceType}.
  94      * @param t the type to visit
  95      */
  96     public void visitDeclaredType(DeclaredType t) {
  97         visitReferenceType(t);
  98     }
  99 
 100     /**
 101      * Visits a class type.
 102      * The implementation simply invokes
 103      * {@link #visitDeclaredType visitDeclaredType}.
 104      * @param t the type to visit
 105      */
 106     public void visitClassType(ClassType t) {
 107         visitDeclaredType(t);
 108     }
 109 
 110     /**
 111      * Visits an enum type.
 112      * The implementation simply invokes
 113      * {@link #visitClassType visitClassType}.
 114      * @param t the type to visit
 115      */
 116     public void visitEnumType(EnumType t) {
 117         visitClassType(t);
 118     }
 119 
 120     /**
 121      * Visits an interface type.
 122      * The implementation simply invokes
 123      * {@link #visitDeclaredType visitDeclaredType}.
 124      * @param t the type to visit
 125      */
 126     public void visitInterfaceType(InterfaceType t) {
 127         visitDeclaredType(t);
 128     }
 129 
 130     /**
 131      * Visits an annotation type.
 132      * The implementation simply invokes
 133      * {@link #visitInterfaceType visitInterfaceType}.
 134      * @param t the type to visit
 135      */
 136     public void visitAnnotationType(AnnotationType t) {
 137         visitInterfaceType(t);
 138     }
 139 
 140     /**
 141      * Visits an array type.
 142      * The implementation simply invokes
 143      * {@link #visitReferenceType visitReferenceType}.
 144      * @param t the type to visit
 145      */
 146     public void visitArrayType(ArrayType t) {
 147         visitReferenceType(t);
 148     }
 149 
 150     /**
 151      * Visits a type variable.
 152      * The implementation simply invokes
 153      * {@link #visitReferenceType visitReferenceType}.
 154      * @param t the type to visit
 155      */
 156     public void visitTypeVariable(TypeVariable t) {
 157         visitReferenceType(t);
 158     }
 159 
 160     /**
 161      * Visits a wildcard.
 162      * The implementation simply invokes
 163      * {@link #visitTypeMirror visitTypeMirror}.
 164      * @param t the type to visit
 165      */
 166     public void visitWildcardType(WildcardType t) {
 167         visitTypeMirror(t);
 168     }
 169 }