cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r479153 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne: map/compiled/ property/
Date Sat, 25 Nov 2006 17:46:48 GMT
Author: aadamchik
Date: Sat Nov 25 09:46:46 2006
New Revision: 479153

URL: http://svn.apache.org/viewvc?view=rev&rev=479153
Log:
CAY-701: "property" package refactoring
(more property package class names refactoring)

Added:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseArcProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseToManyProperty.java
      - copied, changed from r479150, incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseToOneProperty.java
      - copied, changed from r479150, incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java
Removed:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java
Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/compiled/EnhancedPojoSingleObjectArcProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ListProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PersistentObjectProperty.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/property/ToManyProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ToOneProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ValueHolderProperty.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/compiled/EnhancedPojoSingleObjectArcProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/compiled/EnhancedPojoSingleObjectArcProperty.java?view=diff&rev=479153&r1=479152&r2=479153
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/compiled/EnhancedPojoSingleObjectArcProperty.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/compiled/EnhancedPojoSingleObjectArcProperty.java
Sat Nov 25 09:46:46 2006
@@ -20,7 +20,7 @@
 
 import org.apache.cayenne.Fault;
 import org.apache.cayenne.Persistent;
-import org.apache.cayenne.property.AbstractSingleObjectArcProperty;
+import org.apache.cayenne.property.BaseToOneProperty;
 import org.apache.cayenne.property.Accessor;
 import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.property.PropertyException;
@@ -33,7 +33,7 @@
  * @since 3.0
  * @author Andrus Adamchik
  */
