1
2
3
4
5
6
7
8 package org.astrogrid.workflow.beans.v1;
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.exolab.castor.xml.MarshalException;
19 import org.exolab.castor.xml.Marshaller;
20 import org.exolab.castor.xml.Unmarshaller;
21 import org.exolab.castor.xml.ValidationException;
22 import org.xml.sax.ContentHandler;
23
24 /***
25 * Declare (and optionally initialize) a new workflow variable, or
26 * update value of existing variable
27 *
28 * @version $Revision: 1.10 $ $Date: 2007/01/04 16:26:26 $
29 */
30 public class Set extends org.astrogrid.workflow.beans.v1.AbstractActivity
31 implements java.io.Serializable
32 {
33
34
35
36
37
38
39 /***
40 * the name of the variabe to set
41 */
42 private java.lang.String _var;
43
44 /***
45 * the value to set the variable to. May contain embedded
46 * expressions in ${..}, which will be evaluated
47 */
48 private java.lang.String _value;
49
50
51
52
53
54
55 public Set() {
56 super();
57 }
58
59
60
61
62
63
64 /***
65 * Note: hashCode() has not been overriden
66 *
67 * @param obj
68 */
69 public boolean equals(java.lang.Object obj)
70 {
71 if ( this == obj )
72 return true;
73
74 if (super.equals(obj)==false)
75 return false;
76
77 if (obj instanceof Set) {
78
79 Set temp = (Set)obj;
80 if (this._var != null) {
81 if (temp._var == null) return false;
82 else if (!(this._var.equals(temp._var)))
83 return false;
84 }
85 else if (temp._var != null)
86 return false;
87 if (this._value != null) {
88 if (temp._value == null) return false;
89 else if (!(this._value.equals(temp._value)))
90 return false;
91 }
92 else if (temp._value != null)
93 return false;
94 return true;
95 }
96 return false;
97 }
98
99 /***
100 * Returns the value of field 'value'. The field 'value' has
101 * the following description: the value to set the variable to.
102 * May contain embedded expressions in ${..}, which will be
103 * evaluated
104 *
105 * @return the value of field 'value'.
106 */
107 public java.lang.String getValue()
108 {
109 return this._value;
110 }
111
112 /***
113 * Returns the value of field 'var'. The field 'var' has the
114 * following description: the name of the variabe to set
115 *
116 * @return the value of field 'var'.
117 */
118 public java.lang.String getVar()
119 {
120 return this._var;
121 }
122
123 /***
124 * Method isValid
125 */
126 public boolean isValid()
127 {
128 try {
129 validate();
130 }
131 catch (org.exolab.castor.xml.ValidationException vex) {
132 return false;
133 }
134 return true;
135 }
136
137 /***
138 * Method marshal
139 *
140 * @param out
141 */
142 public void marshal(java.io.Writer out)
143 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
144 {
145
146 Marshaller.marshal(this, out);
147 }
148
149 /***
150 * Method marshal
151 *
152 * @param handler
153 */
154 public void marshal(org.xml.sax.ContentHandler handler)
155 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
156 {
157
158 Marshaller.marshal(this, handler);
159 }
160
161 /***
162 * Sets the value of field 'value'. The field 'value' has the
163 * following description: the value to set the variable to. May
164 * contain embedded expressions in ${..}, which will be
165 * evaluated
166 *
167 * @param value the value of field 'value'.
168 */
169 public void setValue(java.lang.String value)
170 {
171 this._value = value;
172 }
173
174 /***
175 * Sets the value of field 'var'. The field 'var' has the
176 * following description: the name of the variabe to set
177 *
178 * @param var the value of field 'var'.
179 */
180 public void setVar(java.lang.String var)
181 {
182 this._var = var;
183 }
184
185 /***
186 * Method unmarshalSet
187 *
188 * @param reader
189 */
190 public static org.astrogrid.workflow.beans.v1.Set unmarshalSet(java.io.Reader reader)
191 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
192 {
193 return (org.astrogrid.workflow.beans.v1.Set) Unmarshaller.unmarshal(org.astrogrid.workflow.beans.v1.Set.class, reader);
194 }
195
196 /***
197 * Method validate
198 */
199 public void validate()
200 throws org.exolab.castor.xml.ValidationException
201 {
202 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
203 validator.validate(this);
204 }
205
206 }