001 /*
002 * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package com.sun.mirror.util;
027
028
029 import com.sun.mirror.declaration.*;
030
031
032 /**
033 * A simple visitor for declarations.
034 *
035 * <p> The implementations of the methods of this class do nothing but
036 * delegate up the declaration hierarchy. A subclass should override the
037 * methods that correspond to the kinds of declarations on which it
038 * will operate.
039 *
040 * @author Joseph D. Darcy
041 * @author Scott Seligman
042 * @since 1.5
043 */
044
045 public class SimpleDeclarationVisitor implements DeclarationVisitor {
046
047 /**
048 * Creates a new <tt>SimpleDeclarationVisitor</tt>.
049 */
050 public SimpleDeclarationVisitor(){}
051
052 /**
053 * Visits a declaration.
054 * The implementation does nothing.
055 * @param d the declaration to visit
056 */
057 public void visitDeclaration(Declaration d) {
058 }
059
060 /**
061 * Visits a package declaration.
062 * The implementation simply invokes
063 * {@link #visitDeclaration visitDeclaration}.
064 * @param d the declaration to visit
065 */
066 public void visitPackageDeclaration(PackageDeclaration d) {
067 visitDeclaration(d);
068 }
069
070 /**
071 * Visits a member or constructor declaration.
072 * The implementation simply invokes
073 * {@link #visitDeclaration visitDeclaration}.
074 * @param d the declaration to visit
075 */
076 public void visitMemberDeclaration(MemberDeclaration d) {
077 visitDeclaration(d);
078 }
079
080 /**
081 * Visits a type declaration.
082 * The implementation simply invokes
083 * {@link #visitMemberDeclaration visitMemberDeclaration}.
084 * @param d the declaration to visit
085 */
086 public void visitTypeDeclaration(TypeDeclaration d) {
087 visitMemberDeclaration(d);
088 }
089
090 /**
091 * Visits a class declaration.
092 * The implementation simply invokes
093 * {@link #visitTypeDeclaration visitTypeDeclaration}.
094 * @param d the declaration to visit
095 */
096 public void visitClassDeclaration(ClassDeclaration d) {
097 visitTypeDeclaration(d);
098 }
099
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 }