Source Code Cross Referenced for JType.java in  » 6.0-JDK-Modules » jaxb-xjc » com » sun » codemodel » 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 » jaxb xjc » com.sun.codemodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms
003:         * of the Common Development and Distribution License
004:         * (the "License").  You may not use this file except
005:         * in compliance with the License.
006:         * 
007:         * You can obtain a copy of the license at
008:         * https://jwsdp.dev.java.net/CDDLv1.0.html
009:         * See the License for the specific language governing
010:         * permissions and limitations under the License.
011:         * 
012:         * When distributing Covered Code, include this CDDL
013:         * HEADER in each file and include the License file at
014:         * https://jwsdp.dev.java.net/CDDLv1.0.html  If applicable,
015:         * add the following below this CDDL HEADER, with the
016:         * fields enclosed by brackets "[]" replaced with your
017:         * own identifying information: Portions Copyright [yyyy]
018:         * [name of copyright owner]
019:         */
020:
021:        package com.sun.codemodel;
022:
023:        /**
024:         * A representation of a type in codeModel.
025:         *
026:         * A type is always either primitive ({@link JPrimitiveType}) or
027:         * a reference type ({@link JClass}).
028:         */
029:        public abstract class JType implements  JGenerable, Comparable {
030:
031:            /**
032:             * Obtains a reference to the primitive type object from a type name.
033:             */
034:            public static JPrimitiveType parse(JCodeModel codeModel,
035:                    String typeName) {
036:                if (typeName.equals("void"))
037:                    return codeModel.VOID;
038:                else if (typeName.equals("boolean"))
039:                    return codeModel.BOOLEAN;
040:                else if (typeName.equals("byte"))
041:                    return codeModel.BYTE;
042:                else if (typeName.equals("short"))
043:                    return codeModel.SHORT;
044:                else if (typeName.equals("char"))
045:                    return codeModel.CHAR;
046:                else if (typeName.equals("int"))
047:                    return codeModel.INT;
048:                else if (typeName.equals("float"))
049:                    return codeModel.FLOAT;
050:                else if (typeName.equals("long"))
051:                    return codeModel.LONG;
052:                else if (typeName.equals("double"))
053:                    return codeModel.DOUBLE;
054:                else
055:                    throw new IllegalArgumentException("Not a primitive type: "
056:                            + typeName);
057:            }
058:
059:            /** Gets the owner code model object. */
060:            public abstract JCodeModel owner();
061:
062:            /**
063:             * Gets the full name of the type.
064:             *
065:             * See http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#25430 for the details.
066:             *
067:             * @return
068:             *      Strings like "int", "java.lang.String",
069:             *      "java.io.File[]". Never null.
070:             */
071:            public abstract String fullName();
072:
073:            /**
074:             * Gets the binary name of the type.
075:             *
076:             * See http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#44909
077:             *
078:             * @return
079:             *      Name like "Foo$Bar", "int", "java.lang.String", "java.io.File[]". Never null.
080:             */
081:            public String binaryName() {
082:                return fullName();
083:            }
084:
085:            /**
086:             * Gets the name of this type.
087:             *
088:             * @return
089:             *     Names like "int", "void", "BigInteger".
090:             */
091:            public abstract String name();
092:
093:            /**
094:             * Create an array type of this type.
095:             * 
096:             * This method is undefined for primitive void type, which
097:             * doesn't have any corresponding array representation.
098:             *
099:             * @return A {@link JClass} representing the array type
100:             *         whose element type is this type
101:             */
102:            public abstract JClass array();
103:
104:            /** Tell whether or not this is an array type. */
105:            public boolean isArray() {
106:                return false;
107:            }
108:
109:            /** Tell whether or not this is a built-in primitive type, such as int or void. */
110:            public boolean isPrimitive() {
111:                return false;
112:            }
113:
114:            /**
115:             * If this class is a primitive type, return the boxed class. Otherwise return <tt>this</tt>.
116:             *
117:             * <p>
118:             * For example, for "int", this method returns "java.lang.Integer".
119:             */
120:            public abstract JClass boxify();
121:
122:            /**
123:             * If this class is a wrapper type for a primitive, return the primitive type.
124:             * Otherwise return <tt>this</tt>.
125:             *
126:             * <p>
127:             * For example, for "java.lang.Integer", this method returns "int".
128:             */
129:            public abstract JType unboxify();
130:
131:            /**
132:             * Returns the erasure of this type.
133:             */
134:            public JType erasure() {
135:                return this ;
136:            }
137:
138:            /**
139:             * Returns true if this is a referenced type.
140:             */
141:            public final boolean isReference() {
142:                return !isPrimitive();
143:            }
144:
145:            /**
146:             * If this is an array, returns the component type of the array.
147:             * (T of T[])
148:             */
149:            public JType elementType() {
150:                throw new IllegalArgumentException("Not an array type");
151:            }
152:
153:            public String toString() {
154:                return this .getClass().getName() + '(' + fullName() + ')';
155:            }
156:
157:            /**
158:             * Compare two JTypes by FQCN, giving sorting precedence to types
159:             * that belong to packages java and javax over all others.
160:             *
161:             * This method is used to sort generated import statments in a
162:             * conventional way for readability.
163:             */
164:            public int compareTo(Object o) {
165:                final String rhs = ((JType) o).fullName();
166:                boolean p = fullName().startsWith("java");
167:                boolean q = rhs.startsWith("java");
168:
169:                if (p && !q) {
170:                    return -1;
171:                } else if (!p && q) {
172:                    return 1;
173:                } else {
174:                    return fullName().compareTo(rhs);
175:                }
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.