1
2
3
4
5
6
7
8 package org.astrogrid.applications.beans.v1.cea.implementation;
9
10
11
12
13
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import org.astrogrid.applications.beans.v1.cea.implementation.types.SwitchTypes;
19 import org.exolab.castor.xml.MarshalException;
20 import org.exolab.castor.xml.Marshaller;
21 import org.exolab.castor.xml.Unmarshaller;
22 import org.exolab.castor.xml.ValidationException;
23 import org.xml.sax.ContentHandler;
24
25 /***
26 * Defines what it is to be a command line parameter - needs more
27 * thought with experience
28 *
29 * @version $Revision: 1.2 $ $Date: 2007/01/04 16:26:20 $
30 */
31 public class CommandLineParameterDefinition extends org.astrogrid.applications.beans.v1.parameters.BaseParameterDefinition
32 implements java.io.Serializable
33 {
34
35
36
37
38
39
40 /***
41 * The characters that make up the commandline switch
42 */
43 private java.lang.String _commandSwitch;
44
45 /***
46 * the command position for a position only parameter. The
47 * default value means that the parameter is position
48 * independent and is assumed to need a switch. Conversely if a
49 * parameter has a position value it is assumed not to need a
50 * switch
51 */
52 private int _commandPosition = -1;
53
54 /***
55 * keeps track of state for field: _commandPosition
56 */
57 private boolean _has_commandPosition;
58
59 /***
60 * is stdio - not used in implementation - should probably be
61 * removed.
62 */
63 private boolean _stdio = false;
64
65 /***
66 * keeps track of state for field: _stdio
67 */
68 private boolean _has_stdio;
69
70 /***
71 * specifies the style of the switch - would be better to call
72 * switchStyle!
73 */
74 private org.astrogrid.applications.beans.v1.cea.implementation.types.SwitchTypes _switchType = org.astrogrid.applications.beans.v1.cea.implementation.types.SwitchTypes.valueOf("normal");
75
76 /***
77 * does the application treat the parameter as a reference to a
78 * file
79 */
80 private boolean _fileRef = true;
81
82 /***
83 * keeps track of state for field: _fileRef
84 */
85 private boolean _has_fileRef;
86
87 /***
88 * the local name of the file that this parameter refers to if
89 * the application uses a fixed file name
90 */
91 private java.lang.String _localFileName;
92
93
94
95
96
97
98 public CommandLineParameterDefinition() {
99 super();
100 setSwitchType(org.astrogrid.applications.beans.v1.cea.implementation.types.SwitchTypes.valueOf("normal"));
101 }
102
103
104
105
106
107
108 /***
109 * Method deleteCommandPosition
110 */
111 public void deleteCommandPosition()
112 {
113 this._has_commandPosition= false;
114 }
115
116 /***
117 * Method deleteFileRef
118 */
119 public void deleteFileRef()
120 {
121 this._has_fileRef= false;
122 }
123
124 /***
125 * Method deleteStdio
126 */
127 public void deleteStdio()
128 {
129 this._has_stdio= false;
130 }
131
132 /***
133 * Note: hashCode() has not been overriden
134 *
135 * @param obj
136 */
137 public boolean equals(java.lang.Object obj)
138 {
139 if ( this == obj )
140 return true;
141
142 if (super.equals(obj)==false)
143 return false;
144
145 if (obj instanceof CommandLineParameterDefinition) {
146
147 CommandLineParameterDefinition temp = (CommandLineParameterDefinition)obj;
148 if (this._commandSwitch != null) {
149 if (temp._commandSwitch == null) return false;
150 else if (!(this._commandSwitch.equals(temp._commandSwitch)))
151 return false;
152 }
153 else if (temp._commandSwitch != null)
154 return false;
155 if (this._commandPosition != temp._commandPosition)
156 return false;
157 if (this._has_commandPosition != temp._has_commandPosition)
158 return false;
159 if (this._stdio != temp._stdio)
160 return false;
161 if (this._has_stdio != temp._has_stdio)
162 return false;
163 if (this._switchType != null) {
164 if (temp._switchType == null) return false;
165 else if (!(this._switchType.equals(temp._switchType)))
166 return false;
167 }
168 else if (temp._switchType != null)
169 return false;
170 if (this._fileRef != temp._fileRef)
171 return false;
172 if (this._has_fileRef != temp._has_fileRef)
173 return false;
174 if (this._localFileName != null) {
175 if (temp._localFileName == null) return false;
176 else if (!(this._localFileName.equals(temp._localFileName)))
177 return false;
178 }
179 else if (temp._localFileName != null)
180 return false;
181 return true;
182 }
183 return false;
184 }
185
186 /***
187 * Returns the value of field 'commandPosition'. The field
188 * 'commandPosition' has the following description: the command
189 * position for a position only parameter. The default value
190 * means that the parameter is position independent and is
191 * assumed to need a switch. Conversely if a parameter has a
192 * position value it is assumed not to need a switch
193 *
194 * @return the value of field 'commandPosition'.
195 */
196 public int getCommandPosition()
197 {
198 return this._commandPosition;
199 }
200
201 /***
202 * Returns the value of field 'commandSwitch'. The field
203 * 'commandSwitch' has the following description: The
204 * characters that make up the commandline switch
205 *
206 * @return the value of field 'commandSwitch'.
207 */
208 public java.lang.String getCommandSwitch()
209 {
210 return this._commandSwitch;
211 }
212
213 /***
214 * Returns the value of field 'fileRef'. The field 'fileRef'
215 * has the following description: does the application treat
216 * the parameter as a reference to a file
217 *
218 * @return the value of field 'fileRef'.
219 */
220 public boolean getFileRef()
221 {
222 return this._fileRef;
223 }
224
225 /***
226 * Returns the value of field 'localFileName'. The field
227 * 'localFileName' has the following description: the local
228 * name of the file that this parameter refers to if the
229 * application uses a fixed file name
230 *
231 * @return the value of field 'localFileName'.
232 */
233 public java.lang.String getLocalFileName()
234 {
235 return this._localFileName;
236 }
237
238 /***
239 * Returns the value of field 'stdio'. The field 'stdio' has
240 * the following description: is stdio - not used in
241 * implementation - should probably be removed.
242 *
243 * @return the value of field 'stdio'.
244 */
245 public boolean getStdio()
246 {
247 return this._stdio;
248 }
249
250 /***
251 * Returns the value of field 'switchType'. The field
252 * 'switchType' has the following description: specifies the
253 * style of the switch - would be better to call switchStyle!
254 *
255 * @return the value of field 'switchType'.
256 */
257 public org.astrogrid.applications.beans.v1.cea.implementation.types.SwitchTypes getSwitchType()
258 {
259 return this._switchType;
260 }
261
262 /***
263 * Method hasCommandPosition
264 */
265 public boolean hasCommandPosition()
266 {
267 return this._has_commandPosition;
268 }
269
270 /***
271 * Method hasFileRef
272 */
273 public boolean hasFileRef()
274 {
275 return this._has_fileRef;
276 }
277
278 /***
279 * Method hasStdio
280 */
281 public boolean hasStdio()
282 {
283 return this._has_stdio;
284 }
285
286 /***
287 * Method isValid
288 */
289 public boolean isValid()
290 {
291 try {
292 validate();
293 }
294 catch (org.exolab.castor.xml.ValidationException vex) {
295 return false;
296 }
297 return true;
298 }
299
300 /***
301 * Method marshal
302 *
303 * @param out
304 */
305 public void marshal(java.io.Writer out)
306 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
307 {
308
309 Marshaller.marshal(this, out);
310 }
311
312 /***
313 * Method marshal
314 *
315 * @param handler
316 */
317 public void marshal(org.xml.sax.ContentHandler handler)
318 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
319 {
320
321 Marshaller.marshal(this, handler);
322 }
323
324 /***
325 * Sets the value of field 'commandPosition'. The field
326 * 'commandPosition' has the following description: the command
327 * position for a position only parameter. The default value
328 * means that the parameter is position independent and is
329 * assumed to need a switch. Conversely if a parameter has a
330 * position value it is assumed not to need a switch
331 *
332 * @param commandPosition the value of field 'commandPosition'.
333 */
334 public void setCommandPosition(int commandPosition)
335 {
336 this._commandPosition = commandPosition;
337 this._has_commandPosition = true;
338 }
339
340 /***
341 * Sets the value of field 'commandSwitch'. The field
342 * 'commandSwitch' has the following description: The
343 * characters that make up the commandline switch
344 *
345 * @param commandSwitch the value of field 'commandSwitch'.
346 */
347 public void setCommandSwitch(java.lang.String commandSwitch)
348 {
349 this._commandSwitch = commandSwitch;
350 }
351
352 /***
353 * Sets the value of field 'fileRef'. The field 'fileRef' has
354 * the following description: does the application treat the
355 * parameter as a reference to a file
356 *
357 * @param fileRef the value of field 'fileRef'.
358 */
359 public void setFileRef(boolean fileRef)
360 {
361 this._fileRef = fileRef;
362 this._has_fileRef = true;
363 }
364
365 /***
366 * Sets the value of field 'localFileName'. The field
367 * 'localFileName' has the following description: the local
368 * name of the file that this parameter refers to if the
369 * application uses a fixed file name
370 *
371 * @param localFileName the value of field 'localFileName'.
372 */
373 public void setLocalFileName(java.lang.String localFileName)
374 {
375 this._localFileName = localFileName;
376 }
377
378 /***
379 * Sets the value of field 'stdio'. The field 'stdio' has the
380 * following description: is stdio - not used in implementation
381 * - should probably be removed.
382 *
383 * @param stdio the value of field 'stdio'.
384 */
385 public void setStdio(boolean stdio)
386 {
387 this._stdio = stdio;
388 this._has_stdio = true;
389 }
390
391 /***
392 * Sets the value of field 'switchType'. The field 'switchType'
393 * has the following description: specifies the style of the
394 * switch - would be better to call switchStyle!
395 *
396 * @param switchType the value of field 'switchType'.
397 */
398 public void setSwitchType(org.astrogrid.applications.beans.v1.cea.implementation.types.SwitchTypes switchType)
399 {
400 this._switchType = switchType;
401 }
402
403 /***
404 * Method unmarshalCommandLineParameterDefinition
405 *
406 * @param reader
407 */
408 public static org.astrogrid.applications.beans.v1.cea.implementation.CommandLineParameterDefinition unmarshalCommandLineParameterDefinition(java.io.Reader reader)
409 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
410 {
411 return (org.astrogrid.applications.beans.v1.cea.implementation.CommandLineParameterDefinition) Unmarshaller.unmarshal(org.astrogrid.applications.beans.v1.cea.implementation.CommandLineParameterDefinition.class, reader);
412 }
413
414 /***
415 * Method validate
416 */
417 public void validate()
418 throws org.exolab.castor.xml.ValidationException
419 {
420 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
421 validator.validate(this);
422 }
423
424 }