db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r180130 - in /incubator/jdo/trunk: core20/src/java/org/apache/jdo/impl/model/java/ core20/src/java/org/apache/jdo/impl/model/java/reflection/ core20/src/java/org/apache/jdo/impl/model/jdo/ core20/src/java/org/apache/jdo/impl/model/jdo/caching/ core20/src/java/org/apache/jdo/impl/model/jdo/util/ core20/src/java/org/apache/jdo/model/java/ core20/src/java/org/apache/jdo/model/jdo/ query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/ query20/src/java/org/apache/jdo/impl/jdoql/tree/ runtime20/src/java/org/apache/jdo/impl/model/java/runtime/ runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/
Date Sun, 05 Jun 2005 18:45:35 GMT
Author: mbo
Date: Sun Jun  5 11:45:34 2005
New Revision: 180130

URL: http://svn.apache.org/viewcvs?rev=180130&view=rev
Log:
Adds support for JDOProperties to JDOModel:
- Add a new interface JDOProperty to the jdo model. It inherits from JDOField 
and specifies method getAssociatedJDOField.
- Add dynamic and caching implementation of JDOProperty.
- Add dynamic and caching implementation of JDOProperty used for a JDOProperty
with an associated JDOField. This implementation delegates the getter methods
to the associated JDOField and throws an exception for the setter methods.
- Add a new convenience method isProperty to JDOField.
- JavaProperty now inherits from JavaField.
- Fix a bug in the caching version of JDOClass when removing fields.
- Remove methods setName and setDeclaringClass from JDOMember. Instead the
JDOMember constructor takes name and declaringClass as arguments. This way the
properties name and declaringClass cannot be changed for an existing member.
JDOField, JDOProperty and JDOClass implementation classes have new constructors
taking name and declaringClass.
- Removed method getJDOField from JavaField. 

Added:
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOAssociatedPropertyImplDynamic.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOPropertyImplDynamic.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOAssociatedPropertyImplCaching.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOPropertyImplCaching.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Member.jpg   (with props)
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Model-jpg   (with props)
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOProperty.java
Removed:
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel.jpg
Modified:
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/BaseReflectionJavaField.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/JavaModel-MemberImpl.jpg
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaField.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaType.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/Bundle.properties
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOClassImplDynamic.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOFieldImplDynamic.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOMemberImpl.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelImplDynamic.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOClassImplCaching.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOFieldImplCaching.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOModelImplCaching.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/util/PrintSupport.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaField.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModel-API.jpg
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModel.mdl
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaProperty.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOClass.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOField.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOMember.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel.mdl
    incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/Optimizer.g
    incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/TypeSupport.java
    incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FieldAccessExpr.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaField.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaType.java

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/BaseReflectionJavaField.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/BaseReflectionJavaField.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/BaseReflectionJavaField.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/BaseReflectionJavaField.java Sun Jun  5 11:45:34 2005
@@ -125,21 +125,6 @@
         return type;
     }
     
-    /**
-     * Returns the corresponding JDOField instance, if the JDOModel
-     * provides any JDO metadata for the field represented by this
-     * JavaField. If there is no corresponding JDOField representation, the
-     * method returns <code>null</code>.
-     * <p>
-     * This implementation always returns <code>null</code>.
-     * @return the corresponding JDOField instance (if available);
-     * <code>null</code> otherwise.
-     */
-    public JDOField getJDOField()
-    {
-        return null;
-    }
-
     // ===== Methods not specified in JavaField =====
 
     /** 

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/JavaModel-MemberImpl.jpg
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/JavaModel-MemberImpl.jpg?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
Binary files - no diff available.

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaField.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaField.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaField.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaField.java Sun Jun  5 11:45:34 2005
@@ -37,9 +37,6 @@
 public class ReflectionJavaField
     extends BaseReflectionJavaField
 {
-    /** The corresponding JDO metadata. */
-    protected JDOField jdoField;
-
     /** I18N support */
     private final static I18NHelper msg =  
         I18NHelper.getInstance("org.apache.jdo.impl.model.java.Bundle"); //NOI18N
@@ -57,18 +54,14 @@
     
     /** 
      * Constructor for fields having JDO metadata.
-     * @param jdoField the JDO field metadata.
+     * @param fieldName the name of the field.
      * @param type the field type.
      * @param declaringClass the JavaType of the class that declares the field.
      */
-    public ReflectionJavaField(JDOField jdoField, JavaType type, JavaType declaringClass)
+    public ReflectionJavaField(String fieldName, JavaType type, 
+                               JavaType declaringClass)
     {
-        super((jdoField == null) ? null : jdoField.getName(), declaringClass);
-        if (jdoField == null)
-            throw new ModelFatalException(msg.msg(
-                "ERR_InvalidNullFieldInstance", //NOI18N
-                "ReflectionJavaField.<init>")); //NOI18N
-        this.jdoField = jdoField;
+        super(fieldName, declaringClass);
         this.type = type;
     }
     
@@ -82,22 +75,6 @@
             type = getJavaTypeForClass(getField().getType());
         }
         return type;
