1 23 24 29 30 package com.sun.jdo.api.persistence.model.jdo.impl; 31 32 import java.beans.PropertyVetoException ; 33 34 import com.sun.jdo.api.persistence.model.ModelException; 35 import com.sun.jdo.api.persistence.model.ModelVetoException; 36 import com.sun.jdo.api.persistence.model.jdo.RelationshipElement; 37 import com.sun.jdo.spi.persistence.utility.JavaTypeHelper; 38 39 52 53 58 public class RelationshipElementImpl extends PersistenceFieldElementImpl 59 implements RelationshipElement.Impl 60 { 61 62 private int _updateAction; 63 64 65 private int _deleteAction; 66 67 68 private boolean _isPrefetch; 69 70 71 private int _lowerBound; 72 73 74 private int _upperBound; 75 76 77 private String _collectionClass; 78 79 80 private String _elementClass; 81 82 83 private String _inverseRelationshipName; 84 85 88 public RelationshipElementImpl () 89 { 90 this(null); 91 } 92 93 96 public RelationshipElementImpl (String name) 97 { 98 super(name); 99 _updateAction = RelationshipElement.NONE_ACTION; 100 _deleteAction = RelationshipElement.NONE_ACTION; 101 _isPrefetch = false; 102 _lowerBound = 0; 103 _upperBound = Integer.MAX_VALUE; 104 } 105 106 115 public int getUpdateAction () { return _updateAction; } 116 117 126 public void setUpdateAction (int action) throws ModelException 127 { 128 Integer old = new Integer (getUpdateAction()); 129 Integer newAction = new Integer (action); 130 131 try 132 { 133 fireVetoableChange(PROP_UPDATE_ACTION, old, newAction); 134 _updateAction = action; 135 firePropertyChange(PROP_UPDATE_ACTION, old, newAction); 136 } 137 catch (PropertyVetoException e) 138 { 139 throw new ModelVetoException(e); 140 } 141 } 142 143 152 public int getDeleteAction () { return _deleteAction; } 153 154 163 public void setDeleteAction (int action) throws ModelException 164 { 165 Integer old = new Integer (getDeleteAction()); 166 Integer newAction = new Integer (action); 167 168 try 169 { 170 fireVetoableChange(PROP_DELETE_ACTION, old, newAction); 171 _deleteAction = action; 172 firePropertyChange(PROP_DELETE_ACTION, old, newAction); 173 } 174 catch (PropertyVetoException e) 175 { 176 throw new ModelVetoException(e); 177 } 178 } 179 180 184 public boolean isPrefetch () { return _isPrefetch; } 185 186 191 public void setPrefetch (boolean flag) throws ModelException 192 { 193 Boolean old = JavaTypeHelper.valueOf(isPrefetch()); 194 Boolean newFlag = JavaTypeHelper.valueOf(flag); 195 196 try 197 { 198 fireVetoableChange(PROP_PREFETCH, old, newFlag); 199 _isPrefetch = flag; 200 firePropertyChange(PROP_PREFETCH, old, newFlag); 201 } 202 catch (PropertyVetoException e) 203 { 204 throw new ModelVetoException(e); 205 } 206 } 207 208 212 public int getLowerBound () { return _lowerBound; } 213 214 218 public void setLowerBound (int lowerBound) throws ModelException 219 { 220 Integer old = new Integer (getLowerBound()); 221 Integer newBound = new Integer (lowerBound); 222 223 try 224 { 225 fireVetoableChange(PROP_CARDINALITY, old, newBound); 226 _lowerBound = lowerBound; 227 firePropertyChange(PROP_CARDINALITY, old, newBound); 228 } 229 catch (PropertyVetoException e) 230 { 231 throw new ModelVetoException(e); 232 } 233 } 234 235 240 public int getUpperBound () { return _upperBound; } 241 242 247 public void setUpperBound (int upperBound) throws ModelException 248 { 249 Integer old = new Integer (getUpperBound()); 250 Integer newBound = new Integer (upperBound); 251 252 try 253 { 254 fireVetoableChange(PROP_CARDINALITY, old, newBound); 255 _upperBound = upperBound; 256 firePropertyChange(PROP_CARDINALITY, old, newBound); 257 } 258 catch (PropertyVetoException e) 259 { 260 throw new ModelVetoException(e); 261 } 262 } 263 264 268 public String getCollectionClass () { return _collectionClass; } 269 270 275 public void setCollectionClass (String collectionClass) 276 throws ModelException 277 { 278 String old = getCollectionClass(); 279 280 try 281 { 282 fireVetoableChange(PROP_COLLECTION_CLASS, old, collectionClass); 283 _collectionClass = collectionClass; 284 firePropertyChange(PROP_COLLECTION_CLASS, old, collectionClass); 285 } 286 catch (PropertyVetoException e) 287 { 288 throw new ModelVetoException(e); 289 } 290 } 291 292 297 public String getElementClass () { return _elementClass; } 298 299 305 public void setElementClass (String elementClass) throws ModelException 306 { 307 String old = getElementClass(); 308 309 try 310 { 311 fireVetoableChange(PROP_ELEMENT_CLASS, old, elementClass); 312 _elementClass = elementClass; 313 firePropertyChange(PROP_ELEMENT_CLASS, old, elementClass); 314 } 315 catch (PropertyVetoException e) 316 { 317 throw new ModelVetoException(e); 318 } 319 } 320 321 332 public String getInverseRelationshipName () 333 { 334 return _inverseRelationshipName; 335 } 336 337 347 public void changeInverseRelationship ( 348 RelationshipElement inverseRelationship) throws ModelException 349 { 350 String newName = ((inverseRelationship != null) ? 351 inverseRelationship.getName() : null); 352 String oldName = getInverseRelationshipName(); 353 354 try 355 { 356 fireVetoableChange(PROP_INVERSE_FIELD, oldName, newName); 357 _inverseRelationshipName = newName; 358 firePropertyChange(PROP_INVERSE_FIELD, oldName, newName); 359 } 360 catch (PropertyVetoException e) 361 { 362 throw new ModelVetoException(e); 363 } 364 } 365 } 366 | Popular Tags |