KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > impl > meta > type > MetaTypeFactory


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

24 package org.objectweb.jalisto.se.impl.meta.type;
25
26 import org.objectweb.jalisto.se.api.MetaType;
27 import org.objectweb.jalisto.se.exception.SchemaException;
28
29 public class MetaTypeFactory {
30
31     public static MetaType getBasicMetaType(Class JavaDoc javaClass) {
32         String JavaDoc className = javaClass.getName();
33         if (className.equals("double") || className.equals("java.lang.Double")) {
34             return new DoubleType();
35         } else if (className.equals("float") || className.equals("java.lang.Float")) {
36             return new FloatType();
37         } else if (className.equals("int") || className.equals("java.lang.Integer")) {
38             return new IntegerType();
39         } else if (className.equals("long") || className.equals("java.lang.Long")) {
40             return new LongType();
41         } else if (className.equals("short") || className.equals("java.lang.Short")) {
42             return new ShortType();
43         } else if (className.equals("boolean") || className.equals("java.lang.Boolean")) {
44             return new BooleanType();
45         } else if (className.equals("byte") || className.equals("java.lang.Byte")) {
46             return new ByteType();
47         } else if (className.equals("char") || className.equals("java.lang.Character")) {
48             return new CharacterType();
49         } else if (className.equals("java.lang.String")) {
50             return new StringType();
51         } else if (className.equals("java.math.BigDecimal")) {
52             return new BigDecimalType();
53         } else if (className.equals("java.math.BigInteger")) {
54             return new BigIntegerType();
55         } else if (className.equals("java.util.Date")) {
56             return new DateType();
57         }
58         throw new SchemaException("unknown basic type : " + className);
59     }
60
61     public static MetaType getMetaType(String JavaDoc typeName) {
62         if (typeName.equals("Double")) {
63             return new DoubleType();
64         } else if (typeName.equals("Float")) {
65             return new FloatType();
66         } else if (typeName.equals("Boolean")) {
67             return new BooleanType();
68         } else if (typeName.equals("Integer")) {
69             return new IntegerType();
70         } else if (typeName.equals("Link")) {
71             return new LinkType();
72         } else if (typeName.equals("Long")) {
73             return new LongType();
74         } else if (typeName.equals("Byte")) {
75             return new ByteType();
76         } else if (typeName.equals("Character")) {
77             return new CharacterType();
78         } else if (typeName.equals("Serialized")) {
79             return new SerializedType();
80         } else if (typeName.equals("Short")) {
81             return new ShortType();
82         } else if (typeName.equals("String")) {
83             return new StringType();
84         } else if (typeName.equals("BigInteger")) {
85             return new BigIntegerType();
86         } else if (typeName.equals("BigDecimal")) {
87             return new BigDecimalType();
88         } else if (typeName.equals("Date")) {
89             return new DateType();
90         } else if (typeName.equals("Array")) {
91             return new ArrayType();
92         } else if (typeName.equals("Collection")) {
93             return new CollectionType();
94         } else if (typeName.equals("Map")) {
95             return new MapType();
96         }
97         throw new SchemaException("unknown type : " + typeName);
98     }
99
100     public static final MetaType ArrayType = new ArrayType();
101     public static final MetaType BigDecimalType = new BigDecimalType();
102     public static final MetaType BigIntegerType = new BigIntegerType();
103     public static final MetaType BooleanType = new BooleanType();
104     public static final MetaType ByteType = new ByteType();
105     public static final MetaType CharacterType = new CharacterType();
106     public static final MetaType CollectionType = new CollectionType();
107     public static final MetaType DateType = new DateType();
108     public static final MetaType DoubleType = new DoubleType();
109     public static final MetaType FloatType = new FloatType();
110     public static final MetaType IntegerType = new IntegerType();
111     public static final MetaType LinkType = new LinkType();
112     public static final MetaType LongType = new LongType();
113     public static final MetaType MapType = new MapType();
114     public static final MetaType SerializedType = new SerializedType();
115     public static final MetaType ShortType = new ShortType();
116     public static final MetaType StringType = new StringType();
117 }
118
Popular Tags