Source Code Cross Referenced for ElementKindVisitor6.java in  » 6.0-JDK-Modules-sun » javac-compiler » javax » lang » model » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules sun » javac compiler » javax.lang.model.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 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 javax.lang.model.util;
027:
028:        import javax.lang.model.element.*;
029:        import static javax.lang.model.element.ElementKind.*;
030:        import javax.annotation.processing.SupportedSourceVersion;
031:        import static javax.lang.model.SourceVersion.*;
032:        import javax.lang.model.SourceVersion;
033:
034:        /**
035:         * A visitor of program elements based on their {@linkplain
036:         * ElementKind kind} with default behavior appropriate for the {@link
037:         * SourceVersion#RELEASE_6 RELEASE_6} source version.  For {@linkplain
038:         * Element elements} <tt><i>XYZ</i></tt> that may have more than one
039:         * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
040:         * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
041:         * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
042:         * call {@link #defaultAction defaultAction}, passing their arguments
043:         * to {@code defaultAction}'s corresponding parameters.
044:         *
045:         * <p> Methods in this class may be overridden subject to their
046:         * general contract.  Note that annotating methods in concrete
047:         * subclasses with {@link java.lang.Override @Override} will help
048:         * ensure that methods are overridden as intended.
049:         * 
050:         * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
051:         * implemented by this class may have methods added to it or the
052:         * {@code ElementKind} {@code enum} used in this case may have
053:         * constants added to it in the future to accommodate new, currently
054:         * unknown, language structures added to future versions of the
055:         * Java&trade; programming language.  Therefore, methods whose names
056:         * begin with {@code "visit"} may be added to this class in the
057:         * future; to avoid incompatibilities, classes which extend this class
058:         * should not declare any instance methods with names beginning with
059:         * {@code "visit"}.
060:         * 
061:         * <p>When such a new visit method is added, the default
062:         * implementation in this class will be to call the {@link
063:         * #visitUnknown visitUnknown} method.  A new abstract element kind
064:         * visitor class will also be introduced to correspond to the new
065:         * language level; this visitor will have different default behavior
066:         * for the visit method in question.  When the new visitor is
067:         * introduced, all or portions of this visitor may be deprecated.
068:         *
069:         * @param <R> the return type of this visitor's methods.  Use {@link
070:         * 	      Void} for visitors that do not need to return results.
071:         * @param <P> the type of the additional parameter to this visitor's
072:         *            methods.  Use {@code Void} for visitors that do not need an
073:         *            additional parameter.
074:         *
075:         * @author Joseph D. Darcy
076:         * @author Scott Seligman
077:         * @author Peter von der Ah&eacute;
078:         * @version 1.11 07/05/05
079:         * @since 1.6
080:         */
081:        @SupportedSourceVersion(RELEASE_6)
082:        public class ElementKindVisitor6<R, P> extends
083:                SimpleElementVisitor6<R, P> {
084:            /**
085:             * Constructor for concrete subclasses; uses {@code null} for the
086:             * default value.
087:             */
088:            protected ElementKindVisitor6() {
089:                super (null);
090:            }
091:
092:            /**
093:             * Constructor for concrete subclasses; uses the argument for the
094:             * default value.
095:             *
096:             * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
097:             */
098:            protected ElementKindVisitor6(R defaultValue) {
099:                super (defaultValue);
100:            }
101:
102:            /**
103:             * {@inheritDoc}
104:             *
105:             * The element argument has kind {@code PACKAGE}.
106:             *
107:             * @param e {@inheritDoc}
108:             * @param p {@inheritDoc}
109:             * @return  {@inheritDoc}
110:             */
111:            @Override
112:            public R visitPackage(PackageElement e, P p) {
113:                assert e.getKind() == PACKAGE : "Bad kind on PackageElement";
114:                return defaultAction(e, p);
115:            }
116:
117:            /**
118:             * Visits a type element, dispatching to the visit method for the
119:             * specific {@linkplain ElementKind kind} of type, {@code
120:             * ANNOTATION_TYPE}, {@code CLASS}, {@code ENUM}, or {@code
121:             * INTERFACE}.
122:             *
123:             * @param e {@inheritDoc}
124:             * @param p {@inheritDoc}
125:             * @return  the result of the kind-specific visit method
126:             */
127:            @Override
128:            public R visitType(TypeElement e, P p) {
129:                ElementKind k = e.getKind();
130:                switch (k) {
131:                case ANNOTATION_TYPE:
132:                    return visitTypeAsAnnotationType(e, p);
133:
134:                case CLASS:
135:                    return visitTypeAsClass(e, p);
136:
137:                case ENUM:
138:                    return visitTypeAsEnum(e, p);
139:
140:                case INTERFACE:
141:                    return visitTypeAsInterface(e, p);
142:
143:                default:
144:                    throw new AssertionError("Bad kind " + k
145:                            + " for TypeElement" + e);
146:                }
147:            }
148:
149:            /**
150:             * Visits an {@code ANNOTATION_TYPE} type element by calling
151:             * {@code defaultAction}.
152:             *
153:             * @param e the element to visit
154:             * @param p a visitor-specified parameter
155:             * @return  the result of {@code defaultAction}
156:             */
157:            public R visitTypeAsAnnotationType(TypeElement e, P p) {
158:                return defaultAction(e, p);
159:            }
160:
161:            /**
162:             * Visits a {@code CLASS} type element by calling {@code
163:             * defaultAction}.
164:             *
165:             * @param e the element to visit
166:             * @param p a visitor-specified parameter
167:             * @return  the result of {@code defaultAction}
168:             */
169:            public R visitTypeAsClass(TypeElement e, P p) {
170:                return defaultAction(e, p);
171:            }
172:
173:            /**
174:             * Visits an {@code ENUM} type element by calling {@code
175:             * defaultAction}.
176:             *
177:             * @param e the element to visit
178:             * @param p a visitor-specified parameter
179:             * @return  the result of {@code defaultAction}
180:             */
181:            public R visitTypeAsEnum(TypeElement e, P p) {
182:                return defaultAction(e, p);
183:            }
184:
185:            /**
186:             * Visits an {@code INTERFACE} type element by calling {@code
187:             * defaultAction}.
188:             *.
189:             * @param e the element to visit
190:             * @param p a visitor-specified parameter
191:             * @return  the result of {@code defaultAction}
192:             */
193:            public R visitTypeAsInterface(TypeElement e, P p) {
194:                return defaultAction(e, p);
195:            }
196:
197:            /**
198:             * Visits a variable element, dispatching to the visit method for
199:             * the specific {@linkplain ElementKind kind} of variable, {@code
200:             * ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD},
201:             * {@code LOCAL_VARIABLE}, or {@code PARAMETER}.
202:             * @param e {@inheritDoc}
203:             * @param p {@inheritDoc}
204:             * @return  the result of the kind-specific visit method
205:             */
206:            @Override
207:            public R visitVariable(VariableElement e, P p) {
208:                ElementKind k = e.getKind();
209:                switch (k) {
210:                case ENUM_CONSTANT:
211:                    return visitVariableAsEnumConstant(e, p);
212:
213:                case EXCEPTION_PARAMETER:
214:                    return visitVariableAsExceptionParameter(e, p);
215:
216:                case FIELD:
217:                    return visitVariableAsField(e, p);
218:
219:                case LOCAL_VARIABLE:
220:                    return visitVariableAsLocalVariable(e, p);
221:
222:                case PARAMETER:
223:                    return visitVariableAsParameter(e, p);
224:
225:                default:
226:                    throw new AssertionError("Bad kind " + k
227:                            + " for VariableElement" + e);
228:                }
229:
230:            }
231:
232:            /**
233:             * Visits an {@code ENUM_CONSTANT} variable element by calling
234:             * {@code defaultAction}.
235:             *
236:             * @param e the element to visit
237:             * @param p a visitor-specified parameter
238:             * @return  the result of {@code defaultAction}
239:             */
240:            public R visitVariableAsEnumConstant(VariableElement e, P p) {
241:                return defaultAction(e, p);
242:            }
243:
244:            /**
245:             * Visits an {@code EXCEPTION_PARAMETER} variable element by calling
246:             * {@code defaultAction}.
247:             *
248:             * @param e the element to visit
249:             * @param p a visitor-specified parameter
250:             * @return  the result of {@code defaultAction}
251:             */
252:            public R visitVariableAsExceptionParameter(VariableElement e, P p) {
253:                return defaultAction(e, p);
254:            }
255:
256:            /**
257:             * Visits a {@code FIELD} variable element by calling
258:             * {@code defaultAction}.
259:             *
260:             * @param e the element to visit
261:             * @param p a visitor-specified parameter
262:             * @return  the result of {@code defaultAction}
263:             */
264:            public R visitVariableAsField(VariableElement e, P p) {
265:                return defaultAction(e, p);
266:            }
267:
268:            /**
269:             * Visits a {@code LOCAL_VARIABLE} variable element by calling
270:             * {@code defaultAction}.
271:             *
272:             * @param e the element to visit
273:             * @param p a visitor-specified parameter
274:             * @return  the result of {@code defaultAction}
275:             */
276:            public R visitVariableAsLocalVariable(VariableElement e, P p) {
277:                return defaultAction(e, p);
278:            }
279:
280:            /**
281:             * Visits a {@code PARAMETER} variable element by calling
282:             * {@code defaultAction}.
283:             *
284:             * @param e the element to visit
285:             * @param p a visitor-specified parameter
286:             * @return  the result of {@code defaultAction}
287:             */
288:            public R visitVariableAsParameter(VariableElement e, P p) {
289:                return defaultAction(e, p);
290:            }
291:
292:            /**
293:             * Visits an executable element, dispatching to the visit method
294:             * for the specific {@linkplain ElementKind kind} of executable,
295:             * {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or
296:             * {@code STATIC_INIT}.
297:             *
298:             * @param e {@inheritDoc}
299:             * @param p {@inheritDoc}
300:             * @return  the result of the kind-specific visit method
301:             */
302:            @Override
303:            public R visitExecutable(ExecutableElement e, P p) {
304:                ElementKind k = e.getKind();
305:                switch (k) {
306:                case CONSTRUCTOR:
307:                    return visitExecutableAsConstructor(e, p);
308:
309:                case INSTANCE_INIT:
310:                    return visitExecutableAsInstanceInit(e, p);
311:
312:                case METHOD:
313:                    return visitExecutableAsMethod(e, p);
314:
315:                case STATIC_INIT:
316:                    return visitExecutableAsStaticInit(e, p);
317:
318:                default:
319:                    throw new AssertionError("Bad kind " + k
320:                            + " for ExecutableElement" + e);
321:                }
322:            }
323:
324:            /**
325:             * Visits a {@code CONSTRUCTOR} executable element by calling
326:             * {@code defaultAction}.
327:             *
328:             * @param e the element to visit
329:             * @param p a visitor-specified parameter
330:             * @return  the result of {@code defaultAction}
331:             */
332:            public R visitExecutableAsConstructor(ExecutableElement e, P p) {
333:                return defaultAction(e, p);
334:            }
335:
336:            /**
337:             * Visits an {@code INSTANCE_INIT} executable element by calling
338:             * {@code defaultAction}.
339:             *
340:             * @param e the element to visit
341:             * @param p a visitor-specified parameter
342:             * @return  the result of {@code defaultAction}
343:             */
344:            public R visitExecutableAsInstanceInit(ExecutableElement e, P p) {
345:                return defaultAction(e, p);
346:            }
347:
348:            /**
349:             * Visits a {@code METHOD} executable element by calling
350:             * {@code defaultAction}.
351:             *
352:             * @param e the element to visit
353:             * @param p a visitor-specified parameter
354:             * @return  the result of {@code defaultAction}
355:             */
356:            public R visitExecutableAsMethod(ExecutableElement e, P p) {
357:                return defaultAction(e, p);
358:            }
359:
360:            /**
361:             * Visits a {@code STATIC_INIT} executable element by calling
362:             * {@code defaultAction}.
363:             *
364:             * @param e the element to visit
365:             * @param p a visitor-specified parameter
366:             * @return  the result of {@code defaultAction}
367:             */
368:            public R visitExecutableAsStaticInit(ExecutableElement e, P p) {
369:                return defaultAction(e, p);
370:            }
371:
372:            /**
373:             * {@inheritDoc}
374:             *
375:             * The element argument has kind {@code TYPE_PARAMETER}.
376:             *
377:             * @param e {@inheritDoc}
378:             * @param p {@inheritDoc}
379:             * @return  {@inheritDoc}
380:             */
381:            @Override
382:            public R visitTypeParameter(TypeParameterElement e, P p) {
383:                assert e.getKind() == TYPE_PARAMETER : "Bad kind on TypeParameterElement";
384:                return defaultAction(e, p);
385:            }
386:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.