1 21 package oracle.toplink.essentials.internal.indirection; 23 24 import java.io.*; 25 import java.util.*; 26 import oracle.toplink.essentials.exceptions.*; 27 import oracle.toplink.essentials.internal.descriptors.*; 28 import oracle.toplink.essentials.internal.sessions.MergeManager; 29 import oracle.toplink.essentials.mappings.*; 30 import oracle.toplink.essentials.queryframework.*; 31 import oracle.toplink.essentials.internal.sessions.AbstractRecord; 32 import oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl; 33 import oracle.toplink.essentials.internal.sessions.AbstractSession; 34 35 62 public abstract class IndirectionPolicy implements Cloneable , Serializable { 63 protected DatabaseMapping mapping; 64 65 69 public IndirectionPolicy() { 70 super(); 71 } 72 73 77 public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) { 78 return this.getMapping().buildBackupCloneForPartObject(attributeValue, clone, backup, unitOfWork); 79 } 80 81 85 protected ReadObjectQuery buildCascadeQuery(MergeManager mergeManager) { 86 ReadObjectQuery cascadeQuery = new ReadObjectQuery(); 87 if (mergeManager.shouldCascadeAllParts()) { 88 cascadeQuery.cascadeAllParts(); 89 cascadeQuery.refreshIdentityMapResult(); 90 } 91 if (mergeManager.shouldCascadePrivateParts() && getForeignReferenceMapping().isPrivateOwned()) { 92 cascadeQuery.cascadePrivateParts(); 93 cascadeQuery.refreshIdentityMapResult(); 94 } 95 96 return cascadeQuery; 97 } 98 99 103 public Object clone() { 104 try { 105 return super.clone(); 106 } catch (CloneNotSupportedException e) { 107 throw new InternalError (); 108 } 109 } 110 111 118 public abstract Object cloneAttribute(Object attributeValue, Object original, Object clone, UnitOfWorkImpl unitOfWork, boolean buildDirectlyFromRow); 119 120 126 public Vector extractPrimaryKeyForReferenceObject(Object referenceObject, AbstractSession session) { 127 return this.getOneToOneMapping().extractPrimaryKeysFromRealReferenceObject(referenceObject, session); 128 } 129 130 137 public abstract AbstractRecord extractReferenceRow(Object referenceObject); 138 139 143 protected CollectionMapping getCollectionMapping() { 144 return (CollectionMapping)this.getMapping(); 145 } 146 147 151 protected ForeignReferenceMapping getForeignReferenceMapping() { 152 return (ForeignReferenceMapping)this.getMapping(); 153 } 154 155 159 public DatabaseMapping getMapping() { 160 return mapping; 161 } 162 163 167 protected ObjectReferenceMapping getOneToOneMapping() { 168 return (ObjectReferenceMapping)this.getMapping(); 169 } 170 171 175 public abstract Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session); 176 177 182 public abstract Object getRealAttributeValueFromObject(Object object); 183 184 189 public static Object getValueFromProxy(Object value) { 190 return value; 191 } 192 193 197 public void initialize() { 198 } 199 200 205 public void iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue) { 206 if (attributeValue != null) { 207 this.getMapping().iterateOnRealAttributeValue(iterator, attributeValue); 208 } 209 } 210 211 217 public abstract Object nullValueFromRow(); 218 219 223 public abstract boolean objectIsInstantiated(Object object); 224 225 229 public void setMapping(DatabaseMapping mapping) { 230 this.mapping = mapping; 231 } 232 233 238 public void setRealAttributeValueInObject(Object target, Object attributeValue) { 239 this.getMapping().setAttributeValueInObject(target, attributeValue); 240 } 241 242 247 public boolean usesIndirection() { 248 return true; 249 } 250 251 256 public boolean usesTransparentIndirection(){ 257 return false; 258 } 259 260 267 public Object validateAttributeOfInstantiatedObject(Object attributeValue) throws DescriptorException { 268 return attributeValue; 269 } 270 271 277 public void validateContainerPolicy(IntegrityChecker checker) throws DescriptorException { 278 } 280 281 287 public void validateDeclaredAttributeType(Class attributeType, IntegrityChecker checker) throws DescriptorException { 288 } 290 291 296 public void validateDeclaredAttributeTypeForCollection(Class attributeType, IntegrityChecker checker) throws DescriptorException { 297 } 299 300 306 public void validateGetMethodReturnType(Class returnType, IntegrityChecker checker) throws DescriptorException { 307 } 309 310 315 public void validateGetMethodReturnTypeForCollection(Class returnType, IntegrityChecker checker) throws DescriptorException { 316 } 318 319 325 public void validateSetMethodParameterType(Class parameterType, IntegrityChecker checker) throws DescriptorException { 326 } 328 329 334 public void validateSetMethodParameterTypeForCollection(Class parameterType, IntegrityChecker checker) throws DescriptorException { 335 } 337 338 343 public abstract Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session); 344 345 350 public abstract Object valueFromRow(Object object); 351 } 352 | Popular Tags |