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