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