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;
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 property
30 * of a persistence capable class. This dynamic implementation only
31 * stores values explicitly set by setter method.
32 *
33 * @author Michael Bouschen
34 * @since 2.0
35 * @version 2.0
36 */
37 public class JDOPropertyImplDynamic
38 extends JDOFieldImplDynamic
39 implements JDOProperty
40 {
41 /*** Constructor. */
42 protected JDOPropertyImplDynamic(String name, JDOClass declaringClass) {
43 super(name, declaringClass);
44 }
45
46
47
48 /***
49 * Get the corresponding JavaField representation for this JDOProperty.
50 * @return the corresponding JavaProperty representation
51 */
52 public JavaField getJavaField() {
53 if (javaField != null) {
54
55 return javaField;
56 }
57
58
59 JavaType javaType = getDeclaringClass().getJavaType();
60 return javaType.getJavaProperty(getName());
61 }
62
63 /***
64 * Sets the corresponding JavaProperty representation for this JDOProperty.
65 * @param javaField the corresponding JavaProperty representation
66 * @throws ModelException if impossible
67 */
68 public void setJavaField(JavaField javaField) throws ModelException {
69 if (javaField instanceof JavaProperty) {
70 this.javaField = javaField;
71 }
72 else {
73 throw new ModelException(msg.msg(
74 "EXC_InvalidJavaFieldForJDOProperty", javaField));
75 }
76 }
77
78 /***
79 * Convenience method to check whether this field represents a property.
80 * @return <code>true</code> if this field represents a property;
81 * <code>false</code> otherwise
82 */
83 public boolean isProperty() {
84 return true;
85 }
86
87
88
89 /***
90 * Return the JDOField instance associated with this property, if
91 * available. If there is no JDOField instance associated, then the method
92 * returns <code>null</code>.
93 * <p>
94 * This implementation always retruns <code>null</code>.
95 * @return associated JDOField instance or <code>null</code> if not
96 * available.
97 */
98 public JDOField getAssociatedJDOField() {
99 return null;
100 }
101 }