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.impl.model.jdo.util.TypeSupport;
21 import org.apache.jdo.model.java.JavaType;
22 import org.apache.jdo.model.jdo.JDOArray;
23 import org.apache.jdo.model.jdo.JDOField;
24
25 /***
26 * An instance of this class represents the JDO relationship metadata
27 * of a array relationship field. This dynamic implementation only
28 * stores property values explicitly set by setter method.
29 *
30 * @author Michael Bouschen
31 * @since 1.1
32 * @version 2.0
33 */
34 public class JDOArrayImplDynamic extends JDORelationshipImpl
35 implements JDOArray {
36
37 /*** Property embeddedElement. */
38 protected Boolean embeddedElement;
39
40 /***
41 * Determines whether the values of the elements should be stored
42 * if possible as part of the instance instead of as their own instances
43 * in the datastore.
44 * @return <code>true</code> if the elements should be stored as part of
45 * the instance; <code>false</code> otherwise
46 */
47 public boolean isEmbeddedElement() {
48 if (embeddedElement != null) {
49
50 return embeddedElement.booleanValue();
51 }
52
53
54 JavaType elementType = getElementType();
55 return (elementType != null) ?
56 TypeSupport.isEmbeddedElementType(elementType) : false;
57 }
58
59 /***
60 * Set whether the values of the elements should be stored
61 * if possible as part of the instance instead of as their own instances
62 * in the datastore.
63 * @param embeddedElement flag indicating whether the elements should be
64 * stored as part of the instance
65 */
66 public void setEmbeddedElement(boolean embeddedElement) {
67 this.embeddedElement = (embeddedElement ? Boolean.TRUE : Boolean.FALSE);
68 }
69
70 /***
71 * Get the type representation of the array component type.
72 * @return the array component type
73 */
74 public JavaType getElementType() {
75 JDOField jdoField = getDeclaringField();
76 JavaType fieldType = jdoField.getType();
77 return (fieldType != null) ? fieldType.getArrayComponentType() : null;
78 }
79
80 /***
81 * Determines whether this JDORelationship represents an array
82 * relationship or not. A return of <code>true</code> means this
83 * JDORelationship is a JDOArray instance.
84 * @return <code>true</code> if this JDORelationship represents an
85 * array relationship; <code>false</code> otherwise.
86 */
87 public boolean isJDOArray() {
88 return true;
89 }
90
91
92
93 /***
94 * Get the type representation of the relationship. This will be
95 * the JavaType for references, the element type for collections
96 * and arrays, and the value type for maps.
97 * @return the relationship type
98 */
99 public JavaType getRelatedJavaType() {
100 return getElementType();
101 }
102
103 }