1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.exolab.castor.builder.types;
15
16 import org.exolab.castor.builder.SourceGeneratorConstants;
17 import org.exolab.castor.xml.schema.Facet;
18 import org.exolab.javasource.JClass;
19 import org.exolab.javasource.JCollectionType;
20 import org.exolab.javasource.JType;
21
22
23
24
25
26
27
28 public abstract class XSListType extends XSType {
29
30
31
32 private final XSType _contentType;
33
34
35 private final JType _jType;
36
37
38 private int _maxSize = -1;
39
40
41 private int _minSize = 0;
42
43
44
45
46
47
48
49
50
51
52 public XSListType(final String colType, final XSType contentType, final boolean useJava50) {
53 super();
54
55 _contentType = contentType;
56
57 if (colType.equalsIgnoreCase(SourceGeneratorConstants.FIELD_INFO_ARRAY_LIST)) {
58 _jType = new JCollectionType("java.util.List", "java.util.ArrayList", contentType.getJType(),
59 useJava50);
60 } else if (colType.equalsIgnoreCase(SourceGeneratorConstants.FIELD_INFO_COLLECTION)) {
61 _jType = new JCollectionType("java.util.Collection", "java.util.LinkedList",
62 contentType.getJType(), useJava50);
63 } else if (colType.equalsIgnoreCase(SourceGeneratorConstants.FIELD_INFO_SET)) {
64 _jType = new JCollectionType("java.util.Set", "java.util.HashSet", contentType.getJType(),
65 useJava50);
66 } else if (colType.equalsIgnoreCase(SourceGeneratorConstants.FIELD_INFO_SORTED_SET)) {
67 _jType = new JCollectionType("java.util.SortedSet", "java.util.TreeSet",
68 contentType.getJType(), useJava50);
69 } else if (colType.equalsIgnoreCase(SourceGeneratorConstants.FIELD_INFO_VECTOR)) {
70 _jType = new JCollectionType("java.util.Vector", contentType.getJType(), useJava50);
71 } else if (colType.equalsIgnoreCase(SourceGeneratorConstants.FIELD_INFO_ODMG)) {
72 _jType = new JClass("org.odmg.DArray");
73 } else {
74 _jType = null;
75 }
76 }
77
78
79
80
81
82
83
84
85
86 public final XSType getContentType() {
87 return _contentType;
88 }
89
90
91
92
93 public JType getJType() {
94 return _jType;
95 }
96
97
98
99
100
101
102 public final int getMaximumSize() {
103 return _maxSize;
104 }
105
106
107
108
109
110
111 public final void setMaximumSize(final int size) {
112 _maxSize = size;
113 }
114
115
116
117
118
119
120 public final int getMinimumSize() {
121 return _minSize;
122 }
123
124
125
126
127
128
129 public final void setMinimumSize(final int size) {
130 _minSize = size;
131 }
132
133
134
135
136 public boolean isCollection() {
137 return true;
138 }
139
140
141
142
143 public String getName() {
144 return _jType.getName();
145 }
146
147
148
149
150 public boolean isPrimitive() {
151 return false;
152 }
153
154
155
156
157 public boolean isDateTime() {
158 return false;
159 }
160
161
162
163
164 public String newInstanceCode() {
165 return "null;";
166 }
167
168
169
170
171 public String createToJavaObjectCode(final String variableName) {
172 return variableName;
173 }
174
175
176
177
178 public String createFromJavaObjectCode(final String variableName) {
179 return "(" + getJType().toString() + ") " + variableName;
180 }
181
182
183
184
185
186
187 protected void setFacet(final Facet facet) {
188
189 }
190
191
192 }