KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb > plugins > cmp > ejbql > EJBQLTypes


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.ejb.plugins.cmp.ejbql;
23
24 import java.util.Date JavaDoc;
25 import javax.ejb.EJBLocalObject JavaDoc;
26 import javax.ejb.EJBObject JavaDoc;
27
28 /**
29  * This class contains a list of the reconized EJB-QL types.
30  *
31  * @author <a HREF="mailto:dain@daingroup.com">Dain Sundstrom</a>
32  * @author <a HREF="mailto:alex@jboss.org">Alexey Loubyansky</a>
33  * @version $Revision: 37459 $
34  */

35 public final class EJBQLTypes
36 {
37    public static final int UNKNOWN_TYPE = -1;
38    public static final int NUMERIC_TYPE = 1;
39    public static final int STRING_TYPE = 2;
40    public static final int DATETIME_TYPE = 3;
41    public static final int BOOLEAN_TYPE = 4;
42    public static final int ENTITY_TYPE = 5;
43    public static final int VALUE_CLASS_TYPE = 6;
44
45    public static int getEJBQLType(Class JavaDoc type)
46    {
47       int result;
48       if(type == Boolean JavaDoc.class || type == Boolean.TYPE)
49       {
50          result = BOOLEAN_TYPE;
51       }
52       else if(type.isPrimitive()
53          || type == Character JavaDoc.class
54          || Number JavaDoc.class.isAssignableFrom(type))
55       {
56          result = NUMERIC_TYPE;
57       }
58       else if(type == String JavaDoc.class)
59       {
60          result = STRING_TYPE;
61       }
62       else if(Date JavaDoc.class.isAssignableFrom(type))
63       {
64          result = DATETIME_TYPE;
65       }
66       else if(EJBObject JavaDoc.class.isAssignableFrom(type) ||
67          EJBLocalObject JavaDoc.class.isAssignableFrom(type))
68       {
69          result = ENTITY_TYPE;
70       }
71       else
72       {
73          result = VALUE_CLASS_TYPE;
74       }
75       return result;
76    }
77 }
78
Popular Tags