Source Code Cross Referenced for JormType.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ejb » lib » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_ejb.lib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: JormType.java 5445 2004-09-17 08:25:02Z joaninh $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_ejb.lib;
025:
026:        import javax.ejb.EJBLocalObject;
027:        import org.objectweb.jorm.type.api.PType;
028:        import org.objectweb.jorm.type.api.PTypeSpace;
029:        import org.objectweb.jorm.naming.api.PNamingContext;
030:        import org.objectweb.jorm.naming.api.PExceptionNaming;
031:        import org.objectweb.medor.type.lib.PTypeSpaceMedor;
032:
033:        /**
034:         * This class contains several methods to manipulate a PType.
035:         *
036:         * @author Sebastien Chassande-Barrioz : Initial developper
037:         * @author Helene Joanin
038:         */
039:        public class JormType {
040:
041:            /**
042:             * This method converts a java.lang.Class into a jorm PType.
043:             * @param cl is a java.lang.Class
044:             * @param isPkField true if this is for a field of the primary key, false otherwise
045:             * @return The PType which matches the class specified in parameter.
046:             */
047:            public static PType getPType(java.lang.Class cl, boolean isPkField) {
048:                if (cl.equals(Boolean.TYPE)) {
049:                    return PTypeSpace.BOOLEAN;
050:                } else if (cl.equals(Boolean.class)) {
051:                    return PTypeSpace.OBJBOOLEAN;
052:                } else if (cl.equals(Character.TYPE)) {
053:                    return PTypeSpace.CHAR;
054:                } else if (cl.equals(Character.class)) {
055:                    return PTypeSpace.OBJCHAR;
056:                } else if (cl.equals(Byte.TYPE)) {
057:                    return PTypeSpace.BYTE;
058:                } else if (cl.equals(Byte.class)) {
059:                    return PTypeSpace.OBJBYTE;
060:                } else if (cl.equals(Short.TYPE)) {
061:                    return PTypeSpace.SHORT;
062:                } else if (cl.equals(Short.class)) {
063:                    return PTypeSpace.OBJSHORT;
064:                } else if (cl.equals(Integer.TYPE)) {
065:                    return PTypeSpace.INT;
066:                } else if (cl.equals(Integer.class)) {
067:                    return PTypeSpace.OBJINT;
068:                } else if (cl.equals(Long.TYPE)) {
069:                    return PTypeSpace.LONG;
070:                } else if (cl.equals(Long.class)) {
071:                    return PTypeSpace.OBJLONG;
072:                } else if (cl.equals(Float.TYPE)) {
073:                    return PTypeSpace.FLOAT;
074:                } else if (cl.equals(Float.class)) {
075:                    if (isPkField) {
076:                        return (JormType.getPType(FloatPkFieldMapping
077:                                .getStorageType(), false));
078:                    } else {
079:                        return PTypeSpace.OBJFLOAT;
080:                    }
081:                } else if (cl.equals(Double.TYPE)) {
082:                    return PTypeSpace.DOUBLE;
083:                } else if (cl.equals(Double.class)) {
084:                    return PTypeSpace.OBJDOUBLE;
085:                } else if (cl.equals(String.class)) {
086:                    return PTypeSpace.STRING;
087:                } else if (cl.equals(java.util.Date.class)
088:                        || cl.equals(java.sql.Date.class)
089:                        || cl.equals(java.sql.Time.class)
090:                        || cl.equals(java.sql.Timestamp.class)) {
091:                    return PTypeSpace.DATE;
092:                } else if (cl.equals(java.math.BigDecimal.class)) {
093:                    return PTypeSpace.BIGDECIMAL;
094:                } else if (EJBLocalObject.class.isAssignableFrom(cl)) {
095:                    return PTypeSpaceMedor.PNAME;
096:                } else if (cl.isArray()
097:                        && java.lang.Byte.TYPE.equals(cl.getComponentType())) {
098:                    return PTypeSpace.BYTEARRAY;
099:                } else if (cl.isArray()
100:                        && java.lang.Character.TYPE.equals(cl
101:                                .getComponentType())) {
102:                    return PTypeSpace.CHARARRAY;
103:                }
104:                return PTypeSpace.SERIALIZED;
105:            }
106:
107:            /**
108:             * This method converts a java.lang.Class into a jorm PType.
109:             * @param cl is a java.lang.Class
110:             * @param isPkField true if this is for a field of the primary key, false otherwise
111:             * @return A String that represents The PType which matches the class.
112:             */
113:            public static String getPTypeDef(Class cl, boolean isPkField) {
114:                if (cl.equals(Boolean.TYPE)) {
115:                    return "PTypeSpace.BOOLEAN";
116:                } else if (cl.equals(Boolean.class)) {
117:                    return "PTypeSpace.OBJBOOLEAN";
118:                } else if (cl.equals(String.class)) {
119:                    return "PTypeSpace.STRING";
120:                } else if (cl.equals(Character.TYPE)) {
121:                    return "PTypeSpace.CHAR";
122:                } else if (cl.equals(Character.class)) {
123:                    return "PTypeSpace.OBJCHAR";
124:                } else if (cl.equals(Byte.TYPE)) {
125:                    return "PTypeSpace.BYTE";
126:                } else if (cl.equals(Byte.class)) {
127:                    return "PTypeSpace.OBJBYTE";
128:                } else if (cl.equals(Short.TYPE)) {
129:                    return "PTypeSpace.SHORT";
130:                } else if (cl.equals(Short.class)) {
131:                    return "PTypeSpace.OBJSHORT";
132:                } else if (cl.equals(Integer.TYPE)) {
133:                    return "PTypeSpace.INT";
134:                } else if (cl.equals(Integer.class)) {
135:                    return "PTypeSpace.OBJINT";
136:                } else if (cl.equals(Long.TYPE)) {
137:                    return "PTypeSpace.LONG";
138:                } else if (cl.equals(Long.class)) {
139:                    return "PTypeSpace.OBJLONG";
140:                } else if (cl.equals(Float.TYPE)) {
141:                    return "PTypeSpace.FLOAT";
142:                } else if (cl.equals(Float.class)) {
143:                    if (isPkField) {
144:                        return (JormType.getPTypeDef(FloatPkFieldMapping
145:                                .getStorageType(), false));
146:                    } else {
147:                        return "PTypeSpace.OBJFLOAT";
148:                    }
149:                } else if (cl.equals(Double.TYPE)) {
150:                    return "PTypeSpace.DOUBLE";
151:                } else if (cl.equals(Double.class)) {
152:                    return "PTypeSpace.OBJDOUBLE";
153:                } else if (cl.equals(java.util.Date.class)
154:                        || cl.equals(java.sql.Date.class)
155:                        || cl.equals(java.sql.Time.class)
156:                        || cl.equals(java.sql.Timestamp.class)) {
157:                    return "PTypeSpace.DATE";
158:                } else if (cl.equals(java.math.BigDecimal.class)) {
159:                    return "PTypeSpace.BIGDECIMAL";
160:                } else if (EJBLocalObject.class.isAssignableFrom(cl)) {
161:                    return "PTypeSpaceMedor.PNAME";
162:                } else if (cl.isArray()
163:                        && java.lang.Byte.TYPE.equals(cl.getComponentType())) {
164:                    return "PTypeSpace.BYTEARRAY";
165:                } else if (cl.isArray()
166:                        && java.lang.Character.TYPE.equals(cl
167:                                .getComponentType())) {
168:                    return "PTypeSpace.CHARARRAY";
169:                }
170:                return "PTypeSpace.SERIALIZED";
171:            }
172:
173:            /**
174:             * It retrieves a coding type either a Class
175:             * @param the Class
176:             * @param isPkField true if this is for a field of the primary key, false otherwise
177:             * @return a coding type wich matches to one of CTxxx fields of the
178:             * PNamingcontext interface.
179:             * @throws PExceptionNaming when the class specified is not support in
180:             * the jorm naming.
181:             */
182:            public static short getCodingType(Class c, boolean isPkField)
183:                    throws PExceptionNaming {
184:                if (c == null) {
185:                    throw new PExceptionNaming(
186:                            "No CodingType associated to a null Class");
187:                }
188:                return getCodingType(getPType(c, isPkField).getTypeCode());
189:            }
190:
191:            /**
192:             * It converts a PType into a coding type.
193:             * @param a  PType
194:             * @return a coding type wich matches to one of CTxxx fields of the
195:             * PNamingcontext interface.
196:             * @throws PExceptionNaming when the PType specified is not support in
197:             * the jorm naming.
198:             */
199:            public static short getCodingType(PType pt) throws PExceptionNaming {
200:                if (pt == null) {
201:                    throw new PExceptionNaming(
202:                            "No CodingType associated to a null PType");
203:                }
204:                return getCodingType(pt.getTypeCode());
205:            }
206:
207:            /**
208:             * It converts a type code into a coding type.
209:             * @param a type code of a PType
210:             * @return a coding type wich matches to one of CTxxx fields of the
211:             * PNamingcontext interface.
212:             * @throws PExceptionNaming when the type code specified is not support in
213:             * the jorm naming.
214:             */
215:            public static short getCodingType(int typeCode)
216:                    throws PExceptionNaming {
217:                switch (typeCode) {
218:                case PType.TYPECODE_CHAR:
219:                    return PNamingContext.CTCHAR;
220:                case PType.TYPECODE_OBJCHAR:
221:                    return PNamingContext.CTOCHAR;
222:
223:                case PType.TYPECODE_BYTE:
224:                    return PNamingContext.CTBYTE;
225:                case PType.TYPECODE_OBJBYTE:
226:                    return PNamingContext.CTOBYTE;
227:
228:                case PType.TYPECODE_SHORT:
229:                    return PNamingContext.CTSHORT;
230:                case PType.TYPECODE_OBJSHORT:
231:                    return PNamingContext.CTOSHORT;
232:
233:                case PType.TYPECODE_INT:
234:                    return PNamingContext.CTINT;
235:                case PType.TYPECODE_OBJINT:
236:                    return PNamingContext.CTOINT;
237:
238:                case PType.TYPECODE_LONG:
239:                    return PNamingContext.CTLONG;
240:                case PType.TYPECODE_OBJLONG:
241:                    return PNamingContext.CTOLONG;
242:
243:                case PType.TYPECODE_BYTEARRAY:
244:                    return PNamingContext.CTBYTEARRAY;
245:
246:                case PType.TYPECODE_CHARARRAY:
247:                    return PNamingContext.CTCHARARRAY;
248:
249:                case PType.TYPECODE_STRING:
250:                    return PNamingContext.CTSTRING;
251:
252:                case PType.TYPECODE_DATE:
253:                    return PNamingContext.CTDATE;
254:
255:                default:
256:                    throw new PExceptionNaming(
257:                            "This type is not suportted: typeCode=" + typeCode);
258:                }
259:            }
260:
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.