1 21 package oracle.toplink.essentials.internal.indirection; 23 24 import oracle.toplink.essentials.queryframework.*; 25 import oracle.toplink.essentials.exceptions.*; 26 import oracle.toplink.essentials.internal.helper.*; 27 import oracle.toplink.essentials.internal.sessions.AbstractRecord; 28 import oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl; 29 import oracle.toplink.essentials.internal.sessions.AbstractSession; 30 31 41 public class NoIndirectionPolicy extends IndirectionPolicy { 42 43 47 public NoIndirectionPolicy() { 48 super(); 49 } 50 51 58 public Object cloneAttribute(Object attributeValue, Object original, Object clone, UnitOfWorkImpl unitOfWork, boolean buildDirectlyFromRow) { 59 if (buildDirectlyFromRow) { 62 return attributeValue; 63 } 64 boolean isExisting = unitOfWork.isObjectRegistered(clone) && (!(unitOfWork.isOriginalNewObject(original))); 65 return this.getMapping().buildCloneForPartObject(attributeValue, original, clone, unitOfWork, isExisting); 66 } 67 68 74 protected boolean collectionTypeIsValid(Class collectionType) { 75 return getCollectionMapping().getContainerPolicy().isValidContainerType(collectionType); 76 } 77 78 85 public AbstractRecord extractReferenceRow(Object referenceObject) { 86 return null; 87 } 88 89 93 public Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session) { 94 return unitOfWorkIndirectionObject; 97 } 98 99 104 public Object getRealAttributeValueFromObject(Object object) { 105 return object; 106 } 107 108 114 public Object nullValueFromRow() { 115 return null; 116 } 117 118 122 public boolean objectIsInstantiated(Object object) { 123 return true; 124 } 125 126 131 protected boolean typeIsValid(Class attributeType) { 132 return attributeType != ClassConstants.ValueHolderInterface_Class; 133 } 134 135 140 public boolean usesIndirection() { 141 return false; 142 } 143 144 151 public void validateDeclaredAttributeType(Class attributeType, IntegrityChecker checker) throws DescriptorException { 152 super.validateDeclaredAttributeType(attributeType, checker); 153 if (!this.typeIsValid(attributeType)) { 154 checker.handleError(DescriptorException.attributeAndMappingWithoutIndirectionMismatch(this.getMapping())); 155 } 156 } 157 158 165 public void validateDeclaredAttributeTypeForCollection(Class attributeType, IntegrityChecker checker) throws DescriptorException { 166 super.validateDeclaredAttributeTypeForCollection(attributeType, checker); 167 if (!this.collectionTypeIsValid(attributeType)) { 168 checker.handleError(DescriptorException.attributeTypeNotValid(this.getCollectionMapping())); 169 } 170 } 171 172 179 public void validateGetMethodReturnType(Class returnType, IntegrityChecker checker) throws DescriptorException { 180 super.validateGetMethodReturnType(returnType, checker); 181 if (!this.typeIsValid(returnType)) { 182 checker.handleError(DescriptorException.returnAndMappingWithoutIndirectionMismatch(this.getMapping())); 183 } 184 } 185 186 193 public void validateGetMethodReturnTypeForCollection(Class returnType, IntegrityChecker checker) throws DescriptorException { 194 super.validateGetMethodReturnTypeForCollection(returnType, checker); 195 if (!this.collectionTypeIsValid(returnType)) { 196 checker.handleError(DescriptorException.getMethodReturnTypeNotValid(getCollectionMapping())); 197 } 198 } 199 200 207 public void validateSetMethodParameterType(Class parameterType, IntegrityChecker checker) throws DescriptorException { 208 super.validateSetMethodParameterType(parameterType, checker); 209 if (!this.typeIsValid(parameterType)) { 210 checker.handleError(DescriptorException.parameterAndMappingWithoutIndirectionMismatch(this.getMapping())); 211 } 212 } 213 214 221 public void validateSetMethodParameterTypeForCollection(Class parameterType, IntegrityChecker checker) throws DescriptorException { 222 super.validateSetMethodParameterTypeForCollection(parameterType, checker); 223 if (!this.collectionTypeIsValid(parameterType)) { 224 checker.handleError(DescriptorException.setMethodParameterTypeNotValid(getCollectionMapping())); 225 } 226 } 227 228 234 public Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session) { 235 return session.executeQuery(query, row); 236 } 237 238 244 public Object valueFromRow(Object object) { 245 return object; 246 } 247 } 248 | Popular Tags |