KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jorm > type > api > PTypeSpace


1 /**
2  * JORM: an implementation of a generic mapping system for persistent Java
3  * objects. Two mapping are supported: to RDBMS and to binary files.
4  * Copyright (C) 2001-2003 France Telecom R&D - INRIA
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Contact: jorm-team@objectweb.org
21  *
22  */

23
24 package org.objectweb.jorm.type.api;
25
26 import java.io.Serializable JavaDoc;
27
28 /**
29  * The <b>PTypeSpace</b> interface defines a space of JORM type along with
30  * the inheritance relationships that may exist between them.
31  * @author P. D?chamboux
32  */

33 public interface PTypeSpace extends Serializable JavaDoc {
34     final static PType BOOLEAN = new PType(PType.TYPECODE_BOOLEAN,
35                                            "boolean", "boolean", "PTypeSpace.BOOLEAN", null);
36     final static PType CHAR = new PType(PType.TYPECODE_CHAR,
37                                         "char", "char", "PTypeSpace.CHAR", "Char");
38     final static PType BYTE = new PType(PType.TYPECODE_BYTE,
39                                         "byte", "byte", "PTypeSpace.BYTE", "Byte");
40     final static PType SHORT = new PType(PType.TYPECODE_SHORT,
41                                          "short", "short", "PTypeSpace.SHORT", "Short");
42     final static PType INT = new PType(PType.TYPECODE_INT,
43                                        "int", "int", "PTypeSpace.INT", "Int");
44     final static PType LONG = new PType(PType.TYPECODE_LONG,
45                                         "long", "long", "PTypeSpace.LONG", "Long");
46     final static PType FLOAT = new PType(PType.TYPECODE_FLOAT,
47                                          "float", "float", "PTypeSpace.FLOAT", null);
48     final static PType DOUBLE = new PType(PType.TYPECODE_DOUBLE,
49                                           "double", "double", "PTypeSpace.DOUBLE", null);
50     final static PType OBJBOOLEAN = new PType(PType.TYPECODE_OBJBOOLEAN,
51                                               "Boolean", "java.lang.Boolean", "PTypeSpace.OBJBOOLEAN", null);
52     final static PType OBJCHAR = new PType(PType.TYPECODE_OBJCHAR,
53                                            "Char", "java.lang.Character", "PTypeSpace.OBJCHAR", "Ochar");
54     final static PType OBJBYTE = new PType(PType.TYPECODE_OBJBYTE,
55                                            "Byte", "java.lang.Byte", "PTypeSpace.OBJBYTE", "Obyte");
56     final static PType OBJSHORT = new PType(PType.TYPECODE_OBJSHORT,
57                                             "Short", "java.lang.Short", "PTypeSpace.OBJSHORT", "Oshort");
58     final static PType OBJINT = new PType(PType.TYPECODE_OBJINT,
59                                           "Int", "java.lang.Integer", "PTypeSpace.OBJINT", "Oint");
60     final static PType OBJLONG = new PType(PType.TYPECODE_OBJLONG,
61                                            "Long", "java.lang.Long", "PTypeSpace.OBJLONG", "Olong");
62     final static PType OBJFLOAT = new PType(PType.TYPECODE_OBJFLOAT,
63                                             "Float", "java.lang.Float", "PTypeSpace.OBJFLOAT", null);
64     final static PType OBJDOUBLE = new PType(PType.TYPECODE_OBJDOUBLE,
65                                              "Double", "java.lang.Double", "PTypeSpace.OBJDOUBLE", null);
66     final static PType STRING = new PType(PType.TYPECODE_STRING,
67                                           "string", "java.lang.String", "PTypeSpace.STRING", "String");
68     final static PType DATE = new PType(PType.TYPECODE_DATE,
69                                         "date", "java.util.Date", "PTypeSpace.DATE", "Date");
70     final static PType CHARARRAY = new PType(PType.TYPECODE_CHARARRAY,
71                                              "chararray", "char[]", "PTypeSpace.CHARARRAY", "CharArray");
72     final static PType BYTEARRAY = new PType(PType.TYPECODE_BYTEARRAY,
73                                              "bytearray", "byte[]", "PTypeSpace.BYTEARRAY", "");
74     final static PType SERIALIZED = new PType(PType.TYPECODE_SERIALIZED,
75                                               "serialized", "java.io.Serializable", "PTypeSpace.SERIALIZED", null);
76     final static PType BIGINTEGER = new PType(PType.TYPECODE_BIGINTEGER,
77                                               "BigInteger", "java.math.BigInteger", "PTypeSpace.BIGINTEGER", "BigInteger");
78     final static PType BIGDECIMAL = new PType(PType.TYPECODE_BIGDECIMAL,
79                                               "BigDecimal", "java.math.BigDecimal", "PTypeSpace.BIGDECIMAL", "BigDecimal");
80     final static PType REFTOP = new PType(PType.TYPECODE_REFERENCE,
81                                           "object", "java.lang.Object", "PTypeSpace.REFTOP", null);
82     final static PType[] PREDEFINEDPTYPES = {
83         BOOLEAN, BYTE, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE,
84         OBJBOOLEAN, OBJBYTE, OBJCHAR, OBJSHORT, OBJINT, OBJLONG, OBJFLOAT, OBJDOUBLE,
85         STRING, DATE, SERIALIZED, BIGINTEGER, BIGDECIMAL, REFTOP, CHARARRAY, BYTEARRAY
86     };
87     final static PType[] SCALARPTYPES = {
88         BOOLEAN, BYTE, CHAR, SHORT, INT, LONG,
89         OBJBOOLEAN, OBJBYTE, OBJCHAR, OBJSHORT, OBJINT, OBJLONG,
90         STRING, DATE, CHARARRAY, BYTEARRAY, BIGINTEGER, BIGDECIMAL
91     };
92
93     /**
94      *
95      */

96     final static PType[] NULLSUPERTYPES = new PType[0];
97
98     /**
99      *
100      */

101     final static String JavaDoc[][] NULLSUPERCLASSNAMES = new String JavaDoc[0][];
102
103     /**
104      * It creates a new PType for a JORM class that has no inherited class.
105      * @param classname The name of the JORM class.
106      * @return The created PType or the existing one if it has the same
107      * definition (same name and same super types).
108      * @exception PExceptionTyping Raised when a PType with this class name
109      * exists with a different array of super
110      * types.
111      */

112     PType createPType(String JavaDoc classname) throws PExceptionTyping;
113
114     /**
115      * It creates a new PType for a JORM class. It is defined by its name and
116      * its inheritance hierarchy. For example, if "Engineer" inherits from
117      * "Employee" that inherits from "Person", then the following stands:
118      * <bl>
119      * <li>classname = "schm1.Engineer"</li>
120      * <li>superclassnames = {{"schm1.Engineer", "schm2.Employee"},
121      * {"schm2.Employee", "schm3.Person"}}</li>
122      * </bl>
123      * @param classname The name of the JORM class to be defined.
124      * @param superclassnames The hierarchy of of classes inherited by the
125      * previous class (defined by classname) if any.
126      * @return The created PType or the existing one if it has the same
127      * definition (same name and same super types).
128      * @exception PExceptionTyping Raised when a PType with this class name
129      * exists with a different array of super
130      * types.
131      */

132     PType createPType(String JavaDoc classname, String JavaDoc[][] superclassnames)
133             throws PExceptionTyping;
134
135     /**
136      * It creates a new PType for a JORM generic class instance. Such an
137      * instance may have a nested structure like
138      * "list<array<set<int>>>", which means that:
139      * <bl>
140      * <li>gcnames = {"list", "array", "set"}</li>
141      * <li>ptypename = INT</li>
142      * </bl>
143      * @param gcnames The array of names of the nested generic classes.
144      * @param ptype The PType of the type of the elements contained
145      * within this generic class, which is one of those
146      * defined inside PREDEFINEDPTYPES.
147      * @return The created PType or the existing one if it has the same
148      * definition (same name and same element type).
149      * @exception PExceptionTyping Raised when a PType with this class name
150      * exists with a different inner PType
151      */

152     PType createPType(String JavaDoc[] gcnames, PType ptype) throws PExceptionTyping;
153
154     /**
155      * It creates a new PType for a JORM generic class instance. Such an
156      * instance may have a nested structure like
157      * "list<array<set<schm1.Engineer>>>", which means that:
158      * <bl>
159      * <li>gcnames = {"list", "array", "set"}</li>
160      * <li>typename = "schm1.Engineer"</li>
161      * <li>superclassnames = {{"schm1.Engineer", "schm2.Employee"},
162      * {"schm2.Employee", "schm3.Person"}}</li>
163      * </bl>
164      * @param gcnames The array of names of the nested generic
165      * classes.
166      * @param typename The name of the type of the elements contained
167      * within this generic class.
168      * @param superclassnames The hierarchy of of classes inherited by the
169      * previous class (defined by typename) if any.
170      * @return The created PType or the existing one if it has the same
171      * definition (same name and same element type).
172      * @exception PExceptionTyping Raised when a PType with this class name
173      * exists with a different inner PType
174      */

175     PType createPType(String JavaDoc[] gcnames, String JavaDoc typename,
176                       String JavaDoc[][] superclassnames) throws PExceptionTyping;
177
178     /**
179      * It tries to retrieve a PType representing a JORM class with the given
180      * class name.
181      * @param classname The name of a JORM class the PType is looking for.
182      * @return The relevant PType if one has been found or null if none found.
183      */

184     PType getPType(String JavaDoc classname);
185
186     /**
187      * Retrieves all subtypes of this PType defined within its PTypeSpace.
188      * @param pt The concerned PType.
189      * @return The array of PType containing all these subtypes.
190      */

191     PType[] getSubTypes(PType pt);
192
193     /**
194      * It compares to PType representing JORM classes. It verifies if the first
195      * one conforms to the second one.
196      * @param pt1 The first JORM class PType.
197      * @param pt2 The second JORM class PType.
198      * @return It returns true if pt1 conforms to pt2.
199      */

200     boolean isa(PType pt1, PType pt2);
201 }
202
Popular Tags