1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jdo.impl.model.jdo.caching;
18
19 import org.apache.jdo.model.java.JavaType;
20 import org.apache.jdo.model.jdo.JDORelationship;
21 import org.apache.jdo.impl.model.jdo.JDOArrayImplDynamic;
22
23 /***
24 * An instance of this class represents the JDO relationship metadata
25 * of a array relationship field. This caching implementation
26 * caches any calulated value to avoid re-calculating it if it is
27 * requested again.
28 *
29 * @author Michael Bouschen
30 * @since 1.1
31 * @version 2.0
32 */
33 public class JDOArrayImplCaching extends JDOArrayImplDynamic {
34
35 /*** Type of the array element. */
36 private transient JavaType elementType;
37
38 /***
39 * Get the mappedBy relationship. If there is no mappedBy relationship
40 * set, the method checks the mappedBy name as specified in the declaring
41 * field and resolves the relationship. The method returns
42 * <code>null</code> if there is no mappedBy relationship set and there
43 * is no mappedBy name specified on the declaring field.
44 * @return the mappedBy relationship if available; <code>null</code>
45 * otherwise.
46 */
47 public JDORelationship getMappedBy() {
48 if (mappedBy == null) {
49 mappedBy = super.getMappedBy();
50 }
51 return mappedBy;
52 }
53
54 /***
55 * Get the inverse JDORelationship in the case of a two-way relationship.
56 * @return the inverse relationship
57 */
58 public JDORelationship getInverseRelationship() {
59 if (inverse == null) {
60 inverse = super.getInverseRelationship();
61 }
62 return inverse;
63 }
64
65 /***
66 * Determines whether the values of the elements should be stored
67 * if possible as part of the instance instead of as their own instances
68 * in the datastore.
69 * @return <code>true</code> if the elements should be stored as part of
70 * the instance; <code>false</code> otherwise
71 */
72 public boolean isEmbeddedElement() {
73 if (embeddedElement == null) {
74 embeddedElement =
75 super.isEmbeddedElement() ? Boolean.TRUE : Boolean.FALSE;
76 }
77 return embeddedElement.booleanValue();
78 }
79
80 /***
81 * Get the type representation of the array component type.
82 * @return the array component type
83 */
84 public JavaType getElementType() {
85 if (elementType == null) {
86 elementType = super.getElementType();
87 }
88 return elementType;
89 }
90
91 }
92