-class EnhancedPojoSingleObjectArcProperty extends AbstractSingleObjectArcProperty {
+class EnhancedPojoSingleObjectArcProperty extends BaseToOneProperty {
 
     protected Accessor faultResolvedFlagAccessor;
 

Added: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseArcProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseArcProperty.java?view=auto&rev=479153
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseArcProperty.java
(added)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseArcProperty.java
Sat Nov 25 09:46:46 2006
@@ -0,0 +1,121 @@
+/*****************************************************************
+ *   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.map.ObjRelationship;
+
+/**
+ * A base implementation of the {@link ArcProperty}.
+ * 
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+public abstract class BaseArcProperty extends BaseProperty implements ArcProperty {
+
+    protected String complimentaryReverseArcName;
+    protected ClassDescriptor targetDescriptor;
+    protected ObjRelationship relationship;
+
+    public BaseArcProperty(ClassDescriptor owner, ClassDescriptor targetDescriptor,
+            Accessor accessor, String reverseName) {
+
+        super(owner, accessor);
+
+        this.targetDescriptor = targetDescriptor;
+        this.complimentaryReverseArcName = reverseName;
+        this.relationship = (ObjRelationship) owner
+                .getEntity()
+                .getRelationship(getName());
+    }
+
+    public abstract boolean visit(PropertyVisitor visitor);
+
+    public abstract boolean isFault(Object source);
+
+    public ObjRelationship getRelationship() {
+        return relationship;
+    }
+
+    public ArcProperty getComplimentaryReverseArc() {
+        return (ArcProperty) targetDescriptor.getProperty(complimentaryReverseArcName);
+    }
+
+    public ClassDescriptor getTargetDescriptor() {
+        return targetDescriptor;
+    }
+
+    /**
+     * A convenience method to set the reverse arc used by subclasses.
+     */
+    protected void setReverse(
+            final Object source,
+            final Object oldTarget,
+            final Object newTarget) {
+
+        ArcProperty reverseArc = getComplimentaryReverseArc();
+
+        if (reverseArc != null) {
+
+            // unset old
+            if (oldTarget != null) {
+
+                PropertyVisitor visitor = new PropertyVisitor() {
+
+                    public boolean visitToMany(ToManyProperty property) {
+                        property.removeTarget(oldTarget, source, false);
+                        return false;
+                    }
+
+                    public boolean visitToOne(ToOneProperty property) {
+                        property.setTarget(oldTarget, null, false);
+                        return false;
+                    }
+
+                    public boolean visitAttribute(AttributeProperty property) {
+                        return false;
+                    }
+                };
+
+                reverseArc.visit(visitor);
+            }
+
+            // set new reverse
+            if (newTarget != null) {
+                PropertyVisitor visitor = new PropertyVisitor() {
+
+                    public boolean visitToMany(ToManyProperty property) {
+                        property.addTarget(newTarget, source, false);
+                        return false;
+                    }
+
+                    public boolean visitToOne(ToOneProperty property) {
+                        property.setTarget(newTarget, source, false);
+                        return false;
+                    }
+
+                    public boolean visitAttribute(AttributeProperty property) {
+                        return false;
+                    }
+                };
+
+                reverseArc.visit(visitor);
+            }
+        }
+    }
+}

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseProperty.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=479153&r1=479152&r2=479153
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseProperty.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseProperty.java
Sat Nov 25 09:46:46 2006
@@ -23,7 +23,7 @@
  * An abstract property descriptor that delegates property access to an {@link Accessor}.
  * Used as a superclass for other implementations.
  * 
- * @since 1.2
+ * @since 3.0
  * @author Andrus Adamchik
  */
 public abstract class BaseProperty implements Property {

Copied: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseToManyProperty.java
(from r479150, incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java)
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseToManyProperty.java?view=diff&rev=479153&p1=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java&r1=479150&p2=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseToManyProperty.java&r2=479153
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseToManyProperty.java
Sat Nov 25 09:46:46 2006
@@ -30,11 +30,11 @@
  * @since 1.2
  * @author Andrus Adamchik
  */
-public abstract class AbstractCollectionProperty extends AbstractSingleObjectArcProperty
-        implements ToManyProperty {
+public abstract class BaseToManyProperty extends BaseArcProperty implements
+        ToManyProperty {
 
-    public AbstractCollectionProperty(ClassDescriptor owner,
-            ClassDescriptor targetDescriptor, Accessor accessor, String reverseName) {
+    public BaseToManyProperty(ClassDescriptor owner, ClassDescriptor targetDescriptor,
+            Accessor accessor, String reverseName) {
         super(owner, targetDescriptor, accessor, reverseName);
     }
 

Copied: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseToOneProperty.java
(from r479150, 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/BaseToOneProperty.java?view=diff&rev=479153&p1=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java&r1=479150&p2=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/BaseToOneProperty.java&r2=479153
==============================================================================
--- 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/BaseToOneProperty.java
Sat Nov 25 09:46:46 2006
@@ -19,33 +19,17 @@
 
 package org.apache.cayenne.property;
 
-import org.apache.cayenne.map.ObjRelationship;
-
 /**
- * A base superclass of SingleObjectArcProperty implementors.
+ * A convenience base superclass for {@link ToOneProperty} implementors.
  * 
- * @since 1.2
+ * @since 3.0
  * @author Andrus Adamchik
  */
-public abstract class AbstractSingleObjectArcProperty extends BaseProperty implements
-        ToOneProperty {
-
-    protected String complimentaryReverseArcName;
-    protected ClassDescriptor targetDescriptor;
-    protected ObjRelationship relationship;
-
-    public AbstractSingleObjectArcProperty(ClassDescriptor owner,
-            ClassDescriptor targetDescriptor, Accessor accessor, String reverseName) {
-        super(owner, accessor);
-        this.targetDescriptor = targetDescriptor;
-        this.complimentaryReverseArcName = reverseName;
-        this.relationship = (ObjRelationship) owner
-                .getEntity()
-                .getRelationship(getName());
-    }
+public abstract class BaseToOneProperty extends BaseArcProperty implements ToOneProperty
{
 
-    public ObjRelationship getRelationship() {
-        return relationship;
+    public BaseToOneProperty(ClassDescriptor owner, ClassDescriptor targetDescriptor,
+            Accessor accessor, String reverseName) {
+        super(owner, targetDescriptor, accessor, reverseName);
     }
 
     public void setTarget(Object source, Object target, boolean setReverse) {
@@ -64,73 +48,7 @@
         writeProperty(source, oldTarget, target);
     }
 
-    protected void setReverse(
-            final Object source,
-            final Object oldTarget,
-            final Object newTarget) {
-
-        ArcProperty reverseArc = getComplimentaryReverseArc();
-
-        if (reverseArc != null) {
-
-            // unset old
-            if (oldTarget != null) {
-
-                PropertyVisitor visitor = new PropertyVisitor() {
-
-                    public boolean visitToMany(ToManyProperty property) {
-                        property.removeTarget(oldTarget, source, false);
-                        return false;
-                    }
-
-                    public boolean visitToOne(ToOneProperty property) {
-                        property.setTarget(oldTarget, null, false);
-                        return false;
-                    }
-
-                    public boolean visitAttribute(AttributeProperty property) {
-                        return false;
-                    }
-                };
-
-                reverseArc.visit(visitor);
-            }
-
-            // set new reverse
-            if (newTarget != null) {
-                PropertyVisitor visitor = new PropertyVisitor() {
-
-                    public boolean visitToMany(ToManyProperty property) {
-                        property.addTarget(newTarget, source, false);
-                        return false;
-                    }
-
-                    public boolean visitToOne(ToOneProperty property) {
-                        property.setTarget(newTarget, source, false);
-                        return false;
-                    }
-
-                    public boolean visitAttribute(AttributeProperty property) {
-                        return false;
-                    }
-                };
-
-                reverseArc.visit(visitor);
-            }
-        }
-    }
-
     public boolean visit(PropertyVisitor visitor) {
         return visitor.visitToOne(this);
     }
-
-    public ArcProperty getComplimentaryReverseArc() {
-        return (ArcProperty) targetDescriptor.getProperty(complimentaryReverseArcName);
-    }
-
-    public ClassDescriptor getTargetDescriptor() {
-        return targetDescriptor;
-    }
-
-    public abstract boolean isFault(Object source);
 }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ListProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ListProperty.java?view=diff&rev=479153&r1=479152&r2=479153
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ListProperty.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ListProperty.java
Sat Nov 25 09:46:46 2006
@@ -30,7 +30,7 @@
  * @since 1.2
  * @author Andrus Adamchik
  */
-public class ListProperty extends AbstractCollectionProperty {
+public class ListProperty extends BaseToManyProperty {
 
     public ListProperty(ClassDescriptor owner, ClassDescriptor targetDescriptor,
             Accessor accessor, String reverseName) {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PersistentObjectProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PersistentObjectProperty.java?view=diff&rev=479153&r1=479152&r2=479153
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PersistentObjectProperty.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PersistentObjectProperty.java
Sat Nov 25 09:46:46 2006
@@ -28,7 +28,7 @@
  * @since 1.2
  * @author Andrus Adamchik
  */
-public class PersistentObjectProperty extends AbstractSingleObjectArcProperty {
+public class PersistentObjectProperty extends BaseToOneProperty {
 
     public PersistentObjectProperty(ClassDescriptor owner,
             ClassDescriptor targetDescriptor, Accessor accessor, String reverseName) {

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=479153&r1=479152&r2=479153
==============================================================================
--- 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
Sat Nov 25 09:46:46 2006
@@ -23,7 +23,7 @@
  * A visitor for various types of properties in a ClassDescriptor. Helpful in defining
  * operations that should be performed differently on differernt properties.
  * 
- * @since 1.2
+ * @since 3.0
  * @author Andrus Adamchik
  */
 public interface PropertyVisitor {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ToManyProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ToManyProperty.java?view=diff&rev=479153&r1=479152&r2=479153
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ToManyProperty.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ToManyProperty.java
Sat Nov 25 09:46:46 2006
@@ -23,7 +23,7 @@
 /**
  * A property representing a collection of objects.
  * 
- * @since 1.2
+ * @since 3.0
  * @author Andrus Adamchik
  */
 public interface ToManyProperty extends ArcProperty {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ToOneProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ToOneProperty.java?view=diff&rev=479153&r1=479152&r2=479153
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ToOneProperty.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ToOneProperty.java
Sat Nov 25 09:46:46 2006
@@ -22,7 +22,7 @@
 /**
  * An ArcProperty that points to a single graph node.
  * 
- * @since 1.2
+ * @since 3.0
  * @author Andrus Adamchik
  */
 public interface ToOneProperty extends ArcProperty {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ValueHolderProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ValueHolderProperty.java?view=diff&rev=479153&r1=479152&r2=479153
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ValueHolderProperty.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ValueHolderProperty.java
Sat Nov 25 09:46:46 2006
@@ -31,7 +31,7 @@
  * @since 1.2
  * @author Andrus Adamchik
  */
-public class ValueHolderProperty extends AbstractSingleObjectArcProperty {
+public class ValueHolderProperty extends BaseToOneProperty {
 
     public ValueHolderProperty(ClassDescriptor owner, ClassDescriptor targetDescriptor,
             Accessor accessor, String reverseName) {



Mime
View raw message