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.declaration.*;
  30 
  31 
  32 /**
  33  * A simple visitor for declarations.
  34  *
  35  * <p> The implementations of the methods of this class do nothing but
  36  * delegate up the declaration hierarchy.  A subclass should override the
  37  * methods that correspond to the kinds of declarations on which it
  38  * will operate.
  39  *
  40  * @author Joseph D. Darcy
  41  * @author Scott Seligman
  42  * @since 1.5
  43  */
  44 
  45 public class SimpleDeclarationVisitor implements DeclarationVisitor {
  46 
  47     /**
  48      * Creates a new <tt>SimpleDeclarationVisitor</tt>.
  49      */
  50     public SimpleDeclarationVisitor(){}
  51 
  52     /**
  53      * Visits a declaration.
  54      * The implementation does nothing.
  55      * @param d the declaration to visit
  56      */
  57     public void visitDeclaration(Declaration d) {
  58     }
  59 
  60     /**
  61      * Visits a package declaration.
  62      * The implementation simply invokes
  63      * {@link #visitDeclaration visitDeclaration}.
  64      * @param d the declaration to visit
  65      */
  66     public void visitPackageDeclaration(PackageDeclaration d) {
  67         visitDeclaration(d);
  68     }
  69 
  70     /**
  71      * Visits a member or constructor declaration.
  72      * The implementation simply invokes
  73      * {@link #visitDeclaration visitDeclaration}.
  74      * @param d the declaration to visit
  75      */
  76     public void visitMemberDeclaration(MemberDeclaration d) {
  77         visitDeclaration(d);
  78     }
  79 
  80     /**
  81      * Visits a type declaration.
  82      * The implementation simply invokes
  83      * {@link #visitMemberDeclaration visitMemberDeclaration}.
  84      * @param d the declaration to visit
  85      */
  86     public void visitTypeDeclaration(TypeDeclaration d) {
  87         visitMemberDeclaration(d);
  88     }
  89 
  90     /**
  91      * Visits a class declaration.
  92      * The implementation simply invokes
  93      * {@link #visitTypeDeclaration visitTypeDeclaration}.
  94      * @param d the declaration to visit
  95      */
  96     public void visitClassDeclaration(ClassDeclaration d) {
  97         visitTypeDeclaration(d);
  98     }
  99 
 100     /**
 101      * Visits an enum declaration.
 102      * The implementation simply invokes
 103      * {@link #visitClassDeclaration visitClassDeclaration}.
 104      * @param d the declaration to visit
 105      */
 106     public void visitEnumDeclaration(EnumDeclaration d) {
 107         visitClassDeclaration(d);
 108     }
 109 
 110     /**
 111      * Visits an interface declaration.
 112      * The implementation simply invokes
 113      * {@link #visitTypeDeclaration visitTypeDeclaration}.
 114      * @param d the declaration to visit
 115      */
 116     public void visitInterfaceDeclaration(InterfaceDeclaration d) {
 117         visitTypeDeclaration(d);
 118     }
 119 
 120     /**
 121      * Visits an annotation type declaration.
 122      * The implementation simply invokes
 123      * {@link #visitInterfaceDeclaration visitInterfaceDeclaration}.
 124      * @param d the declaration to visit
 125      */
 126     public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
 127         visitInterfaceDeclaration(d);
 128     }
 129 
 130     /**
 131      * Visits a field declaration.
 132      * The implementation simply invokes
 133      * {@link #visitMemberDeclaration visitMemberDeclaration}.
 134      * @param d the declaration to visit
 135      */
 136     public void visitFieldDeclaration(FieldDeclaration d) {
 137         visitMemberDeclaration(d);
 138     }
 139 
 140     /**
 141      * Visits an enum constant declaration.
 142      * The implementation simply invokes
 143      * {@link #visitFieldDeclaration visitFieldDeclaration}.
 144      * @param d the declaration to visit
 145      */
 146     public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
 147         visitFieldDeclaration(d);
 148     }
 149 
 150     /**
 151      * Visits a method or constructor declaration.
 152      * The implementation simply invokes
 153      * {@link #visitMemberDeclaration visitMemberDeclaration}.
 154      * @param d the declaration to visit
 155      */
 156     public void visitExecutableDeclaration(ExecutableDeclaration d) {
 157         visitMemberDeclaration(d);
 158     }
 159 
 160     /**
 161      * Visits a constructor declaration.
 162      * The implementation simply invokes
 163      * {@link #visitExecutableDeclaration visitExecutableDeclaration}.
 164      * @param d the declaration to visit
 165      */
 166     public void visitConstructorDeclaration(ConstructorDeclaration d) {
 167         visitExecutableDeclaration(d);
 168     }
 169 
 170     /**
 171      * Visits a method declaration.
 172      * The implementation simply invokes
 173      * {@link #visitExecutableDeclaration visitExecutableDeclaration}.
 174      * @param d the declaration to visit
 175      */
 176     public void visitMethodDeclaration(MethodDeclaration d) {
 177         visitExecutableDeclaration(d);
 178     }
 179 
 180     /**
 181      * Visits an annotation type element declaration.
 182      * The implementation simply invokes
 183      * {@link #visitMethodDeclaration visitMethodDeclaration}.
 184      * @param d the declaration to visit
 185      */
 186     public void visitAnnotationTypeElementDeclaration(
 187             AnnotationTypeElementDeclaration d) {
 188         visitMethodDeclaration(d);
 189     }
 190 
 191     /**
 192      * Visits a parameter declaration.
 193      * The implementation simply invokes
 194      * {@link #visitDeclaration visitDeclaration}.
 195      * @param d the declaration to visit
 196      */
 197     public void visitParameterDeclaration(ParameterDeclaration d) {
 198         visitDeclaration(d);
 199     }
 200 
 201     /**
 202      * Visits a type parameter declaration.
 203      * The implementation simply invokes
 204      * {@link #visitDeclaration visitDeclaration}.
 205      * @param d the declaration to visit
 206      */
 207     public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {
 208         visitDeclaration(d);
 209     }
 210 }