1
2
3
4
5
6
7
8 package org.astrogrid.applications.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 java.util.ArrayList;
19 import java.util.Enumeration;
20 import org.exolab.castor.xml.MarshalException;
21 import org.exolab.castor.xml.Marshaller;
22 import org.exolab.castor.xml.Unmarshaller;
23 import org.exolab.castor.xml.ValidationException;
24 import org.xml.sax.ContentHandler;
25
26 /***
27 * Description of an HTTP get or post service
28 *
29 * @version $Revision: 1.8 $ $Date: 2007/01/04 16:26:34 $
30 */
31 public class WebHttpCall extends org.astrogrid.common.bean.BaseBean
32 implements java.io.Serializable
33 {
34
35
36
37
38
39
40 /***
41 * Field _URL
42 */
43 private org.astrogrid.applications.beans.v1.HttpURLType _URL;
44
45 /***
46 * Field _simpleParameterList
47 */
48 private java.util.ArrayList _simpleParameterList;
49
50
51
52
53
54
55 public WebHttpCall() {
56 super();
57 _simpleParameterList = new ArrayList();
58 }
59
60
61
62
63
64
65 /***
66 * Method addSimpleParameter
67 *
68 * @param vSimpleParameter
69 */
70 public void addSimpleParameter(org.astrogrid.applications.beans.v1.SimpleParameter vSimpleParameter)
71 throws java.lang.IndexOutOfBoundsException
72 {
73 _simpleParameterList.add(vSimpleParameter);
74 }
75
76 /***
77 * Method addSimpleParameter
78 *
79 * @param index
80 * @param vSimpleParameter
81 */
82 public void addSimpleParameter(int index, org.astrogrid.applications.beans.v1.SimpleParameter vSimpleParameter)
83 throws java.lang.IndexOutOfBoundsException
84 {
85 _simpleParameterList.add(index, vSimpleParameter);
86 }
87
88 /***
89 * Method clearSimpleParameter
90 */
91 public void clearSimpleParameter()
92 {
93 _simpleParameterList.clear();
94 }
95
96 /***
97 * Method enumerateSimpleParameter
98 */
99 public java.util.Enumeration enumerateSimpleParameter()
100 {
101 return new org.exolab.castor.util.IteratorEnumeration(_simpleParameterList.iterator());
102 }
103
104 /***
105 * Note: hashCode() has not been overriden
106 *
107 * @param obj
108 */
109 public boolean equals(java.lang.Object obj)
110 {
111 if ( this == obj )
112 return true;
113
114 if (super.equals(obj)==false)
115 return false;
116
117 if (obj instanceof WebHttpCall) {
118
119 WebHttpCall temp = (WebHttpCall)obj;
120 if (this._URL != null) {
121 if (temp._URL == null) return false;
122 else if (!(this._URL.equals(temp._URL)))
123 return false;
124 }
125 else if (temp._URL != null)
126 return false;
127 if (this._simpleParameterList != null) {
128 if (temp._simpleParameterList == null) return false;
129 else if (!(this._simpleParameterList.equals(temp._simpleParameterList)))
130 return false;
131 }
132 else if (temp._simpleParameterList != null)
133 return false;
134 return true;
135 }
136 return false;
137 }
138
139 /***
140 * Method getSimpleParameter
141 *
142 * @param index
143 */
144 public org.astrogrid.applications.beans.v1.SimpleParameter getSimpleParameter(int index)
145 throws java.lang.IndexOutOfBoundsException
146 {
147
148 if ((index < 0) || (index > _simpleParameterList.size())) {
149 throw new IndexOutOfBoundsException();
150 }
151
152 return (org.astrogrid.applications.beans.v1.SimpleParameter) _simpleParameterList.get(index);
153 }
154
155 /***
156 * Method getSimpleParameter
157 */
158 public org.astrogrid.applications.beans.v1.SimpleParameter[] getSimpleParameter()
159 {
160 int size = _simpleParameterList.size();
161 org.astrogrid.applications.beans.v1.SimpleParameter[] mArray = new org.astrogrid.applications.beans.v1.SimpleParameter[size];
162 for (int index = 0; index < size; index++) {
163 mArray[index] = (org.astrogrid.applications.beans.v1.SimpleParameter) _simpleParameterList.get(index);
164 }
165 return mArray;
166 }
167
168 /***
169 * Method getSimpleParameterCount
170 */
171 public int getSimpleParameterCount()
172 {
173 return _simpleParameterList.size();
174 }
175
176 /***
177 * Returns the value of field 'URL'.
178 *
179 * @return the value of field 'URL'.
180 */
181 public org.astrogrid.applications.beans.v1.HttpURLType getURL()
182 {
183 return this._URL;
184 }
185
186 /***
187 * Method isValid
188 */
189 public boolean isValid()
190 {
191 try {
192 validate();
193 }
194 catch (org.exolab.castor.xml.ValidationException vex) {
195 return false;
196 }
197 return true;
198 }
199
200 /***
201 * Method marshal
202 *
203 * @param out
204 */
205 public void marshal(java.io.Writer out)
206 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
207 {
208
209 Marshaller.marshal(this, out);
210 }
211
212 /***
213 * Method marshal
214 *
215 * @param handler
216 */
217 public void marshal(org.xml.sax.ContentHandler handler)
218 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
219 {
220
221 Marshaller.marshal(this, handler);
222 }
223
224 /***
225 * Method removeSimpleParameter
226 *
227 * @param vSimpleParameter
228 */
229 public boolean removeSimpleParameter(org.astrogrid.applications.beans.v1.SimpleParameter vSimpleParameter)
230 {
231 boolean removed = _simpleParameterList.remove(vSimpleParameter);
232 return removed;
233 }
234
235 /***
236 * Method setSimpleParameter
237 *
238 * @param index
239 * @param vSimpleParameter
240 */
241 public void setSimpleParameter(int index, org.astrogrid.applications.beans.v1.SimpleParameter vSimpleParameter)
242 throws java.lang.IndexOutOfBoundsException
243 {
244
245 if ((index < 0) || (index > _simpleParameterList.size())) {
246 throw new IndexOutOfBoundsException();
247 }
248 _simpleParameterList.set(index, vSimpleParameter);
249 }
250
251 /***
252 * Method setSimpleParameter
253 *
254 * @param simpleParameterArray
255 */
256 public void setSimpleParameter(org.astrogrid.applications.beans.v1.SimpleParameter[] simpleParameterArray)
257 {
258
259 _simpleParameterList.clear();
260 for (int i = 0; i < simpleParameterArray.length; i++) {
261 _simpleParameterList.add(simpleParameterArray[i]);
262 }
263 }
264
265 /***
266 * Sets the value of field 'URL'.
267 *
268 * @param URL the value of field 'URL'.
269 */
270 public void setURL(org.astrogrid.applications.beans.v1.HttpURLType URL)
271 {
272 this._URL = URL;
273 }
274
275 /***
276 * Method unmarshalWebHttpCall
277 *
278 * @param reader
279 */
280 public static org.astrogrid.applications.beans.v1.WebHttpCall unmarshalWebHttpCall(java.io.Reader reader)
281 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
282 {
283 return (org.astrogrid.applications.beans.v1.WebHttpCall) Unmarshaller.unmarshal(org.astrogrid.applications.beans.v1.WebHttpCall.class, reader);
284 }
285
286 /***
287 * Method validate
288 */
289 public void validate()
290 throws org.exolab.castor.xml.ValidationException
291 {
292 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
293 validator.validate(this);
294 }
295
296 }