1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package com.finalist.mmbase.uml;
16
17 import com.finalist.mmbase.umlprofile.MMBaseUMLProfile;
18 import java.util.Collection;
19 import java.util.Iterator;
20
21 /***
22 * Value object that models all attributes of a class
23 * including the attributes defined in super classes
24 * and in the implemented interfaces
25 *
26 * Copyright 2003 Finalist IT-Group -- all rights reserved
27 *
28 * @author Rudie Ekkelenkamp.
29 * @version $Revision: 1.8 $, $Date: 2005/01/31 15:09:32 $
30 *
31 */
32 public class MMBaseAttributeVo {
33
34 private String attributeName;
35 private String attributeType;
36 private Collection stereotypes;
37 private String documentation;
38 private String visibility;
39 private String databaseSize;
40 private String minSize;
41 private String maxSize;
42 private String prompt;
43 private String databaseType;
44 private String fieldType;
45 private String optionListDefinition;
46 private String defaultValue;
47 private boolean system;
48
49
50
51
52 /***
53 * The constructor
54 *
55 * @param attributeName Name of the attribute
56 * @param attributeType Type of the attribute as specified in the UML model
57 * @param stereotypes Collection of stereotypes for this attribute
58 * @param documentation Documentation on an attribute.
59 * @param visibility Attribute visibility.
60 * @param databaseType MMbase Database on which the type is mapped.
61 * @param prompt Name of the prompt used in the GUI
62 * @param dbSize Database size of the attribute
63 * @param minSize Minimum size of the attribute.
64 * @param maxSize Maximum size of the attribute.
65 * @param fieldType Type used in the gui.
66 * @param optionListDefinition Name of the definition of the list.
67 * @param defaultValue the specified initialValue of an attribute.
68 * @param system defines an attribute as a system attribute, so not for editing in the wizards..
69 */
70 public MMBaseAttributeVo(String attributeName,
71 String attributeType,
72 Collection stereotypes,
73 String documentation,
74 String visibility,
75 String databaseType,
76 String prompt,
77 String dbSize,
78 String minSize,
79 String maxSize,
80 String fieldType,
81 String optionListDefinition,
82 String defaultValue,
83 boolean system) {
84
85 this.attributeName = attributeName;
86 this.attributeType = attributeType;
87 this.stereotypes = stereotypes;
88 this.documentation = documentation;
89 this.visibility = visibility;
90 this.databaseType = databaseType;
91 this.databaseSize = dbSize;
92 this.prompt = prompt;
93 this.minSize = minSize;
94 this.maxSize = maxSize;
95 this.fieldType = fieldType;
96 this.optionListDefinition = optionListDefinition;
97 this.defaultValue = defaultValue;
98 this.system = system;
99 }
100
101 /***
102 * get fieldtype
103 * @return field type
104 */
105 public String getFieldType() {
106
107 return fieldType;
108 }
109
110 /***
111 * setter of field type
112 * @param fieldType the field type
113 */
114 public void setFieldType(String fieldType) {
115 this.fieldType = fieldType;
116 }
117
118 /***
119 * getter database type.
120 * @return the database type.
121 */
122 public String getDatabaseType() {
123 return databaseType;
124 }
125
126 /***
127 * setter database type.
128 * @param databaseType the database type
129 */
130 public void setDatabaseType(String databaseType) {
131 this.databaseType = databaseType;
132 }
133
134 /***
135 * Get the promptname of a field.
136 * @return String with the promptname.
137 */
138 public String getPrompt() {
139 return prompt;
140 }
141
142 /***
143 * Set the promptName of a field.
144 *
145 * @param prompt name of the prompt.
146 */
147 public void setPrompt(String prompt) {
148 this.prompt = prompt;
149 }
150
151 /***
152 * getter of the min size.
153 * @return the minimum size.
154 */
155 public String getMinSize() {
156 return minSize;
157 }
158
159 /***
160 * Setter of the minimum size.
161 * @param minSize the minimum size.
162 */
163 public void setMinSize(String minSize) {
164 this.minSize = minSize;
165 }
166
167 /***
168 * Getter of the maximum size.
169 * @return the maximum size
170 */
171 public String getMaxSize() {
172 return maxSize;
173 }
174
175 /***
176 * Setter of the maximum size.
177 * @param maxSize the maximum size.
178 */
179 public void setMaxSize(String maxSize) {
180 this.maxSize = maxSize;
181 }
182
183 /***
184 * Getter of the database size
185 * @return the database size
186 */
187 public String getDatabaseSize() {
188 return databaseSize;
189 }
190
191 /***
192 * Setter of the database size.
193 * @param databaseSize the database size.
194 */
195 public void setDatabaseSize(String databaseSize) {
196 this.databaseSize = databaseSize;
197 }
198
199 /***
200 * Getter of the visibility
201 * @return the visibility
202 */
203 public String getVisibility() {
204 return visibility;
205 }
206
207 /***
208 * Setter of the visibility
209 * @param visibility the visibility
210 */
211 public void setVisibility(String visibility) {
212 this.visibility = visibility;
213 }
214
215 /***
216 * Getter of the attribute name.
217 * @return the attribute name.
218 */
219 public String getAttributeName() {
220 return attributeName;
221 }
222
223 /***
224 * Setter of the attribute name.
225 * @param attributeName the attribute name.
226 */
227 public void setAttributeName(String attributeName) {
228 this.attributeName = attributeName;
229 }
230
231 /***
232 * Getter of the attribute type.
233 * @return the attribute type.
234 */
235 public String getAttributeType() {
236 return attributeType;
237 }
238
239 /***
240 * Setter of the attribute type.
241 * @param attributeType the attribute type.
242 */
243 public void setAttributeType(String attributeType) {
244 this.attributeType = attributeType;
245 }
246
247 /***
248 * Setter of the stereo type.
249 * @param stereoType the stereotype
250 */
251 public void setAttributeStereoType(String stereoType) {
252 stereotypes.add(stereoType);
253 }
254
255 /***
256 * Get documentation
257 * @return the documentation
258 */
259 public String getDocumentation() {
260 return documentation;
261 }
262
263 /***
264 * Set the documentation
265 * @param documentation the documentation.
266 */
267 public void setDocumentation(String documentation) {
268 this.documentation = documentation;
269 }
270
271 /***
272 * Get optionListDefinition
273 * @return the name of the optionListDefinition.
274 */
275 public String getOptionListDefinition() {
276 return optionListDefinition;
277 }
278
279 /***
280 * Set the optionListDefinition
281 * @param optionListDefinition the name of the file that defines the list.
282 */
283 public void setOptionListDefinition(String optionListDefinition) {
284 this.optionListDefinition = optionListDefinition;
285 }
286
287 /***
288 * Returns the value of system.
289 */
290 public boolean isSystem()
291 {
292 return system;
293 }
294
295
296 /***
297 * Sets the value of system.
298 * @param system Weather the attribute is a system attribute (and shoud be hidden from the editors)
299 */
300 public void setSystem(boolean system)
301 {
302 this.system = system;
303 }
304
305 /***
306 * Get default value.
307 * @return the default value.
308 */
309 public String getDefaultValue() {
310 return defaultValue;
311 } /***
312 * Set the default value.
313 * @param defaultValue the default value
314 */
315 public void setDefaultValue(String defaultValue) {
316 this.defaultValue = defaultValue;
317 }
318
319
320 /***
321 * Get stereo type.
322 * @return stereotype of the attribute. If there are more stereotypes
323 * a comma separated list will be genereated.
324 * @deprecated use @see #getStrereotypes() or
325 * @see #hasStereotype(String name) in stead
326 */
327
328
329
330
331
332
333
334
335
336
337
338
339
340 /***
341 * Set stereotype.
342 * @param stereoType the type.
343 */
344
345
346
347
348
349 /***
350 * Get required.
351 * @return true if attribute is required
352 */
353 public boolean isRequired() {
354 return (stereotypes.contains(MMBaseUMLProfile.STEREOTYPE_ATTRIBUTE_REQUIRED));
355 }
356
357 /***
358 * Test if this attribute has a certain stereotype
359 * @return true if stereotype was found
360 */
361 public boolean hasStereotype(String stereotype){
362 for(Iterator i = stereotypes.iterator() ; i.hasNext() ;){
363 if(((String)i.next()).equals(stereotype))return true;
364 }
365 return false;
366 }
367
368 public Collection getAttributeStrereotypes(){
369 return stereotypes;
370 }
371
372
373 }