You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2006/11/05 22:35:03 UTC
svn commit: r471537 - in
/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src:
main/java/org/apache/cayenne/ main/java/org/apache/cayenne/access/
main/java/org/apache/cayenne/map/ main/java/org/apache/cayenne/property/
main/java/org/apache/cayenne/uti...
Author: aadamchik
Date: Sun Nov 5 13:35:02 2006
New Revision: 471537
URL: http://svn.apache.org/viewvc?view=rev&rev=471537
Log:
CAY-701: property" package refactoring
(changing property visitor to take AttributeProperty instead of just Property; renamed SimpleProperty to BaseProperty)
Added:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseProperty.java
- copied, changed from r471509, incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleProperty.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleAttributeProperty.java
- copied, changed from r471509, incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BasePropertyTst.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/MockBaseProperty.java
Removed:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleProperty.java
Modified:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneContextGraphAction.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/ObjectContextDeleteAction.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityDescriptor.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/DeepMergeOperation.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/ObjectDetachOperation.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BaseClassDescriptorTst.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/FieldAccessorTst.java
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneContextGraphAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneContextGraphAction.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneContextGraphAction.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneContextGraphAction.java Sun Nov 5 13:35:02 2006
@@ -20,8 +20,8 @@
package org.apache.cayenne;
import org.apache.cayenne.property.ArcProperty;
+import org.apache.cayenne.property.AttributeProperty;
import org.apache.cayenne.property.CollectionProperty;
-import org.apache.cayenne.property.Property;
import org.apache.cayenne.property.PropertyVisitor;
import org.apache.cayenne.property.SingleObjectArcProperty;
import org.apache.cayenne.util.ObjectContextGraphAction;
@@ -130,7 +130,7 @@
return false;
}
- public boolean visitProperty(Property property) {
+ public boolean visitAttributeProperty(AttributeProperty property) {
return false;
}
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/ObjectContextDeleteAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/ObjectContextDeleteAction.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/ObjectContextDeleteAction.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/ObjectContextDeleteAction.java Sun Nov 5 13:35:02 2006
@@ -28,6 +28,7 @@
import org.apache.cayenne.map.ObjEntity;
import org.apache.cayenne.map.ObjRelationship;
import org.apache.cayenne.property.ArcProperty;
+import org.apache.cayenne.property.AttributeProperty;
import org.apache.cayenne.property.ClassDescriptor;
import org.apache.cayenne.property.CollectionProperty;
import org.apache.cayenne.property.Property;
@@ -118,7 +119,7 @@
return true;
}
- public boolean visitProperty(Property property) {
+ public boolean visitAttributeProperty(AttributeProperty property) {
return true;
}
});
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java Sun Nov 5 13:35:02 2006
@@ -62,9 +62,9 @@
import org.apache.cayenne.map.ObjAttribute;
import org.apache.cayenne.map.ObjEntity;
import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.property.AttributeProperty;
import org.apache.cayenne.property.ClassDescriptor;
import org.apache.cayenne.property.CollectionProperty;
-import org.apache.cayenne.property.Property;
import org.apache.cayenne.property.PropertyVisitor;
import org.apache.cayenne.property.SingleObjectArcProperty;
import org.apache.cayenne.query.NamedQuery;
@@ -893,7 +893,7 @@
return true;
}
- public boolean visitProperty(Property property) {
+ public boolean visitAttributeProperty(AttributeProperty property) {
return true;
}
});
@@ -1587,7 +1587,7 @@
lazyInitParentDomainName));
}
}
-
+
public void prepareForAccess(Persistent object, String property, boolean lazyFaulting) {
try {
super.prepareForAccess(object, property, lazyFaulting);
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java Sun Nov 5 13:35:02 2006
@@ -31,7 +31,6 @@
import org.apache.cayenne.property.AttributeProperty;
import org.apache.cayenne.property.ClassDescriptor;
import org.apache.cayenne.property.CollectionProperty;
-import org.apache.cayenne.property.Property;
import org.apache.cayenne.property.PropertyVisitor;
import org.apache.cayenne.property.SingleObjectArcProperty;
import org.apache.cayenne.util.Util;
@@ -85,8 +84,8 @@
descriptor.visitProperties(new PropertyVisitor() {
- public boolean visitProperty(Property property) {
- ObjAttribute attr = ((AttributeProperty) property).getAttribute();
+ public boolean visitAttributeProperty(AttributeProperty property) {
+ ObjAttribute attr = property.getAttribute();
String dbAttrPath = attr.getDbAttributePath();
Object value = snapshot.get(dbAttrPath);
@@ -135,10 +134,8 @@
descriptor.visitProperties(new PropertyVisitor() {
- public boolean visitProperty(Property property) {
- String dbAttrPath = ((AttributeProperty) property)
- .getAttribute()
- .getDbAttributePath();
+ public boolean visitAttributeProperty(AttributeProperty property) {
+ String dbAttrPath = property.getAttribute().getDbAttributePath();
// supports merging of partial snapshots...
// check for null is cheaper than double lookup
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java Sun Nov 5 13:35:02 2006
@@ -17,7 +17,6 @@
* under the License.
****************************************************************/
-
package org.apache.cayenne.access;
import java.util.ArrayList;
@@ -37,6 +36,7 @@
import org.apache.cayenne.map.EntityResolver;
import org.apache.cayenne.map.ObjEntity;
import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.property.AttributeProperty;
import org.apache.cayenne.property.ClassDescriptor;
import org.apache.cayenne.property.CollectionProperty;
import org.apache.cayenne.property.Property;
@@ -88,7 +88,7 @@
classDescriptor.visitProperties(new PropertyVisitor() {
- public boolean visitProperty(Property property) {
+ public boolean visitAttributeProperty(AttributeProperty property) {
snapshot.put(property.getName(), property.readProperty(object));
return true;
}
@@ -264,7 +264,8 @@
getClassDescriptor().visitProperties(new PropertyVisitor() {
- public boolean visitProperty(Property property) {
+ public boolean visitAttributeProperty(AttributeProperty property) {
+
Object oldValue = snapshot.get(property.getName());
Object newValue = property.readProperty(object);
@@ -324,8 +325,8 @@
final Persistent object = (Persistent) objectStore.getNodeNoSync(nodeId);
getClassDescriptor().visitProperties(new PropertyVisitor() {
- public boolean visitProperty(Property property) {
-
+ public boolean visitAttributeProperty(AttributeProperty property) {
+
Object newValue = property.readProperty(object);
// no baseline to compare
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java Sun Nov 5 13:35:02 2006
@@ -47,9 +47,9 @@
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.ObjEntity;
import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.AttributeProperty;
import org.apache.cayenne.property.ClassDescriptor;
import org.apache.cayenne.property.CollectionProperty;
-import org.apache.cayenne.property.Property;
import org.apache.cayenne.property.PropertyVisitor;
import org.apache.cayenne.property.SingleObjectArcProperty;
import org.apache.cayenne.query.ObjectIdQuery;
@@ -819,7 +819,7 @@
return true;
}
- public boolean visitProperty(Property property) {
+ public boolean visitAttributeProperty(AttributeProperty property) {
return true;
}
});
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityDescriptor.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityDescriptor.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityDescriptor.java Sun Nov 5 13:35:02 2006
@@ -35,7 +35,7 @@
import org.apache.cayenne.property.Property;
import org.apache.cayenne.property.PropertyAccessException;
import org.apache.cayenne.property.Accessor;
-import org.apache.cayenne.property.SimplePersistentProperty;
+import org.apache.cayenne.property.SimpleAttributeProperty;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
@@ -159,7 +159,7 @@
Class propertyType = attribute.getJavaClass();
Accessor accessor = makeAccessor(attribute.getName(), propertyType);
- allDescriptors.put(attribute.getName(), new SimplePersistentProperty(
+ allDescriptors.put(attribute.getName(), new SimpleAttributeProperty(
this,
accessor,
attribute));
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java Sun Nov 5 13:35:02 2006
@@ -27,7 +27,7 @@
* @since 1.2
* @author Andrus Adamchik
*/
-public abstract class AbstractSingleObjectArcProperty extends SimpleProperty implements
+public abstract class AbstractSingleObjectArcProperty extends BaseProperty implements
SingleObjectArcProperty {
protected String complimentaryReverseArcName;
@@ -88,8 +88,8 @@
property.setTarget(oldTarget, null, false);
return false;
}
-
- public boolean visitProperty(Property property) {
+
+ public boolean visitAttributeProperty(AttributeProperty property) {
return false;
}
};
@@ -111,7 +111,7 @@
return false;
}
- public boolean visitProperty(Property property) {
+ public boolean visitAttributeProperty(AttributeProperty property) {
return false;
}
};
Copied: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseProperty.java (from r471509, incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleProperty.java)
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseProperty.java?view=diff&rev=471537&p1=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleProperty.java&r1=471509&p2=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseProperty.java&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleProperty.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseProperty.java Sun Nov 5 13:35:02 2006
@@ -20,13 +20,13 @@
package org.apache.cayenne.property;
/**
- * A property descriptor that provides access to a simple object property, delegating
- * property read/write operations to an accessor.
+ * An abstract property descriptor that delegates property access to an {@link Accessor}.
+ * Used as a superclass for other implementations.
*
* @since 1.2
* @author Andrus Adamchik
*/
-public class SimpleProperty implements Property {
+public abstract class BaseProperty implements Property {
protected ClassDescriptor owner;
protected Accessor accessor;
@@ -34,7 +34,7 @@
// name is derived from accessor, cached here for performance
final String name;
- public SimpleProperty(ClassDescriptor owner, Accessor accessor) {
+ public BaseProperty(ClassDescriptor owner, Accessor accessor) {
if (accessor == null) {
throw new IllegalArgumentException("Null accessor");
@@ -58,9 +58,7 @@
return name;
}
- public boolean visit(PropertyVisitor visitor) {
- return visitor.visitProperty(this);
- }
+ public abstract boolean visit(PropertyVisitor visitor);
/**
* Does nothing.
@@ -70,8 +68,7 @@
}
public void shallowMerge(Object from, Object to) throws PropertyAccessException {
- writePropertyDirectly(to, accessor.getValue(to), accessor
- .getValue(from));
+ writePropertyDirectly(to, accessor.getValue(to), accessor.getValue(from));
}
public Object readPropertyDirectly(Object object) throws PropertyAccessException {
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java Sun Nov 5 13:35:02 2006
@@ -28,8 +28,7 @@
*/
public interface PropertyVisitor {
- // TODO: andrus, 10/11/2006 - replace this with visitAttributeProperty()
- boolean visitProperty(Property property);
+ boolean visitAttributeProperty(AttributeProperty property);
boolean visitSingleObjectArc(SingleObjectArcProperty property);
Copied: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleAttributeProperty.java (from r471509, incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java)
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleAttributeProperty.java?view=diff&rev=471537&p1=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java&r1=471509&p2=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleAttributeProperty.java&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimpleAttributeProperty.java Sun Nov 5 13:35:02 2006
@@ -23,17 +23,23 @@
import org.apache.cayenne.map.ObjAttribute;
/**
+ * A descriptor of an "attribute" persistent property.
+ *
* @since 3.0
* @author Andrus Adamchik
*/
-public class SimplePersistentProperty extends SimpleProperty implements AttributeProperty {
+public class SimpleAttributeProperty extends BaseProperty implements AttributeProperty {
private ObjAttribute attribute;
- public SimplePersistentProperty(ClassDescriptor owner, Accessor accessor,
+ public SimpleAttributeProperty(ClassDescriptor owner, Accessor accessor,
ObjAttribute attribute) {
super(owner, accessor);
this.attribute = attribute;
+ }
+
+ public boolean visit(PropertyVisitor visitor) {
+ return visitor.visitAttributeProperty(this);
}
public ObjAttribute getAttribute() {
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/DeepMergeOperation.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/DeepMergeOperation.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/DeepMergeOperation.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/DeepMergeOperation.java Sun Nov 5 13:35:02 2006
@@ -29,9 +29,9 @@
import org.apache.cayenne.ObjectContext;
import org.apache.cayenne.ObjectId;
import org.apache.cayenne.Persistent;
+import org.apache.cayenne.property.AttributeProperty;
import org.apache.cayenne.property.ClassDescriptor;
import org.apache.cayenne.property.CollectionProperty;
-import org.apache.cayenne.property.Property;
import org.apache.cayenne.property.PropertyVisitor;
import org.apache.cayenne.property.SingleObjectArcProperty;
@@ -120,10 +120,9 @@
return true;
}
- public boolean visitProperty(Property property) {
+ public boolean visitAttributeProperty(AttributeProperty property) {
return true;
}
-
});
return target;
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/ObjectDetachOperation.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/ObjectDetachOperation.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/ObjectDetachOperation.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/util/ObjectDetachOperation.java Sun Nov 5 13:35:02 2006
@@ -29,6 +29,7 @@
import org.apache.cayenne.ObjectId;
import org.apache.cayenne.Persistent;
import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.property.AttributeProperty;
import org.apache.cayenne.property.ClassDescriptor;
import org.apache.cayenne.property.CollectionProperty;
import org.apache.cayenne.property.Property;
@@ -153,13 +154,12 @@
return true;
}
- public boolean visitProperty(Property property) {
+ public boolean visitAttributeProperty(AttributeProperty property) {
Property targetProperty = targetDescriptor
.getProperty(property.getName());
targetProperty.writeProperty(target, null, property.readProperty(source));
return true;
}
-
});
return target;
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BaseClassDescriptorTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BaseClassDescriptorTst.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BaseClassDescriptorTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BaseClassDescriptorTst.java Sun Nov 5 13:35:02 2006
@@ -58,7 +58,7 @@
BaseClassDescriptor d1 = new MockBaseClassDescriptor();
FieldAccessor accessor = new FieldAccessor(TestBean.class, "string", String.class);
- SimpleProperty property = new SimpleProperty(d1, accessor);
+ BaseProperty property = new MockBaseProperty(d1, accessor);
d1.declaredProperties.put(property.getName(), property);
Added: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BasePropertyTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BasePropertyTst.java?view=auto&rev=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BasePropertyTst.java (added)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/BasePropertyTst.java Sun Nov 5 13:35:02 2006
@@ -0,0 +1,47 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+package org.apache.cayenne.property;
+
+import org.apache.cayenne.unit.util.TestBean;
+
+import junit.framework.TestCase;
+
+public class BasePropertyTst extends TestCase {
+
+ public void testShallowMerge() {
+ ClassDescriptor d = new MockClassDescriptor();
+ BaseProperty property = new BaseProperty(d, new FieldAccessor(
+ TestBean.class,
+ "string",
+ String.class)) {
+
+ public boolean visit(PropertyVisitor visitor) {
+ return false;
+ }
+ };
+
+ TestBean from = new TestBean();
+ from.setString("123");
+
+ TestBean to = new TestBean();
+
+ property.shallowMerge(from, to);
+ assertEquals("123", to.getString());
+ }
+}
Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/FieldAccessorTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/FieldAccessorTst.java?view=diff&rev=471537&r1=471536&r2=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/FieldAccessorTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/FieldAccessorTst.java Sun Nov 5 13:35:02 2006
@@ -26,88 +26,61 @@
public class FieldAccessorTst extends TestCase {
public void testConstructor() {
- ClassDescriptor d = new MockClassDescriptor();
- SimpleProperty property = new SimpleProperty(d, new FieldAccessor(
- TestBean.class,
- "string",
- String.class));
-
- assertEquals("string", property.getName());
+ FieldAccessor accessor = new FieldAccessor(TestBean.class, "string", String.class);
+ assertEquals("string", accessor.getName());
}
public void testGet() {
- ClassDescriptor d = new MockClassDescriptor();
- SimpleProperty property = new SimpleProperty(d, new FieldAccessor(
- TestBean.class,
- "string",
- String.class));
+ FieldAccessor accessor = new FieldAccessor(TestBean.class, "string", String.class);
TestBean object = new TestBean();
object.setString("abc");
-
- assertEquals("abc", property.readPropertyDirectly(object));
+ assertEquals("abc", accessor.getValue(object));
}
- public void testWriteValue() {
- ClassDescriptor d = new MockClassDescriptor();
+ public void testSetValue() {
TestFields object = new TestFields();
// string
- new SimpleProperty(d,
- new FieldAccessor(TestFields.class, "stringField", String.class))
- .writePropertyDirectly(object, null, "aaa");
+ new FieldAccessor(TestFields.class, "stringField", String.class).setValue(
+ object,
+ "aaa");
assertEquals("aaa", object.stringField);
// primitive array
byte[] bytes = new byte[] {
1, 2, 3
};
- new SimpleProperty(d, new FieldAccessor(
- TestFields.class,
- "byteArrayField",
- byte[].class)).writePropertyDirectly(object, null, bytes);
+ new FieldAccessor(TestFields.class, "byteArrayField", byte[].class).setValue(
+ object,
+ bytes);
assertSame(bytes, object.byteArrayField);
// object array
String[] strings = new String[] {
"a", "b"
};
- new SimpleProperty(d, new FieldAccessor(
- TestFields.class,
- "stringArrayField",
- String[].class)).writePropertyDirectly(object, null, strings);
+ new FieldAccessor(TestFields.class, "stringArrayField", String[].class).setValue(
+ object,
+ strings);
assertSame(strings, object.stringArrayField);
}
- public void testWriteValuePrimitive() {
- ClassDescriptor d = new MockClassDescriptor();
+ public void testSetValuePrimitive() {
TestFields object = new TestFields();
// primitive int .. write non-null
- new SimpleProperty(d, new FieldAccessor(TestFields.class, "intField", Integer.TYPE))
- .writePropertyDirectly(object, null, new Integer(6));
+ new FieldAccessor(TestFields.class, "intField", Integer.TYPE).setValue(
+ object,
+ new Integer(6));
assertEquals(6, object.intField);
// primitive int .. write null
object.intField = 55;
- new SimpleProperty(d, new FieldAccessor(TestFields.class, "intField", Integer.TYPE))
- .writePropertyDirectly(object, null, null);
+ new FieldAccessor(TestFields.class, "intField", Integer.TYPE).setValue(
+ object,
+ null);
assertEquals(0, object.intField);
- }
-
- public void testCopy() {
- ClassDescriptor d = new MockClassDescriptor();
- SimpleProperty property = new SimpleProperty(d, new FieldAccessor(
- TestBean.class,
- "string",
- String.class));
- TestBean from = new TestBean();
- from.setString("123");
-
- TestBean to = new TestBean();
-
- property.shallowMerge(from, to);
- assertEquals("123", to.getString());
}
}
Added: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/MockBaseProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/MockBaseProperty.java?view=auto&rev=471537
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/MockBaseProperty.java (added)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/property/MockBaseProperty.java Sun Nov 5 13:35:02 2006
@@ -0,0 +1,30 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+package org.apache.cayenne.property;
+
+public class MockBaseProperty extends BaseProperty {
+
+ public MockBaseProperty(ClassDescriptor owner, Accessor accessor) {
+ super(owner, accessor);
+ }
+
+ public boolean visit(PropertyVisitor visitor) {
+ return true;
+ }
+}