KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > tools > enhancer > info > FieldInfo


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdo.tools.enhancer.info;
13
14 import com.versant.lib.bcel.generic.Type;
15
16
17 import com.versant.core.metadata.MDStatics;
18
19 import javax.jdo.spi.PersistenceCapable;
20 /**
21  *
22  */

23 public class FieldInfo implements Comparable JavaDoc{
24
25     private String JavaDoc jdoSetName;
26     private String JavaDoc jdoGetName;
27     private String JavaDoc returnType;
28     private String JavaDoc fieldName;
29     private String JavaDoc className;
30     private String JavaDoc primativeTypeObject;
31     private String JavaDoc signature;
32     private Type type;
33     private int fieldNo;
34     private int persistenceModifier;
35     private boolean primaryKey;
36     private boolean defaultFetchGroup;
37     private boolean isPublic;
38     private boolean isPrivate;
39     private boolean isProtected;
40     private boolean isArray;
41     private boolean isPrimative;
42
43
44
45
46     public FieldInfo() {}
47
48
49     public int getFieldNo() {
50         return fieldNo;
51     }
52
53     public void setFieldNo(int fieldNo) {
54         this.fieldNo = fieldNo;
55     }
56
57     public String JavaDoc getClassName() {
58         return className;
59     }
60
61     public void setClassName(String JavaDoc className) {
62         this.className = className;
63     }
64
65
66
67     public void setSignature(String JavaDoc signature){
68         this.signature = signature;
69     }
70
71
72     public String JavaDoc getSignature(){
73         return signature;
74     }
75
76     public void setType(Type type){
77         this.type = type;
78     }
79     public Type getType(){
80         return type;
81     }
82
83     public byte getFlag(){
84         if (persistenceModifier == MDStatics.PERSISTENCE_MODIFIER_TRANSACTIONAL){
85             return PersistenceCapable.CHECK_WRITE;
86         } else if (primaryKey){
87             return PersistenceCapable.MEDIATE_WRITE;
88         } else if (defaultFetchGroup){
89             return PersistenceCapable.CHECK_READ + PersistenceCapable.CHECK_WRITE;
90         } else {
91             return PersistenceCapable.MEDIATE_READ + PersistenceCapable.MEDIATE_WRITE;
92         }
93     }
94
95     /**
96      * Implements Comparable to order all fields by name
97      *
98      */

99     public int compareTo(Object JavaDoc o){
100         FieldInfo other = (FieldInfo)o;
101         return fieldName.compareTo(other.getFieldName());
102     }
103
104     public boolean equals(Object JavaDoc other){
105         if (other != null && getClass() == other.getClass()){
106             FieldInfo otherFieldInfo = (FieldInfo)other;
107             return fieldName.equals(otherFieldInfo.getFieldName());
108         } else {
109             return false;
110         }
111     }
112
113     public int hashCode(){
114         return 13 * fieldName.hashCode();
115     }
116     /**
117      * Gets the jdoSetName.
118      */

119     public String JavaDoc getJdoSetName(){
120         return jdoSetName;
121     }
122     /**
123      * Sets the jdoSetName.
124      */

125     public void setJdoSetName(String JavaDoc jdoSetName){
126         this.jdoSetName = jdoSetName;
127     }
128     /**
129      * Gets the jdoGetName.
130      */

131     public String JavaDoc getJdoGetName(){
132         return jdoGetName;
133     }
134     /**
135      * Sets the jdoGetName.
136      */

137     public void setJdoGetName(String JavaDoc jdoGetName){
138         this.jdoGetName = jdoGetName;
139     }
140     /**
141      * Gets the returnType.
142      */

143     public String JavaDoc getReturnType(){
144         return returnType;
145     }
146     /**
147      * Sets the returnType.
148      */

149     public void setReturnType(String JavaDoc returnType){
150         this.returnType = returnType;
151     }
152     /**
153      * Gets the fieldName.
154      */

155     public String JavaDoc getFieldName(){
156         return fieldName;
157     }
158     /**
159      * Sets the fieldName.
160      */

161     public void setFieldName(String JavaDoc fieldName){
162         this.fieldName = fieldName;
163     }
164
165     /**
166      * Gets the persistence modifier.
167      */

168     public int getPersistenceModifier(){
169         return persistenceModifier;
170     }
171     /**
172      * Sets the persistence modifier.
173      */

174     public void setPersistenceModifier(int persistenceModifier){
175         this.persistenceModifier = persistenceModifier;
176     }
177
178     /**
179      * Sets primaryKey.
180      */

181     public void primaryKey(boolean primaryKey){
182         this.primaryKey = primaryKey;
183     }
184     /**
185      * Gets primaryKey.
186      */

187     public boolean primaryKey(){
188         return primaryKey;
189     }
190     /**
191      * Sets default fetch group.
192      */

193     public void defaultFetchGroup(boolean defaultFetchGroup){
194         this.defaultFetchGroup = defaultFetchGroup;
195     }
196
197
198     /**
199      * Sets isPublic.
200      */

201     public void isPublic(boolean isPublic){
202         this.isPublic = isPublic;
203     }
204     /**
205      * Gets isPublic.
206      */

207     public boolean isPublic(){
208         return isPublic;
209     }
210     /**
211      * Sets isPrivate.
212      */

213     public void isPrivate(boolean isPrivate){
214         this.isPrivate = isPrivate;
215     }
216     /**
217      * Gets isPrivate.
218      */

219     public boolean isPrivate(){
220         return isPrivate;
221     }
222     /**
223      * Sets isProtected.
224      */

225     public void isProtected(boolean isProtected){
226         this.isProtected = isProtected;
227     }
228     /**
229      * Gets isProtected.
230      */

231     public boolean isProtected(){
232         return isProtected;
233     }
234     /**
235      * Sets isArray.
236      */

237     public void isArray(boolean isArray){
238         this.isArray = isArray;
239     }
240     /**
241      * Gets isArray.
242      */

243     public boolean isArray(){
244         return isArray;
245     }
246     /**
247      * Sets isPrimative.
248      */

249     public void isPrimative(boolean isPrimative){
250         this.isPrimative = isPrimative;
251     }
252     /**
253      * Gets isPrimative.
254      */

255     public boolean isPrimative(){
256         return isPrimative;
257     }
258
259     /**
260      * Sets primative type object.
261      */

262     public void setPrimativeTypeObject(String JavaDoc primativeTypeObject){
263         this.primativeTypeObject = primativeTypeObject;
264     }
265     /**
266      * Gets primative type object.
267      */

268     public String JavaDoc getPrimativeTypeObject(){
269         return primativeTypeObject;
270     }
271
272     public String JavaDoc toString(){
273         return "\n************ Field "+fieldName+"************\n"+
274                 "jdoSetName = "+jdoSetName+"\n"+
275                 "jdoGetName = "+jdoGetName+"\n"+
276                 "returnType = "+returnType+"\n"+
277                 "fieldName = "+fieldName+"\n"+
278                 "persistenceModifier = "+persistenceModifier+"\n"+
279                 "primaryKey = "+primaryKey+"\n"+
280                 "defaultFetchGroup = "+(primaryKey ? false : defaultFetchGroup)+"\n"+
281                 "primativeTypeObject = "+primativeTypeObject+"\n"+
282                 "isPublic = "+isPublic+"\n"+
283                 "isPrivate = "+isPrivate+"\n"+
284                 "isProtected = "+isProtected+"\n"+
285                 "isArray = "+isArray+"\n"+
286                 "isPrimative = "+isPrimative+"\n"+
287                 "Type = "+type+"\n"+
288                 "*********************************************\n";
289     }
290
291 }
292
Popular Tags