1
2
3
4
5
6
7
8 package org.astrogrid.registry.beans.v10.resource.dataservice;
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.astrogrid.registry.beans.v10.resource.dataservice.types.HTTPQueryType;
21 import org.exolab.castor.xml.MarshalException;
22 import org.exolab.castor.xml.Marshaller;
23 import org.exolab.castor.xml.Unmarshaller;
24 import org.exolab.castor.xml.ValidationException;
25 import org.xml.sax.ContentHandler;
26
27 /***
28 * A service invoked via an HTTP Query (either Get or Post)
29 * with a set of arguments consisting of keyword name-value pairs.
30 *
31 * Note that the URL for help with this service can be put into
32 * the Service/ReferenceURL element.
33 *
34 *
35 * @version $Revision: 1.2 $ $Date: 2007/01/04 16:26:25 $
36 */
37 public class ParamHTTP extends org.astrogrid.registry.beans.v10.resource.Interface
38 implements java.io.Serializable
39 {
40
41
42
43
44
45
46 /***
47 * The type of HTTP request, either GET or POST.
48 *
49 */
50 private org.astrogrid.registry.beans.v10.resource.dataservice.types.HTTPQueryType _qtype;
51
52 /***
53 * The MIME type of a document returned by an HTTP Get.
54 *
55 */
56 private java.lang.String _resultType;
57
58 /***
59 * a description of a input parameter. Each should be
60 * rendered as name=value in the query URL's arguements.
61 *
62 */
63 private java.util.ArrayList _paramList;
64
65
66
67
68
69
70 public ParamHTTP() {
71 super();
72 _paramList = new ArrayList();
73 }
74
75
76
77
78
79
80 /***
81 * Method addParam
82 *
83 * @param vParam
84 */
85 public void addParam(org.astrogrid.registry.beans.v10.resource.dataservice.Param vParam)
86 throws java.lang.IndexOutOfBoundsException
87 {
88 _paramList.add(vParam);
89 }
90
91 /***
92 * Method addParam
93 *
94 * @param index
95 * @param vParam
96 */
97 public void addParam(int index, org.astrogrid.registry.beans.v10.resource.dataservice.Param vParam)
98 throws java.lang.IndexOutOfBoundsException
99 {
100 _paramList.add(index, vParam);
101 }
102
103 /***
104 * Method clearParam
105 */
106 public void clearParam()
107 {
108 _paramList.clear();
109 }
110
111 /***
112 * Method enumerateParam
113 */
114 public java.util.Enumeration enumerateParam()
115 {
116 return new org.exolab.castor.util.IteratorEnumeration(_paramList.iterator());
117 }
118
119 /***
120 * Note: hashCode() has not been overriden
121 *
122 * @param obj
123 */
124 public boolean equals(java.lang.Object obj)
125 {
126 if ( this == obj )
127 return true;
128
129 if (super.equals(obj)==false)
130 return false;
131
132 if (obj instanceof ParamHTTP) {
133
134 ParamHTTP temp = (ParamHTTP)obj;
135 if (this._qtype != null) {
136 if (temp._qtype == null) return false;
137 else if (!(this._qtype.equals(temp._qtype)))
138 return false;
139 }
140 else if (temp._qtype != null)
141 return false;
142 if (this._resultType != null) {
143 if (temp._resultType == null) return false;
144 else if (!(this._resultType.equals(temp._resultType)))
145 return false;
146 }
147 else if (temp._resultType != null)
148 return false;
149 if (this._paramList != null) {
150 if (temp._paramList == null) return false;
151 else if (!(this._paramList.equals(temp._paramList)))
152 return false;
153 }
154 else if (temp._paramList != null)
155 return false;
156 return true;
157 }
158 return false;
159 }
160
161 /***
162 * Method getParam
163 *
164 * @param index
165 */
166 public org.astrogrid.registry.beans.v10.resource.dataservice.Param getParam(int index)
167 throws java.lang.IndexOutOfBoundsException
168 {
169
170 if ((index < 0) || (index > _paramList.size())) {
171 throw new IndexOutOfBoundsException();
172 }
173
174 return (org.astrogrid.registry.beans.v10.resource.dataservice.Param) _paramList.get(index);
175 }
176
177 /***
178 * Method getParam
179 */
180 public org.astrogrid.registry.beans.v10.resource.dataservice.Param[] getParam()
181 {
182 int size = _paramList.size();
183 org.astrogrid.registry.beans.v10.resource.dataservice.Param[] mArray = new org.astrogrid.registry.beans.v10.resource.dataservice.Param[size];
184 for (int index = 0; index < size; index++) {
185 mArray[index] = (org.astrogrid.registry.beans.v10.resource.dataservice.Param) _paramList.get(index);
186 }
187 return mArray;
188 }
189
190 /***
191 * Method getParamCount
192 */
193 public int getParamCount()
194 {
195 return _paramList.size();
196 }
197
198 /***
199 * Returns the value of field 'qtype'. The field 'qtype' has
200 * the following description: The type of HTTP request, either
201 * GET or POST.
202 *
203 *
204 * @return the value of field 'qtype'.
205 */
206 public org.astrogrid.registry.beans.v10.resource.dataservice.types.HTTPQueryType getQtype()
207 {
208 return this._qtype;
209 }
210
211 /***
212 * Returns the value of field 'resultType'. The field
213 * 'resultType' has the following description: The MIME type of
214 * a document returned by an HTTP Get.
215 *
216 *
217 * @return the value of field 'resultType'.
218 */
219 public java.lang.String getResultType()
220 {
221 return this._resultType;
222 }
223
224 /***
225 * Method isValid
226 */
227 public boolean isValid()
228 {
229 try {
230 validate();
231 }
232 catch (org.exolab.castor.xml.ValidationException vex) {
233 return false;
234 }
235 return true;
236 }
237
238 /***
239 * Method marshal
240 *
241 * @param out
242 */
243 public void marshal(java.io.Writer out)
244 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
245 {
246
247 Marshaller.marshal(this, out);
248 }
249
250 /***
251 * Method marshal
252 *
253 * @param handler
254 */
255 public void marshal(org.xml.sax.ContentHandler handler)
256 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
257 {
258
259 Marshaller.marshal(this, handler);
260 }
261
262 /***
263 * Method removeParam
264 *
265 * @param vParam
266 */
267 public boolean removeParam(org.astrogrid.registry.beans.v10.resource.dataservice.Param vParam)
268 {
269 boolean removed = _paramList.remove(vParam);
270 return removed;
271 }
272
273 /***
274 * Method setParam
275 *
276 * @param index
277 * @param vParam
278 */
279 public void setParam(int index, org.astrogrid.registry.beans.v10.resource.dataservice.Param vParam)
280 throws java.lang.IndexOutOfBoundsException
281 {
282
283 if ((index < 0) || (index > _paramList.size())) {
284 throw new IndexOutOfBoundsException();
285 }
286 _paramList.set(index, vParam);
287 }
288
289 /***
290 * Method setParam
291 *
292 * @param paramArray
293 */
294 public void setParam(org.astrogrid.registry.beans.v10.resource.dataservice.Param[] paramArray)
295 {
296
297 _paramList.clear();
298 for (int i = 0; i < paramArray.length; i++) {
299 _paramList.add(paramArray[i]);
300 }
301 }
302
303 /***
304 * Sets the value of field 'qtype'. The field 'qtype' has the
305 * following description: The type of HTTP request, either GET
306 * or POST.
307 *
308 *
309 * @param qtype the value of field 'qtype'.
310 */
311 public void setQtype(org.astrogrid.registry.beans.v10.resource.dataservice.types.HTTPQueryType qtype)
312 {
313 this._qtype = qtype;
314 }
315
316 /***
317 * Sets the value of field 'resultType'. The field 'resultType'
318 * has the following description: The MIME type of a document
319 * returned by an HTTP Get.
320 *
321 *
322 * @param resultType the value of field 'resultType'.
323 */
324 public void setResultType(java.lang.String resultType)
325 {
326 this._resultType = resultType;
327 }
328
329 /***
330 * Method unmarshalParamHTTP
331 *
332 * @param reader
333 */
334 public static org.astrogrid.registry.beans.v10.resource.dataservice.ParamHTTP unmarshalParamHTTP(java.io.Reader reader)
335 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
336 {
337 return (org.astrogrid.registry.beans.v10.resource.dataservice.ParamHTTP) Unmarshaller.unmarshal(org.astrogrid.registry.beans.v10.resource.dataservice.ParamHTTP.class, reader);
338 }
339
340 /***
341 * Method validate
342 */
343 public void validate()
344 throws org.exolab.castor.xml.ValidationException
345 {
346 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
347 validator.validate(this);
348 }
349
350 }