1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jdo.impl.model.jdo.caching;
19
20 import org.apache.jdo.model.ModelException;
21 import org.apache.jdo.model.java.JavaField;
22 import org.apache.jdo.model.java.JavaProperty;
23 import org.apache.jdo.model.java.JavaType;
24 import org.apache.jdo.model.jdo.JDOClass;
25 import org.apache.jdo.model.jdo.JDOField;
26 import org.apache.jdo.model.jdo.JDOProperty;
27
28 /***
29 * An instance of this class represents the JDO metadata of a managed field
30 * of a persistence capable class. This dynamic implementation only
31 * stores property values explicitly set by setter method.
32 * <p>
33 * Please note, you cannot rely on the Java identity of the
34 * JDORelationship instance returned by {@link #getRelationship}.
35 * The getter will always return a new Java Instance, unless the
36 * relationship is explicitly set by the setter
37 * {@link #setRelationship(JDORelationship relationship)}.
38 *
39 * @author Michael Bouschen
40 * @since 2.0
41 * @version 2.0
42 */
43 public class JDOPropertyImplCaching
44 extends JDOFieldImplCaching
45 implements JDOProperty
46 {
47 /*** */
48 protected JDOPropertyImplCaching(String name, JDOClass declaringClass) {
49 super(name, declaringClass);
50 }
51
52 /***
53 * Get the corresponding JavaField representation for this JDOProperty.
54 * @return the corresponding JavaProperty representation
55 */
56 public JavaField getJavaField() {
57 if (javaField == null) {
58
59
60
61 JavaType javaType = getDeclaringClass().getJavaType();
62 javaField = javaType.getJavaProperty(getName());
63 }
64 return javaField;
65 }
66
67 /***
68 * Sets the corresponding JavaProperty representation for this JDOProperty.
69 * @param javaField the corresponding JavaProperty representation
70 * @throws ModelException if impossible
71 */
72 public void setJavaField(JavaField javaField) throws ModelException {
73 if (javaField instanceof JavaProperty) {
74 this.javaField = javaField;
75 }
76 else {
77 throw new ModelException(msg.msg(
78 "EXC_InvalidJavaFieldForJDOProperty", javaField));
79 }
80 }
81
82 /***
83 * Convenience method to check whether this field represents a property.
84 * @return <code>true</code> if this field represents a property;
85 * <code>false</code> otherwise
86 */
87 public boolean isProperty() {
88 return true;
89 }
90
91 /***
92 * Return the JDOField instance associated with this property, if
93 * available. If there is no JDOField instance associated, then the method
94 * returns <code>null</code>.
95 * <p>
96 * This implementation always retruns <code>null</code>.
97 * @return associated JDOField instance or <code>null</code> if not
98 * available.
99 */
100 public JDOField getAssociatedJDOField() {
101 return null;
102 }
103 }