KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > metadata > SpeedoField


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2004 France Telecom R&D
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  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  * Authors: S.Chassande-Barrioz.
25  *
26  */

27
28 package org.objectweb.speedo.metadata;
29
30 import org.objectweb.asm.Constants;
31 import org.objectweb.asm.Type;
32 import org.objectweb.speedo.generation.enhancer.Util;
33
34 /**
35  * This class corresponds to the description of persistent capable fields.
36  * @author S.Chassande-Barrioz
37  */

38 public class SpeedoField extends SpeedoElement {
39
40     public final static byte NO_RELATION = 0;
41     public final static byte ONE_ONE_RELATION = 1;
42     public final static byte ONE_MANY_RELATION = 2;
43     public final static byte MANY_ONE_RELATION = 3;
44     public final static byte MANY_MANY_RELATION = 4;
45
46     /**
47      * name of the persistent field
48      */

49     public String JavaDoc name;
50
51     /**
52      * modifier of the field (public | protected | private)
53      */

54     public int access;
55
56     /**
57      * Type of the persistent field
58      */

59     public String JavaDoc desc;
60
61     /**
62      * is the index of the persistent field. This field is computed through a
63      * MI visitor.
64      */

65     public int number = -1;
66
67     /**
68      * Attribute persistence-modifier in the XML file.
69      */

70     public byte persistenceModifier = SpeedoModifier.missing;
71
72     /**
73      * Boolean indicating if the field is a primary key.
74      */

75     public boolean primaryKey = false;
76
77     /**
78      * Attribute null-value in the XML file.
79      */

80     public byte nullValue = SpeedoNullValue.NONE;
81
82     /**
83      * This boolean indicates if the field is in the default fetch group.
84      * (not managed)
85      */

86     public boolean defaultFetchGroup = true;
87
88     /**
89      * Recursive fetchgroups are controlled by the depth attribute. A depth of 0 (the default)
90      * will fetch the whole graph of instances reachable from this field.
91      */

92     public int depth = 0;
93     
94     public String JavaDoc fetchGroup;
95     
96     /**
97      * Attribute embedded of the XML file. (not managed)
98      */

99     public boolean embedded = true;
100
101     /**
102      * Attribute value-strategy
103      */

104     public String JavaDoc valueStrategy;
105         
106     /**
107      * Attribute sequence
108      */

109     public String JavaDoc sequence;
110     
111     /**
112      * Type of the relation containinig the persistent field
113      * @see #NO_RELATION
114      * @see #ONE_ONE_RELATION
115      * @see #ONE_MANY_RELATION
116      * @see #MANY_ONE_RELATION
117      * @see #MANY_MANY_RELATION
118      */

119     public byte relationType = NO_RELATION;
120
121     /**
122      * Type of the tuple represented by this SpeedoField if it is a tuple
123      */

124     public SpeedoTuple jdoTuple;
125
126     /**
127      * Description of the class containing the field.
128      */

129     public SpeedoClass jdoClass;
130
131     
132     /**
133      * Transforms a SpeedoField into a String.
134      * @return the String corresponding to the SpeedoField.
135      */

136     public String JavaDoc toString() {
137         String JavaDoc s = "\n field name : " + name + ", persistenceModifier : "
138                 + persistenceModifier + ", primaryKey : " + primaryKey
139                 + ", nullValue : " + nullValue + ", defaultFetchGroup : "
140                 + defaultFetchGroup + ", embedded : " + embedded
141                 + ", fetchGroup : " + fetchGroup + ", depth : " + depth
142                 + ", valueStrategy : " + valueStrategy + " , sequence : " + sequence;
143         if (jdoTuple != null)
144             s = s + jdoTuple.toString();
145         return s;
146     }
147
148     /**
149      * Returns the field's signature with a public modifier.
150      * @return the String containing the field' signature with a public modifier.
151      */

152     public String JavaDoc publicSignature() {
153         int publicAccess = access;
154         publicAccess &= ~(Constants.ACC_PRIVATE | Constants.ACC_PROTECTED);
155         publicAccess |= Constants.ACC_PUBLIC;
156         return Util.modifier(publicAccess) + type() + " " + name;
157     }
158
159     /**
160      * Returns the field's signature with a private modifier.
161      * @return the String containing the field' signature with a private modifier.
162      */

163     public String JavaDoc privateSignature() {
164         int privateAccess = access;
165         privateAccess &= ~(Constants.ACC_PUBLIC | Constants.ACC_PROTECTED);
166         privateAccess |= Constants.ACC_PRIVATE;
167         return Util.modifier(privateAccess) + type() + " " + name;
168     }
169
170     /**
171      * Returns the field's modifier
172      * @return the String representing the modifier (<code>public</code>,
173      * <code>private</code>, <code>protected</code>)
174      */

175     public String JavaDoc modifier() {
176         return Util.modifier(access);
177     }
178
179     /**
180      * Returns the type of the field.
181      * @return type of the field.
182      */

183     public String JavaDoc type() {
184         return Util.type(Type.getType(desc));
185     }
186 }
187
Popular Tags