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 * Error-handling construct. if an error occurs during execution of
26 * the wrapped activity,
27 * the activity in the 'catch' block is executed.
28 *
29 * @version $Revision: 1.10 $ $Date: 2007/01/04 16:26:26 $
30 */
31 public class Try extends org.astrogrid.workflow.beans.v1.AbstractActivity
32 implements java.io.Serializable
33 {
34
35
36
37
38
39
40 /***
41 * Head of the substitution group
42 */
43 private org.astrogrid.workflow.beans.v1.AbstractActivity _activity;
44
45 /***
46 * Action to take when an error occurs in the wrapped try block
47 * variable specified by 'var' attribute will contain details
48 * of the error.
49 *
50 */
51 private org.astrogrid.workflow.beans.v1.Catch _catch;
52
53
54
55
56
57
58 public Try() {
59 super();
60 }
61
62
63
64
65
66
67 /***
68 * Note: hashCode() has not been overriden
69 *
70 * @param obj
71 */
72 public boolean equals(java.lang.Object obj)
73 {
74 if ( this == obj )
75 return true;
76
77 if (super.equals(obj)==false)
78 return false;
79
80 if (obj instanceof Try) {
81
82 Try temp = (Try)obj;
83 if (this._activity != null) {
84 if (temp._activity == null) return false;
85 else if (!(this._activity.equals(temp._activity)))
86 return false;
87 }
88 else if (temp._activity != null)
89 return false;
90 if (this._catch != null) {
91 if (temp._catch == null) return false;
92 else if (!(this._catch.equals(temp._catch)))
93 return false;
94 }
95 else if (temp._catch != null)
96 return false;
97 return true;
98 }
99 return false;
100 }
101
102 /***
103 * Returns the value of field 'activity'. The field 'activity'
104 * has the following description: Head of the substitution
105 * group
106 *
107 * @return the value of field 'activity'.
108 */
109 public org.astrogrid.workflow.beans.v1.AbstractActivity getActivity()
110 {
111 return this._activity;
112 }
113
114 /***
115 * Returns the value of field 'catch'. The field 'catch' has
116 * the following description: Action to take when an error
117 * occurs in the wrapped try block
118 * variable specified by 'var' attribute will contain details
119 * of the error.
120 *
121 *
122 * @return the value of field 'catch'.
123 */
124 public org.astrogrid.workflow.beans.v1.Catch getCatch()
125 {
126 return this._catch;
127 }
128
129 /***
130 * Method isValid
131 */
132 public boolean isValid()
133 {
134 try {
135 validate();
136 }
137 catch (org.exolab.castor.xml.ValidationException vex) {
138 return false;
139 }
140 return true;
141 }
142
143 /***
144 * Method marshal
145 *
146 * @param out
147 */
148 public void marshal(java.io.Writer out)
149 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
150 {
151
152 Marshaller.marshal(this, out);
153 }
154
155 /***
156 * Method marshal
157 *
158 * @param handler
159 */
160 public void marshal(org.xml.sax.ContentHandler handler)
161 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
162 {
163
164 Marshaller.marshal(this, handler);
165 }
166
167 /***
168 * Sets the value of field 'activity'. The field 'activity' has
169 * the following description: Head of the substitution group
170 *
171 * @param activity the value of field 'activity'.
172 */
173 public void setActivity(org.astrogrid.workflow.beans.v1.AbstractActivity activity)
174 {
175 this._activity = activity;
176 }
177
178 /***
179 * Sets the value of field 'catch'. The field 'catch' has the
180 * following description: Action to take when an error occurs
181 * in the wrapped try block
182 * variable specified by 'var' attribute will contain details
183 * of the error.
184 *
185 *
186 * @param _catch
187 * @param catch the value of field 'catch'.
188 */
189 public void setCatch(org.astrogrid.workflow.beans.v1.Catch _catch)
190 {
191 this._catch = _catch;
192 }
193
194 /***
195 * Method unmarshalTry
196 *
197 * @param reader
198 */
199 public static org.astrogrid.workflow.beans.v1.Try unmarshalTry(java.io.Reader reader)
200 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
201 {
202 return (org.astrogrid.workflow.beans.v1.Try) Unmarshaller.unmarshal(org.astrogrid.workflow.beans.v1.Try.class, reader);
203 }
204
205 /***
206 * Method validate
207 */
208 public void validate()
209 throws org.exolab.castor.xml.ValidationException
210 {
211 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
212 validator.validate(this);
213 }
214
215 }