1 23 24 29 30 package com.sun.jdo.api.persistence.model.jdo; 31 32 import java.util.ArrayList ; 33 34 import com.sun.jdo.api.persistence.model.ModelException; 35 36 42 43 48 public class PersistenceFieldElement extends PersistenceMemberElement 49 { 50 51 public static final int PERSISTENT = 0; 52 53 54 public static final int DERIVED = 1; 55 56 61 public static final int TRANSIENT = 2; 62 63 66 public PersistenceFieldElement () 67 { 68 this(null, null); 69 } 70 71 76 public PersistenceFieldElement (PersistenceFieldElement.Impl impl, 77 PersistenceClassElement declaringClass) 78 { 79 super(impl, declaringClass); 80 } 81 82 84 final Impl getFieldImpl () { return (Impl)getImpl(); } 85 86 90 public int getPersistenceType () 91 { 92 return getFieldImpl().getPersistenceType(); 93 } 94 95 100 public void setPersistenceType (int type) throws ModelException 101 { 102 getFieldImpl().setPersistenceType(type); 103 } 104 105 114 public boolean isReadSensitive () 115 { 116 return ((getPersistenceType() == DERIVED) && 117 getFieldImpl().isReadSensitive()); 118 } 119 120 130 public void setReadSensitive (boolean flag) throws ModelException 131 { 132 getFieldImpl().setReadSensitive(flag); 133 } 134 135 144 public boolean isWriteSensitive () 145 { 146 return ((getPersistenceType() == DERIVED) && 147 getFieldImpl().isWriteSensitive()); 148 } 149 150 160 public void setWriteSensitive (boolean flag) throws ModelException 161 { 162 getFieldImpl().setWriteSensitive(flag); 163 } 164 165 170 public boolean isKey () { return getFieldImpl().isKey(); } 171 172 178 public void setKey (boolean flag) throws ModelException 179 { 180 getFieldImpl().setKey(flag); 181 } 182 183 186 190 public ConcurrencyGroupElement[] getConcurrencyGroups () 191 { 192 ConcurrencyGroupElement[] groups = getDeclaringClass(). 193 getConcurrencyGroups(); 194 int i, count = ((groups != null) ? groups.length : 0); 195 ArrayList myGroups = new ArrayList (count); 196 197 for (i = 0; i < count; i++) 198 { 199 ConcurrencyGroupElement group = groups[i]; 200 201 if (group.containsField(this)) 202 myGroups.add(group); 203 } 204 205 count = myGroups.size(); 206 207 return ((ConcurrencyGroupElement[])myGroups.toArray( 208 new ConcurrencyGroupElement[count])); 209 } 210 211 214 public int getFieldNumber () 215 { 216 PersistenceFieldElement[] fields = getDeclaringClass().getFields(); 220 int i, count = ((fields != null) ? fields.length : 0); 221 222 for (i = 0; i < count; i++) 223 if (equals(fields[i])) 224 return i; 225 226 return -1; 227 } 228 229 231 232 235 public interface Impl extends PersistenceMemberElement.Impl 236 { 237 241 public int getPersistenceType (); 242 243 248 public void setPersistenceType (int type) throws ModelException; 249 250 261 public boolean isReadSensitive (); 262 263 273 public void setReadSensitive (boolean flag) throws ModelException; 274 275 286 public boolean isWriteSensitive (); 287 288 298 public void setWriteSensitive (boolean flag) throws ModelException; 299 300 305 public boolean isKey (); 306 307 313 public void setKey (boolean flag) throws ModelException; 314 } 315 } 316 | Popular Tags |