1
2
3
4
5 package com.javaforge.bobber.archetype.model;
6
7
8
9
10
11 import java.util.Collection;
12 import java.util.Date;
13
14
15
16
17
18
19
20
21
22 public class Variable implements java.io.Serializable {
23
24
25
26
27
28
29
30
31
32 private String name;
33
34
35
36
37 private String description;
38
39
40
41
42 private String defvalue;
43
44
45
46
47 private java.util.List variables;
48
49
50
51
52
53
54
55
56
57
58
59 public void addVariable(Variable variable)
60 {
61 if ( !(variable instanceof Variable) )
62 {
63 throw new ClassCastException( "Variable.addVariables(variable) parameter must be instanceof " + Variable.class.getName() );
64 }
65 getVariables().add( variable );
66 variable.createVariableAssociation( this );
67 }
68
69
70
71
72
73
74 public void breakVariableAssociation(Variable variable)
75 {
76 if ( ! getVariables().contains( variable ) )
77 {
78 throw new IllegalStateException( "variable isn't associated." );
79 }
80
81 getVariables().remove( variable );
82 }
83
84
85
86
87
88
89 public void createVariableAssociation(Variable variable)
90 {
91 Collection variables = getVariables();
92
93 if ( getVariables().contains(variable) )
94 {
95 throw new IllegalStateException( "variable is already assigned." );
96 }
97
98 variables.add( variable );
99 }
100
101
102
103
104
105
106 public String getDefvalue()
107 {
108 return this.defvalue;
109 }
110
111
112
113
114
115
116 public String getDescription()
117 {
118 return this.description;
119 }
120
121
122
123
124
125
126 public String getName()
127 {
128 return this.name;
129 }
130
131
132
133
134
135
136 public java.util.List getVariables()
137 {
138 if ( this.variables == null )
139 {
140 this.variables = new java.util.ArrayList();
141 }
142
143 return this.variables;
144 }
145
146
147
148
149
150
151 public void removeVariable(Variable variable)
152 {
153 if ( !(variable instanceof Variable) )
154 {
155 throw new ClassCastException( "Variable.removeVariables(variable) parameter must be instanceof " + Variable.class.getName() );
156 }
157 variable.breakVariableAssociation( this );
158 getVariables().remove( variable );
159 }
160
161
162
163
164
165
166 public void setDefvalue(String defvalue)
167 {
168 this.defvalue = defvalue;
169 }
170
171
172
173
174
175
176 public void setDescription(String description)
177 {
178 this.description = description;
179 }
180
181
182
183
184
185
186 public void setName(String name)
187 {
188 this.name = name;
189 }
190
191
192
193
194
195
196
197 public void setVariables(java.util.List variables)
198 {
199 this.variables = variables;
200 }
201
202
203 private String modelEncoding = "UTF-8";
204
205
206
207
208
209
210 public void setModelEncoding( String modelEncoding )
211 {
212 this.modelEncoding = modelEncoding;
213 }
214
215
216
217
218 public String getModelEncoding()
219 {
220 return modelEncoding;
221 }
222 }