Source Code Cross Referenced for TypeKindVisitor6.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.type.*;
029:        import javax.annotation.processing.SupportedSourceVersion;
030:        import static javax.lang.model.element.ElementKind.*;
031:        import static javax.lang.model.SourceVersion.*;
032:        import javax.lang.model.SourceVersion;
033:
034:        /**
035:         * A visitor of types based on their {@linkplain TypeKind kind} with
036:         * default behavior appropriate for the {@link SourceVersion#RELEASE_6
037:         * RELEASE_6} source version.  For {@linkplain
038:         * TypeMirror types} <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 TypeVisitor} interface implemented
051:         * by this class may have methods added to it in the future to
052:         * accommodate new, currently unknown, language structures added to
053:         * future versions of the Java&trade; programming language.
054:         * Therefore, methods whose names begin with {@code "visit"} may be
055:         * added to this class in the future; to avoid incompatibilities,
056:         * classes which extend this class should not declare any instance
057:         * methods with names beginning with {@code "visit"}.
058:         * 
059:         * <p>When such a new visit method is added, the default
060:         * implementation in this class will be to call the {@link
061:         * #visitUnknown visitUnknown} method.  A new type kind visitor class
062:         * will also be introduced to correspond to the new language level;
063:         * this visitor will have different default behavior for the visit
064:         * method in question.  When the new visitor is introduced, all or
065:         * portions of this visitor may be deprecated.
066:         *
067:         * @param <R> the return type of this visitor's methods.  Use {@link
068:         *            Void} for visitors that do not need to return results.
069:         * @param <P> the type of the additional parameter to this visitor's
070:         *            methods.  Use {@code Void} for visitors that do not need an
071:         *            additional parameter.
072:         *
073:         * @author Joseph D. Darcy
074:         * @author Scott Seligman
075:         * @author Peter von der Ah&eacute;
076:         * @version 1.12 07/05/05
077:         * @since 1.6
078:         */
079:        @SupportedSourceVersion(RELEASE_6)
080:        public class TypeKindVisitor6<R, P> extends SimpleTypeVisitor6<R, P> {
081:            /**
082:             * Constructor for concrete subclasses to call; uses {@code null}
083:             * for the default value.
084:             */
085:            protected TypeKindVisitor6() {
086:                super (null);
087:            }
088:
089:            /**
090:             * Constructor for concrete subclasses to call; uses the argument
091:             * for the default value.
092:             *
093:             * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
094:             */
095:            protected TypeKindVisitor6(R defaultValue) {
096:                super (defaultValue);
097:            }
098:
099:            /**
100:             * Visits a primitive type, dispatching to the visit method for
101:             * the specific {@linkplain TypeKind kind} of primitive type:
102:             * {@code BOOLEAN}, {@code BYTE}, etc.
103:             *
104:             * @param t {@inheritDoc}
105:             * @param p {@inheritDoc}
106:             * @return  the result of the kind-specific visit method
107:             */
108:            @Override
109:            public R visitPrimitive(PrimitiveType t, P p) {
110:                TypeKind k = t.getKind();
111:                switch (k) {
112:                case BOOLEAN:
113:                    return visitPrimitiveAsBoolean(t, p);
114:
115:                case BYTE:
116:                    return visitPrimitiveAsByte(t, p);
117:
118:                case SHORT:
119:                    return visitPrimitiveAsShort(t, p);
120:
121:                case INT:
122:                    return visitPrimitiveAsInt(t, p);
123:
124:                case LONG:
125:                    return visitPrimitiveAsLong(t, p);
126:
127:                case CHAR:
128:                    return visitPrimitiveAsChar(t, p);
129:
130:                case FLOAT:
131:                    return visitPrimitiveAsFloat(t, p);
132:
133:                case DOUBLE:
134:                    return visitPrimitiveAsDouble(t, p);
135:
136:                default:
137:                    throw new AssertionError("Bad kind " + k
138:                            + " for PrimitiveType" + t);
139:                }
140:            }
141:
142:            /**
143:             * Visits a {@code BOOLEAN} primitive type by calling
144:             * {@code defaultAction}.
145:             *
146:             * @param t the type to visit
147:             * @param p a visitor-specified parameter
148:             * @return  the result of {@code defaultAction}
149:             */
150:            public R visitPrimitiveAsBoolean(PrimitiveType t, P p) {
151:                return defaultAction(t, p);
152:            }
153:
154:            /**
155:             * Visits a {@code BYTE} primitive type by calling
156:             * {@code defaultAction}.
157:             *
158:             * @param t the type to visit
159:             * @param p a visitor-specified parameter
160:             * @return  the result of {@code defaultAction}
161:             */
162:            public R visitPrimitiveAsByte(PrimitiveType t, P p) {
163:                return defaultAction(t, p);
164:            }
165:
166:            /**
167:             * Visits a {@code SHORT} primitive type by calling
168:             * {@code defaultAction}.
169:             *
170:             * @param t the type to visit
171:             * @param p a visitor-specified parameter
172:             * @return  the result of {@code defaultAction}
173:             */
174:            public R visitPrimitiveAsShort(PrimitiveType t, P p) {
175:                return defaultAction(t, p);
176:            }
177:
178:            /**
179:             * Visits an {@code INT} primitive type by calling
180:             * {@code defaultAction}.
181:             *
182:             * @param t the type to visit
183:             * @param p a visitor-specified parameter
184:             * @return  the result of {@code defaultAction}
185:             */
186:            public R visitPrimitiveAsInt(PrimitiveType t, P p) {
187:                return defaultAction(t, p);
188:            }
189:
190:            /**
191:             * Visits a {@code LONG} primitive type by calling
192:             * {@code defaultAction}.
193:             *
194:             * @param t the type to visit
195:             * @param p a visitor-specified parameter
196:             * @return  the result of {@code defaultAction}
197:             */
198:            public R visitPrimitiveAsLong(PrimitiveType t, P p) {
199:                return defaultAction(t, p);
200:            }
201:
202:            /**
203:             * Visits a {@code CHAR} primitive type by calling
204:             * {@code defaultAction}.
205:             *
206:             * @param t the type to visit
207:             * @param p a visitor-specified parameter
208:             * @return  the result of {@code defaultAction}
209:             */
210:            public R visitPrimitiveAsChar(PrimitiveType t, P p) {
211:                return defaultAction(t, p);
212:            }
213:
214:            /**
215:             * Visits a {@code FLOAT} primitive type by calling
216:             * {@code defaultAction}.
217:             *
218:             * @param t the type to visit
219:             * @param p a visitor-specified parameter
220:             * @return  the result of {@code defaultAction}
221:             */
222:            public R visitPrimitiveAsFloat(PrimitiveType t, P p) {
223:                return defaultAction(t, p);
224:            }
225:
226:            /**
227:             * Visits a {@code DOUBLE} primitive type by calling
228:             * {@code defaultAction}.
229:             *
230:             * @param t the type to visit
231:             * @param p a visitor-specified parameter
232:             * @return  the result of {@code defaultAction}
233:             */
234:            public R visitPrimitiveAsDouble(PrimitiveType t, P p) {
235:                return defaultAction(t, p);
236:            }
237:
238:            /**
239:             * Visits a {@link NoType} instance, dispatching to the visit method for
240:             * the specific {@linkplain TypeKind kind} of pseudo-type:
241:             * {@code VOID}, {@code PACKAGE}, or {@code NONE}.
242:             *
243:             * @param t {@inheritDoc}
244:             * @param p {@inheritDoc}
245:             * @return  the result of the kind-specific visit method
246:             */
247:            @Override
248:            public R visitNoType(NoType t, P p) {
249:                TypeKind k = t.getKind();
250:                switch (k) {
251:                case VOID:
252:                    return visitNoTypeAsVoid(t, p);
253:
254:                case PACKAGE:
255:                    return visitNoTypeAsPackage(t, p);
256:
257:                case NONE:
258:                    return visitNoTypeAsNone(t, p);
259:
260:                default:
261:                    throw new AssertionError("Bad kind " + k + " for NoType"
262:                            + t);
263:                }
264:            }
265:
266:            /**
267:             * Visits a {@link TypeKind#VOID VOID} pseudo-type by calling
268:             * {@code defaultAction}.
269:             *
270:             * @param t the type to visit
271:             * @param p a visitor-specified parameter
272:             * @return  the result of {@code defaultAction}
273:             */
274:            public R visitNoTypeAsVoid(NoType t, P p) {
275:                return defaultAction(t, p);
276:            }
277:
278:            /**
279:             * Visits a {@link TypeKind#PACKAGE PACKAGE} pseudo-type by calling
280:             * {@code defaultAction}.
281:             *
282:             * @param t the type to visit
283:             * @param p a visitor-specified parameter
284:             * @return  the result of {@code defaultAction}
285:             */
286:            public R visitNoTypeAsPackage(NoType t, P p) {
287:                return defaultAction(t, p);
288:            }
289:
290:            /**
291:             * Visits a {@link TypeKind#NONE NONE} pseudo-type by calling
292:             * {@code defaultAction}.
293:             *
294:             * @param t the type to visit
295:             * @param p a visitor-specified parameter
296:             * @return  the result of {@code defaultAction}
297:             */
298:            public R visitNoTypeAsNone(NoType t, P p) {
299:                return defaultAction(t, p);
300:            }
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.