Source Code Cross Referenced for JArrayType.java in  » Ajax » GWT » com » google » gwt » core » ext » typeinfo » 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 » Ajax » GWT » com.google.gwt.core.ext.typeinfo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * the License at
007:         * 
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package com.google.gwt.core.ext.typeinfo;
017:
018:        import com.google.gwt.core.ext.UnableToCompleteException;
019:
020:        import java.lang.annotation.Annotation;
021:        import java.util.Map;
022:
023:        /**
024:         * Type representing a Java array.
025:         */
026:        public class JArrayType extends JClassType {
027:            private static final JArrayType[] NO_JARRAYS = new JArrayType[0];
028:
029:            private JType componentType;
030:
031:            private String lazyQualifiedName;
032:
033:            private String lazySimpleName;
034:
035:            private final TypeOracle oracle;
036:
037:            JArrayType(JType componentType, TypeOracle oracle) {
038:                this .componentType = componentType;
039:                this .oracle = oracle;
040:            }
041:
042:            @Override
043:            public void addImplementedInterface(JClassType intf) {
044:                throw new UnsupportedOperationException("modifying a "
045:                        + getClass().getSimpleName());
046:            }
047:
048:            @Override
049:            public void addMetaData(String tagName, String[] values) {
050:                throw new UnsupportedOperationException("modifying a "
051:                        + getClass().getSimpleName());
052:            }
053:
054:            @Override
055:            public void addModifierBits(int bits) {
056:                throw new UnsupportedOperationException("modifying a "
057:                        + getClass().getSimpleName());
058:            }
059:
060:            @Override
061:            public JConstructor findConstructor(JType[] paramTypes) {
062:                return null;
063:            }
064:
065:            @Override
066:            public JField findField(String name) {
067:                return null;
068:            }
069:
070:            @Override
071:            public JMethod findMethod(String name, JType[] paramTypes) {
072:                return getOracle().getJavaLangObject().findMethod(name,
073:                        paramTypes);
074:            }
075:
076:            @Override
077:            public JClassType findNestedType(String typeName) {
078:                return null;
079:            }
080:
081:            @Override
082:            public <T extends Annotation> T getAnnotation(
083:                    Class<T> annotationClass) {
084:                return null;
085:            }
086:
087:            @Override
088:            public Annotation[] getAnnotations() {
089:                return TypeOracle.NO_ANNOTATIONS;
090:            }
091:
092:            @Override
093:            public int getBodyEnd() {
094:                return 0;
095:            }
096:
097:            @Override
098:            public int getBodyStart() {
099:                return 0;
100:            }
101:
102:            @Override
103:            public CompilationUnitProvider getCompilationUnit() {
104:                return null;
105:            }
106:
107:            public JType getComponentType() {
108:                return componentType;
109:            }
110:
111:            @Override
112:            public JConstructor getConstructor(JType[] paramTypes)
113:                    throws NotFoundException {
114:                throw new NotFoundException();
115:            }
116:
117:            @Override
118:            public JConstructor[] getConstructors() {
119:                return TypeOracle.NO_JCTORS;
120:            }
121:
122:            @Override
123:            public Annotation[] getDeclaredAnnotations() {
124:                return TypeOracle.NO_ANNOTATIONS;
125:            }
126:
127:            @Override
128:            public JClassType getEnclosingType() {
129:                return null;
130:            }
131:
132:            @Override
133:            public JClassType getErasedType() {
134:                return getOracle().getArrayType(
135:                        getComponentType().getErasedType());
136:            }
137:
138:            @Override
139:            public JField getField(String name) {
140:                return null;
141:            }
142:
143:            @Override
144:            public JField[] getFields() {
145:                return TypeOracle.NO_JFIELDS;
146:            }
147:
148:            @Override
149:            public JClassType[] getImplementedInterfaces() {
150:                return TypeOracle.NO_JCLASSES;
151:            }
152:
153:            @Override
154:            public String getJNISignature() {
155:                return "[" + componentType.getJNISignature();
156:            }
157:
158:            @Override
159:            public JType getLeafType() {
160:                return componentType.getLeafType();
161:            }
162:
163:            @Override
164:            public String[][] getMetaData(String tagName) {
165:                return TypeOracle.NO_STRING_ARR_ARR;
166:            }
167:
168:            @Override
169:            public String[] getMetaDataTags() {
170:                return TypeOracle.NO_STRINGS;
171:            }
172:
173:            @Override
174:            public JMethod getMethod(String name, JType[] paramTypes)
175:                    throws NotFoundException {
176:                return getOracle().getJavaLangObject().getMethod(name,
177:                        paramTypes);
178:            }
179:
180:            @Override
181:            public JMethod[] getMethods() {
182:                return getOracle().getJavaLangObject().getMethods();
183:            }
184:
185:            @Override
186:            public String getName() {
187:                return getSimpleSourceName();
188:            }
189:
190:            @Override
191:            public JClassType getNestedType(String typeName)
192:                    throws NotFoundException {
193:                throw new NotFoundException();
194:            }
195:
196:            @Override
197:            public JClassType[] getNestedTypes() {
198:                return TypeOracle.NO_JCLASSES;
199:            }
200:
201:            @Override
202:            public TypeOracle getOracle() {
203:                return oracle;
204:            }
205:
206:            @Override
207:            public JMethod[] getOverloads(String name) {
208:                return getOracle().getJavaLangObject().getOverloads(name);
209:            }
210:
211:            @Override
212:            public JMethod[] getOverridableMethods() {
213:                return getOracle().getJavaLangObject().getOverridableMethods();
214:            }
215:
216:            @Override
217:            public JPackage getPackage() {
218:                JType leafType = getLeafType();
219:                if (leafType.isPrimitive() != null) {
220:                    // TODO: is there a default package?
221:                    return null;
222:                }
223:
224:                JClassType leafClass = (JClassType) leafType;
225:                return leafClass.getPackage();
226:            }
227:
228:            @Override
229:            public String getParameterizedQualifiedSourceName() {
230:                return getComponentType().getParameterizedQualifiedSourceName()
231:                        + "[]";
232:            }
233:
234:            @Override
235:            public String getQualifiedSourceName() {
236:                if (lazyQualifiedName == null) {
237:                    lazyQualifiedName = getComponentType()
238:                            .getQualifiedSourceName()
239:                            + "[]";
240:                }
241:                return lazyQualifiedName;
242:            }
243:
244:            public int getRank() {
245:                JArrayType componentArrayType = componentType.isArray();
246:                if (componentArrayType != null) {
247:                    return 1 + componentArrayType.getRank();
248:                }
249:
250:                return 1;
251:            }
252:
253:            @Override
254:            public String getSimpleSourceName() {
255:                if (lazySimpleName == null) {
256:                    lazySimpleName = getComponentType().getSimpleSourceName()
257:                            + "[]";
258:                }
259:                return lazySimpleName;
260:            }
261:
262:            @Override
263:            public JArrayType[] getSubtypes() {
264:                if (getComponentType().isPrimitive() != null) {
265:                    return NO_JARRAYS;
266:                }
267:
268:                JClassType componentClass = (JClassType) getComponentType();
269:                JClassType[] componentSubtypes = componentClass.getSubtypes();
270:                JArrayType[] arraySubtypes = new JArrayType[componentSubtypes.length];
271:                for (int i = 0; i < componentSubtypes.length; ++i) {
272:                    arraySubtypes[i] = getOracle().getArrayType(
273:                            componentSubtypes[i]);
274:                }
275:
276:                return arraySubtypes;
277:            }
278:
279:            @Override
280:            public JClassType getSuperclass() {
281:                return getOracle().getJavaLangObject();
282:            }
283:
284:            @Override
285:            public String getTypeHash() throws UnableToCompleteException {
286:                JType leafType = getLeafType();
287:                JClassType leafClassType = leafType.isClassOrInterface();
288:                if (leafClassType != null) {
289:                    return leafClassType.getTypeHash();
290:                }
291:
292:                // Arrays of primitive types should have a stable hash
293:                assert (leafType.isPrimitive() != null);
294:
295:                return leafType.getQualifiedSourceName();
296:            }
297:
298:            @Override
299:            public boolean isAbstract() {
300:                return false;
301:            }
302:
303:            @Override
304:            public boolean isAnnotationPresent(
305:                    Class<? extends Annotation> annotationClass) {
306:                return false;
307:            }
308:
309:            @Override
310:            public JArrayType isArray() {
311:                return this ;
312:            }
313:
314:            @Override
315:            public boolean isAssignableFrom(JClassType possibleSubtype) {
316:                if (this  == possibleSubtype) {
317:                    // type is assignable to itself
318:                    return true;
319:                }
320:
321:                JArrayType possibleSubtypeArray = possibleSubtype.isArray();
322:                if (possibleSubtypeArray == null) {
323:                    // possible subtype must be an array to be assignable
324:                    return false;
325:                }
326:
327:                JType this ComponentType = getComponentType();
328:                JType otherComponentType = possibleSubtypeArray
329:                        .getComponentType();
330:
331:                if (this ComponentType.isPrimitive() != null
332:                        || otherComponentType.isPrimitive() != null) {
333:                    /*
334:                     * Since this was not equal to the possible subtype, we know that either
335:                     * the dimensions are off or the component types are off
336:                     */
337:                    return false;
338:                }
339:
340:                assert (this ComponentType instanceof  JClassType);
341:                assert (otherComponentType instanceof  JClassType);
342:
343:                JClassType this ComponentClassType = (JClassType) this ComponentType;
344:                JClassType otherComponentClassType = (JClassType) otherComponentType;
345:
346:                return this ComponentClassType
347:                        .isAssignableFrom(otherComponentClassType);
348:            }
349:
350:            @Override
351:            public boolean isAssignableTo(JClassType possibleSupertype) {
352:                return possibleSupertype.isAssignableFrom(this );
353:            }
354:
355:            @Override
356:            public JClassType isClass() {
357:                // intentional null
358:                return null;
359:            }
360:
361:            @Override
362:            public boolean isDefaultInstantiable() {
363:                return true;
364:            }
365:
366:            @Override
367:            public JEnumType isEnum() {
368:                return null;
369:            }
370:
371:            @Override
372:            public JGenericType isGenericType() {
373:                return null;
374:            }
375:
376:            @Override
377:            public JClassType isInterface() {
378:                // intentional null
379:                return null;
380:            }
381:
382:            @Override
383:            public boolean isLocalType() {
384:                return false;
385:            }
386:
387:            @Override
388:            public boolean isMemberType() {
389:                return false;
390:            }
391:
392:            @Override
393:            public JParameterizedType isParameterized() {
394:                // intentional null
395:                return null;
396:            }
397:
398:            @Override
399:            public JPrimitiveType isPrimitive() {
400:                // intentional null
401:                return null;
402:            }
403:
404:            @Override
405:            public boolean isPrivate() {
406:                return false;
407:            }
408:
409:            @Override
410:            public boolean isProtected() {
411:                return false;
412:            }
413:
414:            @Override
415:            public boolean isPublic() {
416:                return true;
417:            }
418:
419:            @Override
420:            public JRawType isRawType() {
421:                return null;
422:            }
423:
424:            @Override
425:            public boolean isStatic() {
426:                return true;
427:            }
428:
429:            @Override
430:            public JWildcardType isWildcard() {
431:                return null;
432:            }
433:
434:            public void setLeafType(JType type) {
435:                JArrayType componentTypeIsArray = componentType.isArray();
436:                if (componentTypeIsArray != null) {
437:                    componentTypeIsArray.setLeafType(type);
438:                } else {
439:                    componentType = type;
440:                }
441:            }
442:
443:            @Override
444:            public void setSuperclass(JClassType type) {
445:            }
446:
447:            @Override
448:            public String toString() {
449:                return getQualifiedSourceName();
450:            }
451:
452:            @Override
453:            protected void acceptSubtype(JClassType me) {
454:                throw new UnsupportedOperationException("modifying a "
455:                        + getClass().getSimpleName());
456:            }
457:
458:            @Override
459:            protected int getModifierBits() {
460:                return 0;
461:            }
462:
463:            @Override
464:            protected void getOverridableMethodsOnSuperclassesAndThisClass(
465:                    Map<String, JMethod> methodsBySignature) {
466:                getOracle().getJavaLangObject()
467:                        .getOverridableMethodsOnSuperclassesAndThisClass(
468:                                methodsBySignature);
469:            }
470:
471:            @Override
472:            protected void getOverridableMethodsOnSuperinterfacesAndMaybeThisInterface(
473:                    Map<String, JMethod> methodsBySignature) {
474:                getOracle()
475:                        .getJavaLangObject()
476:                        .getOverridableMethodsOnSuperinterfacesAndMaybeThisInterface(
477:                                methodsBySignature);
478:            }
479:
480:            @Override
481:            protected void notifySuperTypesOf(JClassType me) {
482:            }
483:
484:            @Override
485:            protected void removeSubtype(JClassType me) {
486:            }
487:
488:            @Override
489:            void addConstructor(JConstructor ctor) {
490:                throw new UnsupportedOperationException("modifying a "
491:                        + getClass().getSimpleName());
492:            }
493:
494:            @Override
495:            void addField(JField field) {
496:                throw new UnsupportedOperationException("modifying a "
497:                        + getClass().getSimpleName());
498:            }
499:
500:            @Override
501:            void addMethod(JMethod method) {
502:                throw new UnsupportedOperationException("modifying a "
503:                        + getClass().getSimpleName());
504:            }
505:
506:            @Override
507:            void addNestedType(JClassType type) {
508:                throw new UnsupportedOperationException("modifying a "
509:                        + getClass().getSimpleName());
510:            }
511:
512:            @Override
513:            JClassType findNestedTypeImpl(String[] typeName, int index) {
514:                return null;
515:            }
516:
517:            @Override
518:            JArrayType getSubstitutedType(JParameterizedType parameterizedType) {
519:                return oracle.getArrayType(getComponentType()
520:                        .getSubstitutedType(parameterizedType));
521:            }
522:
523:            @Override
524:            void notifySuperTypes() {
525:            }
526:
527:            @Override
528:            void removeFromSupertypes() {
529:            }
530:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.