-    }
-
-    /**
-     * Returns the JDOField instance if this JavaField represents a
-     * managed field of a persistence capable class. The method returns
-     * <code>null</code>, if this JavaField does not represent a managed
-     * field. 
-     * <p>
-     * The method throws a {@link org.apache.jdo.model.ModelFatalException},
-     * if there is a problem accessing the JDO meta data for this JavaField. 
-     * @return the JDOField instance if this JavaField represents a managed
-     * field; <code>null</code> otherwise.
-     */
-    public JDOField getJDOField()
-    {
-        return jdoField;
     }
 
     // ===== Methods not defined in JavaField =====

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaType.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaType.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaType.java Sun Jun  5 11:45:34 2005
@@ -257,9 +257,10 @@
             JDOClass jdoClass = getJDOClass();
             if (jdoClass != null) {
                 // pc class => look for JDOField first
-                JDOField jdoField = jdoClass.getDeclaredField(fieldName);
-                if (jdoField != null) {
-                    javaField = newJavaFieldInstance(jdoField, null);
+                if (jdoClass.getDeclaredField(fieldName) != null) {
+                    // Use JDO metadata and create a JavaField skeleton to
+                    // avoid unnecessary reflection access.
+                    javaField = newJavaFieldInstance(fieldName, null);
                     declaredJavaFields.put(fieldName, javaField);
                 }
             }
@@ -338,9 +339,9 @@
      * instance.
      * @return a new JavaField instance.
      */
-    protected JavaField newJavaFieldInstance(JDOField jdoField, JavaType type) 
+    protected JavaField newJavaFieldInstance(String fieldName, JavaType type) 
     {
-        return new ReflectionJavaField(jdoField, type, this);
+        return new ReflectionJavaField(fieldName, type, this);
     }
     
     /**

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/Bundle.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/Bundle.properties?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/Bundle.properties (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/Bundle.properties Sun Jun  5 11:45:34 2005
@@ -42,10 +42,12 @@
 EXC_CannotRemoveJDOField=Cannot remove JDOField after after field number calculation.
 EXC_CannotResolveObjectIdClass=Cannot resolve objectid-class ''{0}'' of persistence-capable class ''{1}''.
 EXC_CannotResolvePCSuperClass=Cannot resolve persistence-capable-superclass ''{0}'' of persistence-capable class ''{1}''.
+EXC_ExistingJDOProperty=Cannot create JDOField called ''{0}''. There is an existing JDOProperty with the same name.
+EXC_ExistingJDOField=Cannot create JDOProperty called ''{0}''. There is an existing JDOField with the same name.
+EXC_ExistingJDOAssociatedProperty=Cannot create JDOProperty called ''{0}''. There is an existing JDOProperty with the same name, but a different associated JDOField.
 #NOI18N
 ERR_InvalidInheritedFieldNumber=JDOClassImpl.getFieldList inheritedFields.size() != inheritedFieldsCount.
 
-
 #
 # JDOFieldImpl
 #
@@ -66,10 +68,11 @@
 EXC_CannotResolveValueType=Cannot resolve value-type ''{0}'' of map field ''{1}'' in class ''{2}''.
 
 #
-# RuntimeJDOModelFactory
-#
-EXC_NoJDOImplHelper=Cannot get JDOImplHelper instance.
-EXC_InvalidJDOModelKey=Invalid key for runtime JDOModel lookup: expected ''java.lang.ClassLoader'' instance, found ''{0}'' instance.
+# JDOAssociatedPropertyImpl
+# 
+EXC_InvalidNullAssociatedJDOField=Associated JDOField instance must not be null.
+EXC_CannotModifyJDOProperty=Cannot modify JDOProperty instance with associated JDOField.
+EXC_InvalidJavaFieldForJDOProperty=Invalid JavaField ''{0}'' for JDOProperty, expected a JavaProperty instance.
 
 #
 # JDOParser

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOAssociatedPropertyImplDynamic.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOAssociatedPropertyImplDynamic.java?rev=180130&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOAssociatedPropertyImplDynamic.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOAssociatedPropertyImplDynamic.java Sun Jun  5 11:45:34 2005
@@ -0,0 +1,276 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.jdo.impl.model.jdo;
+
+import org.apache.jdo.model.ModelException;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.model.java.JavaProperty;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOArray;
+import org.apache.jdo.model.jdo.JDOClass;
+import org.apache.jdo.model.jdo.JDOCollection;
+import org.apache.jdo.model.jdo.JDOField;
+import org.apache.jdo.model.jdo.JDOMap;
+import org.apache.jdo.model.jdo.JDOProperty;
+import org.apache.jdo.model.jdo.JDOReference;
+import org.apache.jdo.model.jdo.JDORelationship;
+import org.apache.jdo.util.I18NHelper;
+
+/**
+ * An instance of this class represents the JDO metadata of a managed property
+ * of a persistence capable class. This JDOProperty implementation is used for
+ * persistent properties with an associated JDOField. All JDOField getter
+ * methods delegate to the associated JDOField, except methods getName,
+ * getDeclaringClass and getJavaField. All JDOField setter method throw a
+ * ModelException to avoid changing the associated JDOField through this
+ * JDOProperty instance. This dynamic implementation only stores values
+ * explicitly set by setter method. 
+ *
+ * @author Michael Bouschen
+ * @since 2.0
+ * @version 2.0
+ */
+public class JDOAssociatedPropertyImplDynamic
+    extends JDOMemberImpl 
+    implements JDOProperty
+{
+    /** The associated JDOField instance. */
+    private final JDOField associatedJDOField;
+
+    /** The corresponding JavaProperty instance. */
+    protected JavaProperty javaProperty;
+
+   /** I18N support. */
+    protected final static I18NHelper msg =  
+        I18NHelper.getInstance(JDOAssociatedPropertyImplDynamic.class);
+    
+    /** Constrcutor. */
+    protected JDOAssociatedPropertyImplDynamic(
+        String name, JDOClass declaringClass, JDOField associatedJDOField)
+        throws ModelException {
+        super(name, declaringClass);
+        this.associatedJDOField = associatedJDOField;
+        if (associatedJDOField == null) {
+            throw new ModelException(
+                msg.msg("EXC_InvalidNullAssociatedJDOField")); //NOI18N
+        }
+    }
+    
+    // ===== Methods specified in JDOField =====
+
+    /**
+     * Get the corresponding JavaProperty representation for this JDOProperty.
+     * @return the corresponding JavaProperty representation
+     */
+    public JavaField getJavaField() {
+        if (javaProperty != null) {
+            // return javaProperty, if explicitly set by the setter
+            return javaProperty;
+        }
+        
+        // not set => calculate
+        JavaType javaType = getDeclaringClass().getJavaType();
+        return javaType.getJavaProperty(getName());
+    }
+
+    /**
+     * Sets the corresponding JavaProperty representation for this JDOProperty.
+     * @param javaField the corresponding JavaProperty representation
+     * @throws ModelException if impossible
+     */
+    public void setJavaField(JavaField javaField) throws ModelException {
+        
+        if (javaField instanceof JavaProperty) {
+            this.javaProperty = (JavaProperty)javaField;
+        }
+        else {
+            throw new ModelException(msg.msg(
+                "EXC_InvalidJavaFieldForJDOProperty", javaField)); //NOI18N
+        }
+    }
+
+    /**
+     * Convenience method to check whether this field represents a property.
+     * @return <code>true</code> if this field represents a property; 
+     * <code>false</code> otherwise
+     */
+    public boolean isProperty() {
+        return true;
+    }
+
+    // ===== Methods specified in JDOField delegate to associatedJDOField =====
+
+    /** Deletegate to associatedJDOField. */
+    public int getPersistenceModifier() {
+        return associatedJDOField.getPersistenceModifier();
+    }
+
+    /** Throws ModelException. */
+    public void setPersistenceModifier (int persistenceModifier)
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+    
+    /** Deletegate to associatedJDOField. */
+    public boolean isPrimaryKey() {
+        return associatedJDOField.isPrimaryKey();
+    }
+    
+    /** Throws ModelException. */
+    public void setPrimaryKey(boolean primaryKey)
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+    
+    /** Deletegate to associatedJDOField. */
+    public int getNullValueTreatment() {
+        return associatedJDOField.getNullValueTreatment();
+    }
+    
+    /** Throws ModelException. */
+    public void setNullValueTreatment(int nullValueTreament)
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+    
+    /** Deletegate to associatedJDOField. */
+    public boolean isDefaultFetchGroup() {
+        return associatedJDOField.isDefaultFetchGroup();
+    }
+
+    /** Throws ModelException. */
+    public void setDefaultFetchGroup(boolean defaultFetchGroup)
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+
+    /** Deletegate to associatedJDOField. */
+    public boolean isEmbedded() {
+        return associatedJDOField.isEmbedded();
+    }
+    
+    /** Throws ModelException. */
+    public void setEmbedded(boolean embedded)
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+
+    /** Deletegate to associatedJDOField. */
+    public boolean isSerializable() {
+        return associatedJDOField.isSerializable();
+    }
+
+    /** Throws ModelException. */
+    public void setSerializable(boolean serializable)
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+
+    /** Deletegate to associatedJDOField. */
+    public JDORelationship getRelationship() {
+        return associatedJDOField.getRelationship();
+    }
+
+    /** Throws ModelException. */
+    public void setRelationship(JDORelationship relationship)
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+
+    /** Throws ModelException. */
+    public JDOReference createJDOReference()
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+
+    /** Throws ModelException. */
+    public JDOCollection createJDOCollection()
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+
+    /** Throws ModelException. */
+    public JDOArray createJDOArray()
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+    
+    /** Throws ModelException. */
+    public JDOMap createJDOMap()
+        throws ModelException {
+        throw new ModelException(
+            msg.msg("EXC_CannotModifyJDOProperty")); //NOI18N
+    }
+    
+    /** Deletegate to associatedJDOField. */
+    public boolean isPersistent() {
+        return associatedJDOField.isPersistent();
+    }
+    
+    /** Deletegate to associatedJDOField. */
+    public boolean isTransactional() {
+        return associatedJDOField.isTransactional();
+    }
+
+    /** Deletegate to associatedJDOField. */
+    public boolean isManaged() {
+        return associatedJDOField.isManaged();
+    }
+
+    /** Deletegate to associatedJDOField. */
+    public boolean isRelationship() {
+        return associatedJDOField.isRelationship();
+    }
+
+    /** Deletegate to associatedJDOField. */
+    public JavaType getType() {
+        return associatedJDOField.getType();
+    }
+
+    /** Deletegate to associatedJDOField. */
+    public int getFieldNumber() {
+        return associatedJDOField.getFieldNumber();
+    }
+
+    /** Deletegate to associatedJDOField. */
+    public int getRelativeFieldNumber() {
+        return associatedJDOField.getRelativeFieldNumber();
+    }
+
+    // ===== Methods specified in JDOProperty =====
+
+    /** 
+     * Return the JDOField instance associated with this property, if
+     * available. If there is no JDOField instance associated, then the method
+     * returns <code>null</code>.
+     * @return associated JDOField instance or <code>null</code> if not
+     * available.
+     */
+    public JDOField getAssociatedJDOField() {
+        return associatedJDOField;
+    }
+}

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOClassImplDynamic.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOClassImplDynamic.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOClassImplDynamic.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOClassImplDynamic.java Sun Jun  5 11:45:34 2005
@@ -30,6 +30,7 @@
 import org.apache.jdo.model.jdo.JDOMember;
 import org.apache.jdo.model.jdo.JDOModel;
 import org.apache.jdo.model.jdo.JDOPackage;
+import org.apache.jdo.model.jdo.JDOProperty;
 
 import org.apache.jdo.util.I18NHelper;
 import org.apache.jdo.util.StringHelper;
@@ -88,6 +89,12 @@
      */
     private Map declaredFields = new HashMap();
 
+    /** 
+     * Map of properties having associated JDOField instances. Key is the
+     * unqualified field name, value is the JDOField instance. 
+     */
+    private Map associatedProperties = new HashMap();
+
     /**
      * Relationship JDOClass<->JDOMember.
      * Map of inner classes declared by this JDOClass. 
@@ -106,6 +113,16 @@
     protected final static I18NHelper msg =  
         I18NHelper.getInstance(JDOClassImplDynamic.class);
 
+    /** Constructor. */
+    protected JDOClassImplDynamic(String name) {
+        super(name, null);
+    }
+
+    /** Constructor for inner classes. */
+    protected JDOClassImplDynamic(String name, JDOClass declaringClass) {
+        super(name, declaringClass);
+    }
+
     /** 
      * Get the short name of this JDOClass. The short name defaults to the
      * unqualified class name, if not explicitly set by method
@@ -355,14 +372,35 @@
      * @exception ModelException if impossible
      */
     public void removeDeclaredMember(JDOMember member) throws ModelException {
+        if (member == null) {
+            throw new ModelException(
+                msg.msg("EXC_InvalidMember", "null")); //NOI18N
+        }
+        String name = member.getName();
+        if (member instanceof JDOProperty) {
+            // Check for property with associated field
+            if (associatedProperties.containsValue(member)) {
+                associatedProperties.remove(name);
+            }
+            else {
+                declaredFields.remove(name); 
+            }
+        }
         if (member instanceof JDOField) {
-            declaredFields.remove(member.getName());
+            // JDOField which is not a JDOProperty
+            declaredFields.remove(name);
+            // There might be a property with the field to be removed as
+            // associated JDOField => remove the property too.
+            JDOProperty prop = getAssociatedProperty((JDOField) member);
+            if (prop != null) {
+                removeDeclaredMember(prop);
+            }
         }
         else if (member instanceof JDOClass) {
-            declaredClasses.remove(member.getName());
+            // inner class
+            declaredClasses.remove(name);
         }
         else {
-            String name = (member == null) ? "null" : member.getName(); //NOI18N
             throw new ModelException(
                 msg.msg("EXC_InvalidMember", name)); //NOI18N
         }
@@ -462,7 +500,7 @@
      * This method returns a JDOField instance for the field with the specified 
      * name. If this JDOClass already declares such a field, the existing 
      * JDOField instance is returned. Otherwise, it creates a new JDOField 
-     * instance, sets its declaringClass and returns the new instance.
+     * instance, sets its declaring JDOClass and returns the new instance.
      * <P> 
      * Note, if the field numbers for the managed fields of this JDOClass are 
      * calculated, this methid will fail to create a new JDOField. Any new field
@@ -472,30 +510,91 @@
      */
     public JDOField createJDOField(String name) throws ModelException {
         // check whether there is a field with the specified name
-        JDOField field = (JDOField)declaredFields.get(name);
+        JDOField field = getDeclaredField(name);
         if (field == null) {
-            field = newJDOFieldInstance();
-            field.setName(name);
-            field.setDeclaringClass(this);
+            field = newJDOFieldInstance(name);
             declaredFields.put(name, field);
         }
+        else if (field instanceof JDOProperty) {
+            throw new ModelException(
+                msg.msg("EXC_ExistingJDOProperty", name)); //NOI18N
+        }
         return field;
     }
     
     /**
+     * This method returns a JDOProperty instance for the property with the
+     * specified name. If this JDOClass already declares such a property, the
+     * existing JDOProperty instance is returned. Otherwise, it creates a new
+     * JDOProperty instance, sets its declaring JDOClass and returns the new
+     * instance.
+     * @param name the name of the property
+     * @return a JDOProperty instance for the specified property
+     * @exception ModelException if impossible
+     */
+    public JDOProperty createJDOProperty(String name) throws ModelException {
+        // check whether there is a field or property with the specified name
+        JDOProperty property = null;
+        JDOField field = getDeclaredField(name);
+        if (field == null) {
+            property = newJDOPropertyInstance(name);
+            declaredFields.put(name, property);
+        } 
+        else if (field instanceof JDOProperty) {
+            property = (JDOProperty) field;
+        }
+        else {
+            throw new ModelException(
+                msg.msg("EXC_ExistingJDOField", name)); //NOI18N
+        }
+        return property;
+    }
+
+    /**
+     * This method returns a JDOProperty instance for the property with the
+     * specified name and associated field. If this JDOClass already declares
+     * such a property the existing JDOProperty instance is returned. If it
+     * declares a property with the specified name but different associated
+     * field, then a ModelException is thrown. If there is no such property,
+     * the method creates a new JDOProperty instance, sets its declaring
+     * JDOClass and associated field and returns the new instance. 
+     * @param name the name of the property
+     * @param associatedField the associated JDOField 
+     * @return a JDOProperty instance for the specified property
+     * @exception ModelException if impossible
+     */
+    public JDOProperty createJDOProperty(String name, 
+                                         JDOField associatedJDOField)
+        throws ModelException
+    {
+        JDOProperty property = (JDOProperty) associatedProperties.get(name);
+        if (property == null) {
+            property = newJDOPropertyInstance(name, associatedJDOField);
+            associatedProperties.put(name, property);
+        } 
+        else {
+            if (property.getAssociatedJDOField() != associatedJDOField) {
+                throw new ModelException(
+                    msg.msg("EXC_ExistingJDOAssociatedProperty", //NOI18N
+                            name, associatedJDOField)); 
+            }
+        }
+        return property;
+    }
+    
+    /**
      * This method returns a JDOClass instance representing an inner class of 
      * this JDOClass If this JDOClass already declares such an inner class, 
      * the existing JDOClass instance is returned. Otherwise, it creates a new 
-     * JDOClass instance, sets its declaringClass and returns the new instance.
+     * JDOClass instance, sets its declaring JDOClass and returns the new
+     * instance.
      * @param name the name of the inner class
      * @exception ModelException if impossible
      */
     public JDOClass createJDOClass(String name) throws ModelException {
         JDOClass innerClass = (JDOClass)declaredClasses.get(name);
         if (innerClass == null) {
-            innerClass = newJDOClassInstance();
-            innerClass.setName(name);
-            innerClass.setDeclaringClass(this);
+            innerClass = newJDOClassInstance(name);
             declaredClasses.put(name, innerClass);
         }
         return innerClass;
@@ -943,18 +1042,72 @@
     }
 
     /** 
-     * Returns JDOField metadata for a particular declared field specified by 
-     * field name. Please note, the method does not  return inherited fields.
-     * The field name must not be qualified by a class name. The method returns
-     * <code>null</code> if the field name does not denote a field declared by 
-     * JDOClass.
-     * @param fieldName the unqualified name of field for which field metadata 
+     * Returns JDOField metadata for a particular declared field for the
+     * specified name. Please note, the method does not return inherited
+     * fields. The field name must not be qualified by a class name. The
+     * method returns <code>null</code> if the field name does not denote a
+     * field declared by JDOClass.
+     * @param name the unqualified name of field for which field metadata 
      * is needed.
      * @return JDOField metadata for the field or <code>null</code>
      * if there is no such field declared by this JDOClass.
      */
-    public JDOField getDeclaredField(String fieldName) {
-        return (JDOField)declaredFields.get(fieldName);
+    public JDOField getDeclaredField(String name) {
+        return (JDOField) declaredFields.get(name);
+    }
+
+    /**
+     * Returns JDOProperty metadata for a property with the specified name
+     * having an associated JDOField. The method returns <code>null</code>, if
+     * the name does not denote a property with an associated JDOField of this
+     * JDOClass. Please note, the method does not check for properties without
+     * an associated JDOField. It will return <code>null</code> if there is
+     * a property with the specified name, but this property does not have an
+     * associated JDOField.
+     * @param name the name of property with an associated JDOField for which
+     * metadata is needed.
+     * @return JDOProperty metadata for the property with an associated
+     * JDOField or <code>null</code> if there is no such property.
+     */
+    public JDOProperty getAssociatedProperty(String name) {
+        // first check the associated properties from this class
+        JDOProperty prop = (JDOProperty) associatedProperties.get(name);
+        if (prop != null) {
+            return prop;
+        }
+        
+        // not in this class => check superclass
+        JDOClass superclass = getPersistenceCapableSuperclass();
+        if (superclass != null) {
+            return superclass.getAssociatedProperty(name);
+        }
+        
+        // not found => return null
+        return null;
+    }
+
+    /**
+     * Returns JDOProperty metadata for a property having the specified
+     * JDOField as associated JDOField. The method returns <code>null</code>,
+     * if this JDOClass does not have a property with the specified JDOField
+     * as associated JDOField.
+     * @param JDOField the assoaciated JDOField of the property for which
+     * metadata is needed.
+     * @return JDOProperty metadata for the property the specified JDOField as
+     * associated JDOField or <code>null</code> if there is no such property.
+     */
+    public JDOProperty getAssociatedProperty(JDOField field) {
+        Collection props = associatedProperties.values();
+        for (Iterator i = props.iterator(); i.hasNext();) {
+            JDOProperty prop = (JDOProperty)i.next();
+            if (prop.getAssociatedJDOField() == field) {
+                // found property => return 
+                return prop;
+            }
+        }
+
+        // not found => return null
+        return null;
     }
 
     /**
@@ -1022,9 +1175,9 @@
             return superclass.getPersistenceCapableRootClass();
         }
     }
-    
+
     //========= Internal helper methods ==========
-    
+
     /**
      * Returns the JDOField definition for the specified field. 
      * The method expects unqualified field names. The method 
@@ -1038,10 +1191,11 @@
     protected JDOField getFieldInternal(String fieldName) {
         // first check the declared fields
         JDOField field = (JDOField)declaredFields.get(fieldName);
-        if (field != null)
+        if (field != null) {
             return field;
+        }
         
-        // not in actual class => check superclass
+        // not in this class => check superclass
         JDOClassImplDynamic superclass = 
             (JDOClassImplDynamic)getPersistenceCapableSuperclass();
         if (superclass != null) {
@@ -1049,21 +1203,37 @@
         }
         
         // not found => return null
-        return null;    
+        return null;
     }
     
     /**
      * Returns a new instance of the JDOClass implementation class.
      */
-    protected JDOClass newJDOClassInstance() {
-        return new JDOClassImplDynamic();
+    protected JDOClass newJDOClassInstance(String name) {
+        return new JDOClassImplDynamic(name, this);
     }
 
     /**
      * Returns a new instance of the JDOField implementation class.
      */
-    protected JDOField newJDOFieldInstance() {
-        return new JDOFieldImplDynamic();
+    protected JDOField newJDOFieldInstance(String name) {
+        return new JDOFieldImplDynamic(name, this);
+    }
+
+    /**
+     * Returns a new instance of the JDOProperty implementation class.
+     */
+    protected JDOProperty newJDOPropertyInstance(String name) {
+        return new JDOPropertyImplDynamic(name, this);
+    }
+    
+    /**
+     * Returns a new instance of the JDOProperty implementation class.
+     */
+    protected JDOProperty newJDOPropertyInstance(
+        String name, JDOField associatedJDOField) throws ModelException {
+        return new JDOAssociatedPropertyImplDynamic(
+            name, this, associatedJDOField);
     }
     
 }

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOFieldImplDynamic.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOFieldImplDynamic.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOFieldImplDynamic.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOFieldImplDynamic.java Sun Jun  5 11:45:34 2005
@@ -25,6 +25,7 @@
 import org.apache.jdo.model.java.JavaField;
 import org.apache.jdo.model.java.JavaType;
 import org.apache.jdo.model.jdo.JDOArray;
+import org.apache.jdo.model.jdo.JDOClass;
 import org.apache.jdo.model.jdo.JDOCollection;
 import org.apache.jdo.model.jdo.JDOField;
 import org.apache.jdo.model.jdo.JDOMap;
@@ -54,7 +55,7 @@
  *
  * @author Michael Bouschen
  * @since 1.1
- * @version 1.1
+ * @version 2.0
  */
 public class JDOFieldImplDynamic
     extends JDOMemberImpl 
@@ -79,7 +80,7 @@
     protected Boolean embedded;
 
     /** Property javaField. No default. */
-    private transient JavaField javaField;
+    protected transient JavaField javaField;
 
     /** Property serializable. Defaults to <code>false</code>. */
     private boolean serializable = false;
@@ -91,6 +92,11 @@
     protected final static I18NHelper msg =  
         I18NHelper.getInstance(JDOFieldImplDynamic.class);
 
+    /** Constructor. */
+    protected JDOFieldImplDynamic(String name, JDOClass declaringClass) {
+        super(name, declaringClass);
+    }
+
     /**
      * Get the persistence modifier of this JDOField.
      * @return the persistence modifier, one of 
@@ -248,7 +254,7 @@
     }
     
     /**
-     * Get the corresponding Java field representation for this JDOField.
+     * Get the corresponding JavaField representation for this JDOField.
      * @return the corresponding Java field representation
      */
     public JavaField getJavaField() {
@@ -261,12 +267,12 @@
         JavaType javaType = getDeclaringClass().getJavaType();
         return javaType.getJavaField(getName());
     }
-    
+
     /**
      * Sets the corresponding Java field representation for this JDOField.
      * @param javaField the corresponding Java field representation
      */
-    public void setJavaField (JavaField javaField) {
+    public void setJavaField (JavaField javaField) throws ModelException {
         this.javaField = javaField;
     }
     
@@ -467,6 +473,15 @@
     }
 
     /**
+     * Convenience method to check whether this field represents a property.
+     * @return <code>true</code> if this field represents a property; 
+     * <code>false</code> otherwise
+     */
+    public boolean isProperty() {
+        return false;
+    }
+
+    /**
      * Get the JavaType representation of the type of the field.
      * @return JavaType representation of the type of this field.
      */
@@ -502,7 +517,7 @@
 
     /**
      * Creates and returns a new JDOReference instance. 
-     * This method automatically sets this JDOField as the declarinmg field of 
+     * This method automatically sets this JDOField as the declaring field of 
      * the returned instance.
      * @return a new JDOReference instance bound to this JDOField
      */
@@ -515,7 +530,7 @@
 
     /**
      * Creates and returns a new JDOCollection instance. 
-     * This method automatically this JDOField as the declarinmg field of 
+     * This method automatically this JDOField as the declaring field of 
      * the returned instance.
      * @return a new JDOCollection instance bound to this JDOField
      */
@@ -528,7 +543,7 @@
 
     /**
      * Creates and returns a new JDOArray instance. 
-     * This method automatically this JDOField as the declarinmg field of 
+     * This method automatically this JDOField as the declaring field of 
      * the returned instance.
      * @return a new JDOArray instance bound to this JDOField
      */
@@ -541,7 +556,7 @@
 
     /**
      * Creates and returns a new JDOMap instance. 
-     * This method automatically this JDOField as the declarinmg field of 
+     * This method automatically this JDOField as the declaring field of 
      * the returned instance.
      * @return a new JDOMap instance bound to this JDOField
      */

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOMemberImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOMemberImpl.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOMemberImpl.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOMemberImpl.java Sun Jun  5 11:45:34 2005
@@ -16,8 +16,6 @@
 
 package org.apache.jdo.impl.model.jdo;
 
-import java.text.Collator;
-
 import org.apache.jdo.model.jdo.JDOClass;
 import org.apache.jdo.model.jdo.JDOMember;
 
@@ -37,6 +35,13 @@
     /** Relationship JDOClass<->JDOMember. */
     private JDOClass declaringClass;
 
+    /** Constructor. */
+    protected JDOMemberImpl(String name, JDOClass declaringClass)
+    {
+        this.name = name;
+        this.declaringClass = declaringClass;
+    }
+
     /**
      * Returns the name of this JDOMember.
      * @return the name
@@ -46,15 +51,6 @@
         return name;
     }
 
-    /**
-     * Sets the name of this JDOMember.
-     * @param name the name
-     */
-    public void setName(String name)
-    {
-        this.name = name;
-    }
-
     /** 
      * Get the declaring class of this JDOMember.
      * @return the class that owns this JDOMember, or <code>null</code>
@@ -63,15 +59,6 @@
     public JDOClass getDeclaringClass()
     {
         return declaringClass;
-    }
-
-    /** 
-     * Set the declaring class of this JDOMember.
-     * @param declaringClass the declaring class of this member element
-     */
-    public void setDeclaringClass(JDOClass declaringClass)
-    {
-        this.declaringClass = declaringClass;
     }
 
     //================= redefinition of java.lang.Object methods ================

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelImplDynamic.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelImplDynamic.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelImplDynamic.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelImplDynamic.java Sun Jun  5 11:45:34 2005
@@ -228,8 +228,7 @@
             if (logger.isDebugEnabled())
                 logger.debug("JDOModel.createJDOClass: " + //NOI18N
                              "create new JDOClass instance " + className); //NOI18N
-            jdoClass = newJDOClassInstance();
-            jdoClass.setName(className);
+            jdoClass = newJDOClassInstance(className);
             jdoClass.setDeclaringModel(this);
             jdoClasses.put(className, jdoClass);
             // create the corresponding JDOPackage
@@ -451,8 +450,8 @@
     //========= Internal helper methods ==========
     
     /** Returns a new instance of the JDOClass implementation class. */
-    protected JDOClass newJDOClassInstance() {
-        return new JDOClassImplDynamic();
+    protected JDOClass newJDOClassInstance(String name) {
+        return new JDOClassImplDynamic(name);
     }
 
     /**

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOPropertyImplDynamic.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOPropertyImplDynamic.java?rev=180130&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOPropertyImplDynamic.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOPropertyImplDynamic.java Sun Jun  5 11:45:34 2005
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.jdo.impl.model.jdo;
+
+import org.apache.jdo.model.ModelException;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.model.java.JavaProperty;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOClass;
+import org.apache.jdo.model.jdo.JDOField;
+import org.apache.jdo.model.jdo.JDOProperty;
+
+/**
+ * An instance of this class represents the JDO metadata of a managed property
+ * of a persistence capable class. This dynamic implementation only
+ * stores values explicitly set by setter method. 
+ *
+ * @author Michael Bouschen
+ * @since 2.0
+ * @version 2.0
+ */
+public class JDOPropertyImplDynamic
+    extends JDOFieldImplDynamic
+    implements JDOProperty
+{
+    /** Constructor. */
+    protected JDOPropertyImplDynamic(String name, JDOClass declaringClass) {
+        super(name, declaringClass);
+    }
+
+    // ===== methods specified in JDOField =====
+
+    /**
+     * Get the corresponding JavaField representation for this JDOProperty.
+     * @return the corresponding JavaProperty representation
+     */
+    public JavaField getJavaField() {
+        if (javaField != null) {
+            // return java field, if explicitly set by the setter
+            return javaField;
+        }
+        
+        // not set => calculate
+        JavaType javaType = getDeclaringClass().getJavaType();
+        return javaType.getJavaProperty(getName());
+    }
+
+    /**
+     * Sets the corresponding JavaProperty representation for this JDOProperty.
+     * @param javaField the corresponding JavaProperty representation
+     * @throws ModelException if impossible
+     */
+    public void setJavaField(JavaField javaField) throws ModelException {
+        if (javaField instanceof JavaProperty) {
+            this.javaField = javaField;
+        }
+        else {
+            throw new ModelException(msg.msg(
+                "EXC_InvalidJavaFieldForJDOProperty", javaField)); //NOI18N
+        }
+    }
+
+    /**
+     * Convenience method to check whether this field represents a property.
+     * @return <code>true</code> if this field represents a property; 
+     * <code>false</code> otherwise
+     */
+    public boolean isProperty() {
+        return true;
+    }
+
+    // ===== methods specified in JDOProperty =====
+
+    /** 
+     * Return the JDOField instance associated with this property, if
+     * available. If there is no JDOField instance associated, then the method
+     * returns <code>null</code>.
+     * <p>
+     * This implementation always retruns <code>null</code>.
+     * @return associated JDOField instance or <code>null</code> if not
+     * available.
+     */
+    public JDOField getAssociatedJDOField() {
+        return null;
+    }
+}

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOAssociatedPropertyImplCaching.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOAssociatedPropertyImplCaching.java?rev=180130&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOAssociatedPropertyImplCaching.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOAssociatedPropertyImplCaching.java Sun Jun  5 11:45:34 2005
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.jdo.impl.model.jdo.caching;
+
+import org.apache.jdo.model.ModelException;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.model.java.JavaProperty;
+import org.apache.jdo.model.jdo.JDOClass;
+import org.apache.jdo.model.jdo.JDOField;
+import org.apache.jdo.impl.model.jdo.JDOAssociatedPropertyImplDynamic;
+
+/**
+ * An instance of this class represents the JDO metadata of a managed property
+ * of a persistence capable class. This JDOProperty implementation is used for
+ * persistent properties with an associated JDOField. All JDOField getter
+ * methods delegate to the associated JDOField, except methods getName,
+ * getDeclaringClass and getJavaField. All JDOField setter method throw a
+ * ModelException to avoid changing the associated JDOField through this
+ * JDOProperty instance. This caching implementation caches any calculated
+ * value to avoid re-calculating it if it is requested again. 
+ *
+ * @author Michael Bouschen
+ * @since 2.0
+ * @version 2.0
+ */
+public class JDOAssociatedPropertyImplCaching
+    extends JDOAssociatedPropertyImplDynamic
+{
+    /** Constructor. */
+    protected JDOAssociatedPropertyImplCaching(
+        String name, JDOClass declaringClass, JDOField associatedJDOField)
+        throws ModelException {
+        super(name, declaringClass, associatedJDOField);
+    }
+    
+    // ===== Methods specified in JDOField =====
+
+    /**
+     * Get the corresponding JavaProperty representation for this JDOProperty.
+     * @return the corresponding JavaProperty representation
+     */
+    public JavaField getJavaField() {
+        if (javaProperty == null) {
+            javaProperty = (JavaProperty)super.getJavaField();
+        }
+        return javaProperty;
+    }
+}

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOClassImplCaching.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOClassImplCaching.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOClassImplCaching.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOClassImplCaching.java Sun Jun  5 11:45:34 2005
@@ -22,6 +22,7 @@
 import org.apache.jdo.model.jdo.JDOField;
 import org.apache.jdo.model.jdo.JDOIdentityType;
 import org.apache.jdo.model.jdo.JDOMember;
+import org.apache.jdo.model.jdo.JDOProperty;
 
 import org.apache.jdo.impl.model.jdo.JDOClassImplDynamic;
 
@@ -94,7 +95,17 @@
     /** Flag indicating wthere field numbers are calculated already. */
     private boolean fieldNumbersCalculated = false;
 
-     /** 
+    /** Constructor. */
+    protected JDOClassImplCaching(String name) {
+        super(name);
+    }
+
+    /** Constructor for inner classes. */
+    protected JDOClassImplCaching(String name, JDOClass declaringClass) {
+        super(name, declaringClass);
+    }
+
+    /** 
      * Get the short name of this JDOClass. The short name defaults to the
      * unqualified class name, if not explicitly set by method
      * {@link #setShortName(String shortName)}.
@@ -179,6 +190,15 @@
             throw new ModelException(
                 msg.msg("EXC_CannotRemoveJDOField")); //NOI18N
         }
+
+        // nullify JDOField arrays storing calculated field lists
+        declaredManagedFields = null;
+        managedFields = null;
+        persistentFields = null;
+        primaryKeyFields = null;
+        persistentRelationshipFields = null;
+        defaultFetchGroupFields = null;
+
         super.removeDeclaredMember(member);
     }
 
@@ -443,14 +463,30 @@
     /**
      * Returns a new instance of the JDOClass implementation class.
      */
-    protected JDOClass newJDOClassInstance() {
-        return new JDOClassImplCaching();
+    protected JDOClass newJDOClassInstance(String name) {
+        return new JDOClassImplCaching(name, this);
     }
 
     /**
      * Returns a new instance of the JDOField implementation class.
      */
-    protected JDOField newJDOFieldInstance() {
-        return new JDOFieldImplCaching();
+    protected JDOField newJDOFieldInstance(String name) {
+        return new JDOFieldImplCaching(name, this);
+    }
+
+    /**
+     * Returns a new instance of the JDOProperty implementation class.
+     */
+    protected JDOProperty newJDOPropertyInstance(String name) {
+        return new JDOPropertyImplCaching(name, this);
+    }
+
+    /**
+     * Returns a new instance of the JDOProperty implementation class.
+     */
+    protected JDOProperty newJDOPropertyInstance(
+        String name, JDOField associatedJDOField) throws ModelException {
+        return new JDOAssociatedPropertyImplCaching(
+            name, this, associatedJDOField);
     }
 }

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOFieldImplCaching.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOFieldImplCaching.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOFieldImplCaching.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOFieldImplCaching.java Sun Jun  5 11:45:34 2005
@@ -17,7 +17,9 @@
 package org.apache.jdo.impl.model.jdo.caching;
 
 import org.apache.jdo.model.ModelException;
+import org.apache.jdo.model.java.JavaField;
 import org.apache.jdo.model.jdo.JDOArray;
+import org.apache.jdo.model.jdo.JDOClass;
 import org.apache.jdo.model.jdo.JDOCollection;
 import org.apache.jdo.model.jdo.JDOMap;
 import org.apache.jdo.model.jdo.JDOReference;
@@ -39,13 +41,18 @@
  *
  * @author Michael Bouschen
  * @since 1.1
- * @version 1.1
+ * @version 2.0
  */
 public class JDOFieldImplCaching extends JDOFieldImplDynamic {
 
     /** Relative field number. */
     private int relativeFieldNumber = -1;
 
+    /** Constructor. */
+    protected JDOFieldImplCaching(String name, JDOClass declaringClass) {
+        super(name, declaringClass);
+    }
+
     /**
      * Get the persistence modifier of this JDOField.
      * @return the persistence modifier, one of 
@@ -98,6 +105,17 @@
         return (embedded == null) ? false : embedded.booleanValue();
     }
     
+    /**
+     * Get the corresponding JavaField representation for this JDOField.
+     * @return the corresponding Java field representation
+     */
+    public JavaField getJavaField() {
+        if (javaField == null) {
+            javaField = super.getJavaField();
+        }
+        return javaField;
+    }
+
     /**
      * Get the relationship information for this JDOField. The method 
      * returns null if the field is not part of a relationship 

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOModelImplCaching.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOModelImplCaching.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOModelImplCaching.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOModelImplCaching.java Sun Jun  5 11:45:34 2005
@@ -145,8 +145,8 @@
     }
 
     /** Returns a new instance of the JDOClass implementation class. */
-    protected JDOClass newJDOClassInstance() {
-        return new JDOClassImplCaching();
+    protected JDOClass newJDOClassInstance(String name) {
+        return new JDOClassImplCaching(name);
     }
 
     /**

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOPropertyImplCaching.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOPropertyImplCaching.java?rev=180130&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOPropertyImplCaching.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/caching/JDOPropertyImplCaching.java Sun Jun  5 11:45:34 2005
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.jdo.impl.model.jdo.caching;
+
+import org.apache.jdo.model.ModelException;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.model.java.JavaProperty;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOClass;
+import org.apache.jdo.model.jdo.JDOField;
+import org.apache.jdo.model.jdo.JDOProperty;
+
+/**
+ * An instance of this class represents the JDO metadata of a managed field 
+ * of a persistence capable class. This dynamic implementation only
+ * stores property values explicitly set by setter method. 
+ * <p>
+ * Please note, you cannot rely on the Java identity of the
+ * JDORelationship instance returned by {@link #getRelationship}.  
+ * The getter will always return a new Java Instance, unless the
+ * relationship is explicitly set by the setter 
+ * {@link #setRelationship(JDORelationship relationship)}.
+ *
+ * @author Michael Bouschen
+ * @since 2.0
+ * @version 2.0
+ */
+public class JDOPropertyImplCaching
+    extends JDOFieldImplCaching
+    implements JDOProperty
+{
+    /** */
+    protected JDOPropertyImplCaching(String name, JDOClass declaringClass) {
+        super(name, declaringClass);
+    }
+
+    /**
+     * Get the corresponding JavaField representation for this JDOProperty.
+     * @return the corresponding JavaProperty representation
+     */
+    public JavaField getJavaField() {
+        if (javaField == null) {
+            // not set => calculate
+            // Please note, cannot call super.getJavaField, because it
+            // returns a JavaField!
+            JavaType javaType = getDeclaringClass().getJavaType();
+            javaField = javaType.getJavaProperty(getName());
+        }
+        return javaField;
+    }
+
+    /**
+     * Sets the corresponding JavaProperty representation for this JDOProperty.
+     * @param javaField the corresponding JavaProperty representation
+     * @throws ModelException if impossible
+     */
+    public void setJavaField(JavaField javaField) throws ModelException {
+        if (javaField instanceof JavaProperty) {
+            this.javaField = javaField;
+        }
+        else {
+            throw new ModelException(msg.msg(
+                "EXC_InvalidJavaFieldForJDOProperty", javaField)); //NOI18N
+        }
+    }
+
+    /**
+     * Convenience method to check whether this field represents a property.
+     * @return <code>true</code> if this field represents a property; 
+     * <code>false</code> otherwise
+     */
+    public boolean isProperty() {
+        return true;
+    }
+
+    /** 
+     * Return the JDOField instance associated with this property, if
+     * available. If there is no JDOField instance associated, then the method
+     * returns <code>null</code>.
+     * <p>
+     * This implementation always retruns <code>null</code>.
+     * @return associated JDOField instance or <code>null</code> if not
+     * available.
+     */
+    public JDOField getAssociatedJDOField() {
+        return null;
+    }
+}

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/util/PrintSupport.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/util/PrintSupport.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/util/PrintSupport.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/util/PrintSupport.java Sun Jun  5 11:45:34 2005
@@ -136,8 +136,12 @@
     {
         if (jdoField == null)
             return;
+        boolean isProperty = jdoField.isProperty();
 
-        println(indent, "--> JDOField "); //NOI18N
+        if (isProperty)
+            println(indent, "--> JDOProperty"); //NOI18N
+        else
+            println(indent, "--> JDOField"); //NOI18N
         println(indent+1, "name                = " + jdoField.getName()); //NOI18N
         println(indent+1, "declaringClass      = " + jdoField.getDeclaringClass().getName()); //NOI18N
         println(indent+1, "persistenceModifier = " + PersistenceModifier.toString(jdoField.getPersistenceModifier())); //NOI18N
@@ -151,9 +155,13 @@
         println(indent+1, "serializable        = " + jdoField.isSerializable()); //NOI18N
         println(indent+1, "fieldNumber         = " + jdoField.getFieldNumber()); //NOI18N
         println(indent+1, "relativeFieldNumber = " + jdoField.getRelativeFieldNumber()); //NOI18N
+        println(indent+1, "isProperty          = " + jdoField.isProperty()); //NOI18N
         printJDORelationship(indent+1, jdoField.getRelationship()); //NOI18N
         printJDOExtensions(indent+1, jdoField.getJDOExtensions()); //NOI18N
-        println(indent, "<-- JDOField "); //NOI18N
+        if (isProperty)
+            println(indent, "<-- JDOProperty "); //NOI18N
+        else
+            println(indent, "<-- JDOField "); //NOI18N
     }
     
     private static void printJDORelationship(int indent, 

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaField.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaField.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaField.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaField.java Sun Jun  5 11:45:34 2005
@@ -16,8 +16,6 @@
 
 package org.apache.jdo.model.java;
 
-import org.apache.jdo.model.jdo.JDOField;
-
 /**
  * A JavaField instance represents a field declared by a class. It allows
  * to get detailed information about the field such as name, modifiers,
@@ -34,24 +32,4 @@
  */
 public interface JavaField extends JavaMember 
 {
-    /**
-     * Returns the corresponding JDOField instance, if the JDOModel
-     * provides any JDO metadata for the field represented by this
-     * JavaField. If there is no corresponding JDOField representation, the
-     * method returns <code>null</code>. 
-     * <p>
-     * A <code>null</code> result means the declaring class is not
-     * persistence capable or the field represented by this JavaField is
-     * not managed. Note, a non-<code>null</code> result does not
-     * necessarily mean the field is managed. The JDO metadata might define
-     * the persistence-modifier of this field as <code>none</code>. Then
-     * the JDOModel provides a JDOField instance which is returned by this
-     * method. You can call method  
-     * {@link org.apache.jdo.model.jdo.JDOField#isManaged()} on a 
-     * non-<code>null</code> result to verify that this JavaField
-     * represents a managed field. 
-     * @return the corresponding JDOField instance (if available);
-     * <code>null</code> otherwise.
-     */
-    public JDOField getJDOField();
 }

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModel-API.jpg
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModel-API.jpg?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
Binary files - no diff available.

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModel.mdl
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModel.mdl?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
Binary files - no diff available.

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaProperty.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaProperty.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaProperty.java Sun Jun  5 11:45:34 2005
@@ -22,7 +22,7 @@
  * @author Michael Bouschen
  * @version JDO 2.0
  */
-public interface JavaProperty extends JavaMember 
+public interface JavaProperty extends JavaField
 {
     /**
      * Returns the JavaMethod representation of the getter method for this

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOClass.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOClass.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOClass.java Sun Jun  5 11:45:34 2005
@@ -243,21 +243,52 @@
     public void setJDOPackage(JDOPackage jdoPackage);
 
     /**
-     * This method returns a JDOField instance for the field with the specified 
+     * This method returns a JDOField instance for the field with the specified
      * name. If this JDOClass already declares such a field, the existing 
      * JDOField instance is returned. Otherwise, it creates a new JDOField 
-     * instance, sets its declaringClass and returns the new instance.
+     * instance, sets its declaring JDOClass and returns the new instance.
      * @param name the name of the field
+     * @return a JDOField instance for the specified field name
      * @exception ModelException if impossible
      */
     public JDOField createJDOField(String name)
         throws ModelException;
 
     /**
+     * This method returns a JDOProperty instance for the property with the
+     * specified name. If this JDOClass already declares such a property, the
+     * existing JDOProperty instance is returned. Otherwise, it creates a new
+     * JDOProperty instance, sets its declaring JDOClass and returns the new
+     * instance.
+     * @param name the name of the property
+     * @return a JDOProperty instance for the specified property
+     * @exception ModelException if impossible
+     */
+    public JDOProperty createJDOProperty(String name)
+        throws ModelException;
+
+    /**
+     * This method returns a JDOProperty instance for the property with the
+     * specified name and associated field. If this JDOClass already declares
+     * such a property the existing JDOProperty instance is returned. If it
+     * declares a property with the specified name but different associated
+     * field, then a ModelException is thrown. If there is no such property,
+     * the method creates a new JDOProperty instance, sets its declaring
+     * JDOClass and associated field and returns the new instance.
+     * @param name the name of the property
+     * @param associatedField the associated JDOField 
+     * @return a JDOProperty instance for the specified property
+     * @exception ModelException if impossible
+     */
+    public JDOProperty createJDOProperty(String name, JDOField associatedField)
+        throws ModelException;
+
+    /**
      * This method returns a JDOClass instance representing an inner class of 
      * this JDOClass If this JDOClass already declares such an inner class, 
      * the existing JDOClass instance is returned. Otherwise, it creates a new 
-     * JDOClass instance, sets its declaringClass and returns the new instance.
+     * JDOClass instance, sets its declaring JDOClass and returns the new
+     * instance.
      * @param name the name of the inner class
      * @exception ModelException if impossible
      */
@@ -485,6 +516,33 @@
      * if there is no such field declared by this JDOClass.
      */
     public JDOField getDeclaredField(String fieldName);
+
+    /**
+     * Returns JDOProperty metadata for a property with the specified name
+     * having an associated JDOField. The method returns <code>null</code>, if
+     * the name does not denote a property with an associated JDOField of this
+     * JDOClass. Please note, the method does not check for properties without
+     * an associated JDOField. It will return <code>null</code> if there is
+     * a property with the specified name, but this property does not have an
+     * associated JDOField.
+     * @param name the name of property with an associated JDOField for which
+     * metadata is needed.
+     * @return JDOProperty metadata for the property with an associated
+     * JDOField or <code>null</code> if there is no such property.
+     */
+    public JDOProperty getAssociatedProperty(String name);
+
+    /**
+     * Returns JDOProperty metadata for a property having the specified
+     * JDOField as associated JDOField. The method returns <code>null</code>,
+     * if this JDOClass does not have a property with the specified JDOField
+     * as associated JDOField.
+     * @param JDOField the assoaciated JDOField of the property for which
+     * metadata is needed.
+     * @return JDOProperty metadata for the property the specified JDOField as
+     * associated JDOField or <code>null</code> if there is no such property.
+     */
+    public JDOProperty getAssociatedProperty(JDOField field);
 
     /**
      * Returns the number of managed fields declared in the class represented

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOField.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOField.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOField.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOField.java Sun Jun  5 11:45:34 2005
@@ -265,6 +265,13 @@
     public boolean isRelationship();
 
     /**
+     * Convenience method to check whether this field represents a property.
+     * @return <code>true</code> if this field represents a property; 
+     * <code>false</code> otherwise
+     */
+    public boolean isProperty();
+
+    /**
      * Get the JavaType representation of the type of the field.
      * @return JavaType representation of the type of this field.
      */

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOMember.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOMember.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOMember.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOMember.java Sun Jun  5 11:45:34 2005
@@ -33,27 +33,10 @@
      */
     public String getName();
 
-    /**
-     * Sets the name of this JDOMember.
-     * @param name the name
-     * @exception ModelException if impossible
-     */
-    public void setName(String name)
-        throws ModelException;
-
     /** 
      * Get the declaring class of this JDOMember.
      * @return the class that owns this JDOMember, or <code>null</code>
      * if the element is not attached to any class
      */
     public JDOClass getDeclaringClass();
-
-    /** 
-     * Set the declaring class of this JDOMember.
-     * @param declaringClass the declaring class of this member element
-     * @exception ModelException if impossible
-     */
-    public void setDeclaringClass(JDOClass declaringClass)
-        throws ModelException;
-
 }

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Member.jpg
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Member.jpg?rev=180130&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Member.jpg
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Member.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Model-jpg
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Model-jpg?rev=180130&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Model-jpg
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel-Model-jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel.mdl
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModel.mdl?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
Binary files - no diff available.

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOProperty.java?rev=180130&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOProperty.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOProperty.java Sun Jun  5 11:45:34 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.jdo.model.jdo;
+
+/**
+ * A JDOProperty instance represents the JDO metadata of a property of a
+ * persistence-capable class. 
+ *
+ * @author Michael Bouschen
+ */
+public interface JDOProperty
+    extends JDOField
+{
+    /** 
+     * Return the JDOField instance associated with this property, if
+     * available. If there is no JDOField instance associated, then the method
+     * returns <code>null</code>.
+     * @return associated JDOField instance or <code>null</code> if not
+     * available.
+     */
+    public JDOField getAssociatedJDOField();
+}

Modified: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/Optimizer.g
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/Optimizer.g?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/Optimizer.g (original)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/Optimizer.g Sun Jun  5 11:45:34 2005
@@ -824,7 +824,7 @@
                                  Object object)
     {
         int fieldNumber = 
-            TypeSupport.getFieldNumber(javaField.getJDOField(), pm, object);
+            TypeSupport.getFieldNumber(javaField, pm, object);
         if (fieldNumber == -1) 
             return TypeSupport.getFieldValue(getAccessibleField(javaField), 
                                              object);

Modified: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/TypeSupport.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/TypeSupport.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/TypeSupport.java (original)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/jdoqlc/TypeSupport.java Sun Jun  5 11:45:34 2005
@@ -288,9 +288,20 @@
     }
     
     /** */
+    public static JDOField getJDOField(JavaField javaField)
+    {
+        JDOField jdoField = null;
+        JDOClass jdoClass = javaField.getDeclaringClass().getJDOClass();
+        if (jdoClass != null) {
+            jdoField = jdoClass.getField(javaField.getName());
+        }
+        return jdoField;
+    }
+
+    /** */
     public static JavaType getElementType(JavaField field)
     {
-        JDOField jdoField = field.getJDOField();
+        JDOField jdoField = getJDOField(field);
         if (jdoField != null) {
             // check relationship
             try {
@@ -364,10 +375,11 @@
      * Returns the fieldNumber of the specified field.
      * @return field number 
      */
-    public static int getFieldNumber(JDOField jdoField,
+    public static int getFieldNumber(JavaField javaField,
                                      PersistenceManager pm, 
                                      Object object)
     {
+        JDOField jdoField = getJDOField(javaField);
         if ((object == null) || // null object means static field access
             (jdoField == null) || // no jdo field info
             !jdoField.isManaged()) { // field is not managed

Modified: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FieldAccessExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FieldAccessExpr.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FieldAccessExpr.java (original)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FieldAccessExpr.java Sun Jun  5 11:45:34 2005
@@ -135,7 +135,7 @@
      */
     public Object getFieldValue(PersistenceManager pm, Object object)
     {   JavaField javaField = getFieldInfo();
-        int fieldNumber = TypeSupport.getFieldNumber( javaField.getJDOField(), 
+        int fieldNumber = TypeSupport.getFieldNumber( javaField, 
                                                       pm, object );
         if (fieldNumber == -1) {
             return TypeSupport.getFieldValue( getField(), object );

Modified: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java (original)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java Sun Jun  5 11:45:34 2005
@@ -166,7 +166,7 @@
         throws ModelException
     {
         // handle JavaField
-        JavaField javaField = declaringClass.createJavaField(jdoField, 
+        JavaField javaField = declaringClass.createJavaField(jdoField.getName(),
             javaModelFactory.getJavaType(fieldType));
         jdoField.setJavaField(javaField);
         

Modified: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java (original)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java Sun Jun  5 11:45:34 2005
@@ -21,7 +21,6 @@
 import org.apache.jdo.model.java.JavaField;
 import org.apache.jdo.model.java.JavaModel;
 import org.apache.jdo.model.java.JavaType;
-import org.apache.jdo.model.jdo.JDOField;
 import org.apache.jdo.util.I18NHelper;
 
 /**
@@ -52,20 +51,19 @@
     /**
      * RegisterClassListener calls this method to create a ReflectionJavaField
      * instance when processing the enhancer generated metadata.
-     * @param jdoField the JDO field metadata
+     * @param name the name of the field
      * @param type the type of the field
      * @return the ReflectionJavaField representation
      */
-    public synchronized JavaField createJavaField(JDOField jdoField, JavaType type)
+    public synchronized JavaField createJavaField(String name, JavaType type)
     {
-        String name = jdoField.getName();
         JavaField javaField = (JavaField)declaredJavaFields.get(name);
         if (javaField != null) {
             throw new ModelFatalException(msg.msg(
                 "ERR_MultipleJavaField", //NOI18N
                 "RuntimeJavaType.createJavaField", name, getName())); //NOI18N
         }
-        javaField = newJavaFieldInstance(jdoField, type);
+        javaField = newJavaFieldInstance(name, type);
         declaredJavaFields.put(name, javaField);
         return javaField;
     }

Modified: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaField.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaField.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaField.java (original)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaField.java Sun Jun  5 11:45:34 2005
@@ -20,7 +20,6 @@
 
 import org.apache.jdo.impl.model.java.reflection.ReflectionJavaField;
 import org.apache.jdo.model.java.JavaType;
-import org.apache.jdo.model.jdo.JDOField;
 
 /**
  * A reflection based JavaField implementation used at runtime in a
@@ -43,14 +42,14 @@
         
     /** 
      * Constructor for fields having JDO metadata.
-     * @param jdoField the JDO field metadata.
+     * @param name the name of the field.
      * @param type the field type.
      * @param declaringClass the JavaType of the class that declares the field.
      */
-    public JDK5RuntimeJavaField(JDOField jdoField, JavaType type, 
+    public JDK5RuntimeJavaField(String name, JavaType type,
             JavaType declaringClass)
     {
-        super(jdoField, type, declaringClass);
+        super(name, type, declaringClass);
     }
     
     // ===== methods specified in JavaMember =====

Modified: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaType.java?rev=180130&r1=180129&r2=180130&view=diff
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaType.java (original)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/jdk5/JDK5RuntimeJavaType.java Sun Jun  5 11:45:34 2005
@@ -20,7 +20,6 @@
 import org.apache.jdo.model.java.JavaMethod;
 import org.apache.jdo.model.java.JavaProperty;
 import org.apache.jdo.model.java.JavaType;
-import org.apache.jdo.model.jdo.JDOField;
 
 import java.lang.reflect.Field;
 import org.apache.jdo.impl.model.java.runtime.*;
@@ -47,13 +46,13 @@
    /**
      * Creates a new instance of the JavaField implementation class.
      * <p>
-     * This implementation returns a <code>ReflectionJavaField</code>
+     * This implementation returns a <code>JDK5RuntimeJavaField</code>
      * instance.
      * @return a new JavaField instance.
      */
-    protected JavaField newJavaFieldInstance(JDOField jdoField, JavaType type) 
+    protected JavaField newJavaFieldInstance(String name, JavaType type) 
     {
-        return new JDK5RuntimeJavaField(jdoField, type, this);
+        return new JDK5RuntimeJavaField(name, type, this);
     }
     
     /**



Mime
View raw message