KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jorm > metainfo > api > GenClassRef


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.metainfo.api;
25
26 import org.objectweb.jorm.type.api.PType;
27
28 import java.util.Collection JavaDoc;
29
30 /**
31  * A GenClassRef is an interface which describes method to define
32  * a class field which can be a reference to a generic class.
33  * A GenClassRef object is composed by a PrimitiveElement (a primitive type),
34  * or a ClassRef (a reference to a Class), or an another GenClassRef (a
35  * reference to a generic class.
36  * A recursion is defined when a GenClassRef object is composed by an other
37  * GenClassRef object. A final object of the recursion is a PrimitiveElement
38  * or a ClassRef objects.
39  * @author X. Spengler
40  */

41 public interface GenClassRef extends Reference {
42     /**
43      * Creates a new PrimitiveElement object, and attach it to the current GenClassRef
44      * This method must be used when the recursion is finished (we are on
45      * final object which is a PrimitiveElement).
46      * @param type is the PType of the primitive element which will be created
47      * @return PrimitiveElement the primitive element which defines the current
48      * GenClassRef object. This object is the final
49      * object of the recursion.
50      */

51     PrimitiveElement createPrimitiveElement(PType type, int size, int scale);
52
53     /**
54      * Creates a new ClassRef object, and attach it to the current GenClassRef
55      * This method must be used when the recursion is finished (we are on
56      * final object which is a ClassRef).
57      * @param clazz the reference to the Class object which defines the
58      * current GenClassRef object. This object is the final
59      * object of the recursion.
60      * @return ClassRef a new ClassRef object
61      */

62     ClassRef createClassRef(Class JavaDoc clazz);
63
64     /**
65      * Creates a new GenClassRef object.
66      * This method must be used when the recursion is not finished (we are on
67      * not final object).
68      * @param genClassRefName the name of the generic class used to create a
69      * new GenClassRef object
70      * @return a new GenClassRef object
71      */

72     GenClassRef createGenClassRef(String JavaDoc genClassRefName);
73
74     /**
75      * Returns the PrimitiveElement object which defines the current GenClassRef
76      * object.
77      * This method is used after a call to isPrimitive() method, to determine
78      * if the current object is a "basic" type.
79      * @return the current type of the field. This method always returns a
80      * PType object, and can not return null value because of the
81      * previous test.
82      */

83     PrimitiveElement getPrimitiveElement();
84
85     /**
86      * Removes the primitive element.
87      * @param fieldName is the name of the field to be removed
88      * @return the removed primitive element.
89      */

90     TypedElement removeTypedElement(String JavaDoc fieldName);
91     
92     /**
93      * Returns the ClassRef object which defines the current GenClassRef object.
94      * This method is used after a call to isClassRef() method, to determine if
95      * the current object is defined by a final class or not.
96      * @return the final Class which describes the type of the object which
97      * defines the GenClassRef object. This method always returns a
98      * Class, and can not return null value because of the previous
99      * test.
100      */

101     ClassRef getClassRef();
102
103     /**
104      * Returns the GenClassRef object which defines the current GenClassRef
105      * object.
106      * This object exists when it is in a recursion. This method is used after a
107      * call to isGenClassRef() method, to determine if the current object is a
108      * reference to a generic class or not.
109      * @return the underlying reference to the generic class. This method
110      * always returns a GenClassRef, and can not return null value
111      * because of the previous test.
112      */

113     GenClassRef getGenClassRef();
114
115     /**
116      * Allows to know if the current object is primitive or not (final and
117      * "basic").
118      * @return true, if the current object is primitive, else false, if the
119      * object is not primitive (either a reference to a Class, or
120      * a reference to a generic class).
121      */

122     boolean isPrimitive();
123
124     /**
125      * Allows to know if the current object is a reference to a Class or not.
126      * @return true, if the object is a reference to a Class, else false, if
127      * the object is not a reference to a Class (either a primitive
128      * object, or a reference to a generic class).
129      */

130     boolean isClassRef();
131
132     /**
133      * Allows to know if the current object is a reference to a generic class
134      * or not.
135      * @return true, if the object is a reference to a generic class, else
136      * false, if the object is not a reference to a generic class
137      * (either a primitive object, or a reference to a class).
138      */

139     boolean isGenClassRef();
140
141     /**
142      * Creates a new NameDef object for the new GenClassRef object.
143      * @return a new object used to describe the PName projection for
144      * the current Class
145      */

146     NameDef createIdNameDef();
147
148     /**
149      * Returns an iterator on existing NameDef of GenClassRef object.
150      * If no NameDef exists, an empty iterator is returned.
151      * @return an iterator on NameDef object
152      */

153     Collection JavaDoc getIdNameDef();
154
155     /**
156      * Returns a NameDef object.
157      * If the namedef does not exist, null is returned.
158      *
159      * @param projectName the name of the project.
160      * @return an existing namedef object,else null is returned.
161      */

162     NameDef getIdNameDef(String JavaDoc projectName);
163
164     /**
165      * Returns the name of the GenClass object. ("Set", ..)
166      * @return the name of the GenClassRef object
167      */

168     String JavaDoc getGenClassName();
169
170     /**
171      * Returns the id of the GenClass object. ("Set/List/String", ..)
172      * @return the id of the GenClassRef object
173      */

174     String JavaDoc getGenClassId();
175
176     /**
177      * Create a new hidden field for the refgenclass.
178      * @return the ScalarField
179      */

180     ScalarField createHiddenField(String JavaDoc fieldName, PType type, int size, int scale);
181
182     /**
183      * return the collection of the hiddenfield of the refgenclass definition.
184      * @return the collection containing the hiddenfield (ScalarField).
185      */

186     Collection JavaDoc getHiddenFields();
187
188     /**
189      * retrieve an hiddenfield from its name.
190      * @return the hiddenfield.
191      */

192     ScalarField getHiddenField(String JavaDoc fieldName);
193
194     /**
195      * @param indexFieldName the name of the index field
196      */

197     void addIndexField(String JavaDoc indexFieldName);
198
199     /**
200      * Allows to know all the existing index field for the current generic
201      * class.
202      * This iterator contains PrimitiveElement objects. If no index field
203      * exists, an empty iterator is returned.
204      *
205      * @return an Iterator on index field (PrimitiveElement). If there is no
206      * index field to return, an empty iterator is returned.
207      */

208     Collection JavaDoc getIndexFields();
209 }
210
Popular Tags