001: /*
002: * @(#)SimpleDeclarationVisitor.java 1.3 04/04/30
003: *
004: * Copyright (c) 2004, Sun Microsystems, Inc.
005: * All rights reserved.
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions are met:
009: *
010: * * Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: * * Neither the name of the Sun Microsystems, Inc. nor the names of
016: * its contributors may be used to endorse or promote products derived from
017: * this software without specific prior written permission.
018: *
019: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
020: * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
021: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
022: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
023: * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
024: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
025: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
026: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
027: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
028: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
029: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030: */
031:
032: package com.sun.mirror.util;
033:
034: import com.sun.mirror.declaration.*;
035:
036: /**
037: * A simple visitor for declarations.
038: *
039: * <p> The implementations of the methods of this class do nothing but
040: * delegate up the declaration hierarchy. A subclass should override the
041: * methods that correspond to the kinds of declarations on which it
042: * will operate.
043: *
044: * @author Joseph D. Darcy
045: * @author Scott Seligman
046: * @version 1.3 04/04/30
047: * @since 1.5
048: */
049:
050: public class SimpleDeclarationVisitor implements DeclarationVisitor {
051:
052: /**
053: * Creates a new <tt>SimpleDeclarationVisitor</tt>.
054: */
055: public SimpleDeclarationVisitor() {
056: }
057:
058: /**
059: * Visits a declaration.
060: * The implementation does nothing.
061: * @param d the declaration to visit
062: */
063: public void visitDeclaration(Declaration d) {
064: }
065:
066: /**
067: * Visits a package declaration.
068: * The implementation simply invokes
069: * {@link #visitDeclaration visitDeclaration}.
070: * @param d the declaration to visit
071: */
072: public void visitPackageDeclaration(PackageDeclaration d) {
073: visitDeclaration(d);
074: }
075:
076: /**
077: * Visits a member or constructor declaration.
078: * The implementation simply invokes
079: * {@link #visitDeclaration visitDeclaration}.
080: * @param d the declaration to visit
081: */
082: public void visitMemberDeclaration(MemberDeclaration d) {
083: visitDeclaration(d);
084: }
085:
086: /**
087: * Visits a type declaration.
088: * The implementation simply invokes
089: * {@link #visitMemberDeclaration visitMemberDeclaration}.
090: * @param d the declaration to visit
091: */
092: public void visitTypeDeclaration(TypeDeclaration d) {
093: visitMemberDeclaration(d);
094: }
095:
096: /**
097: * Visits a class declaration.
098: * The implementation simply invokes
099: * {@link #visitTypeDeclaration visitTypeDeclaration}.
100: * @param d the declaration to visit
101: */
102: public void visitClassDeclaration(ClassDeclaration d) {
103: visitTypeDeclaration(d);
104: }
105:
106: /**
107: * Visits an enum declaration.
108: * The implementation simply invokes
109: * {@link #visitClassDeclaration visitClassDeclaration}.
110: * @param d the declaration to visit
111: */
112: public void visitEnumDeclaration(EnumDeclaration d) {
113: visitClassDeclaration(d);
114: }
115:
116: /**
117: * Visits an interface declaration.
118: * The implementation simply invokes
119: * {@link #visitTypeDeclaration visitTypeDeclaration}.
120: * @param d the declaration to visit
121: */
122: public void visitInterfaceDeclaration(InterfaceDeclaration d) {
123: visitTypeDeclaration(d);
124: }
125:
126: /**
127: * Visits an annotation type declaration.
128: * The implementation simply invokes
129: * {@link #visitInterfaceDeclaration visitInterfaceDeclaration}.
130: * @param d the declaration to visit
131: */
132: public void visitAnnotationTypeDeclaration(
133: AnnotationTypeDeclaration d) {
134: visitInterfaceDeclaration(d);
135: }
136:
137: /**
138: * Visits a field declaration.
139: * The implementation simply invokes
140: * {@link #visitMemberDeclaration visitMemberDeclaration}.
141: * @param d the declaration to visit
142: */
143: public void visitFieldDeclaration(FieldDeclaration d) {
144: visitMemberDeclaration(d);
145: }
146:
147: /**
148: * Visits an enum constant declaration.
149: * The implementation simply invokes
150: * {@link #visitFieldDeclaration visitFieldDeclaration}.
151: * @param d the declaration to visit
152: */
153: public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
154: visitFieldDeclaration(d);
155: }
156:
157: /**
158: * Visits a method or constructor declaration.
159: * The implementation simply invokes
160: * {@link #visitMemberDeclaration visitMemberDeclaration}.
161: * @param d the declaration to visit
162: */
163: public void visitExecutableDeclaration(ExecutableDeclaration d) {
164: visitMemberDeclaration(d);
165: }
166:
167: /**
168: * Visits a constructor declaration.
169: * The implementation simply invokes
170: * {@link #visitExecutableDeclaration visitExecutableDeclaration}.
171: * @param d the declaration to visit
172: */
173: public void visitConstructorDeclaration(ConstructorDeclaration d) {
174: visitExecutableDeclaration(d);
175: }
176:
177: /**
178: * Visits a method declaration.
179: * The implementation simply invokes
180: * {@link #visitExecutableDeclaration visitExecutableDeclaration}.
181: * @param d the declaration to visit
182: */
183: public void visitMethodDeclaration(MethodDeclaration d) {
184: visitExecutableDeclaration(d);
185: }
186:
187: /**
188: * Visits an annotation type element declaration.
189: * The implementation simply invokes
190: * {@link #visitMethodDeclaration visitMethodDeclaration}.
191: * @param d the declaration to visit
192: */
193: public void visitAnnotationTypeElementDeclaration(
194: AnnotationTypeElementDeclaration d) {
195: visitMethodDeclaration(d);
196: }
197:
198: /**
199: * Visits a parameter declaration.
200: * The implementation simply invokes
201: * {@link #visitDeclaration visitDeclaration}.
202: * @param d the declaration to visit
203: */
204: public void visitParameterDeclaration(ParameterDeclaration d) {
205: visitDeclaration(d);
206: }
207:
208: /**
209: * Visits a type parameter declaration.
210: * The implementation simply invokes
211: * {@link #visitDeclaration visitDeclaration}.
212: * @param d the declaration to visit
213: */
214: public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {
215: visitDeclaration(d);
216: }
217: }
|