0283bef8e350a58798154e4fd0c5b01bf508de02
[jalview.git] / src / jalview / schemabinding / version2 / WebServiceParameterSet.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3  * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  *  
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.schemabinding.version2;
19
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
23
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
26
27 /**
28  * Class WebServiceParameterSet.
29  * 
30  * @version $Revision$ $Date$
31  */
32 public class WebServiceParameterSet implements java.io.Serializable
33 {
34
35   // --------------------------/
36   // - Class/Member Variables -/
37   // --------------------------/
38
39   /**
40    * The short name for the parameter set. This will be shown amongst the other
41    * presets for the web service.
42    * 
43    */
44   private java.lang.String _name;
45
46   /**
47    * A Jalview Web Service Parameter Set container version number. Version 1
48    * created for storing Jaba user presets.
49    * 
50    */
51   private java.lang.String _version;
52
53   /**
54    * Short description - as utf8 encoded text. This is usually displayed in the
55    * body of an HTML capable tooltip, so HTML tags may be embedded using
56    * standard UTF8 encoding.
57    * 
58    */
59   private java.lang.String _description;
60
61   /**
62    * URL for which the parameter set is valid. Jalview will use it to match up
63    * parameter sets to service instances that can parse the parameter set
64    * payload.
65    * 
66    */
67   private java.util.Vector _serviceURLList;
68
69   /**
70    * UTF8 encoded string to be processed into a specific web services' parameter
71    * set. Note - newlines may be important to the structure of this file.
72    * 
73    */
74   private java.lang.String _parameters;
75
76   // ----------------/
77   // - Constructors -/
78   // ----------------/
79
80   public WebServiceParameterSet()
81   {
82     super();
83     this._serviceURLList = new java.util.Vector();
84   }
85
86   // -----------/
87   // - Methods -/
88   // -----------/
89
90   /**
91    * 
92    * 
93    * @param vServiceURL
94    * @throws java.lang.IndexOutOfBoundsException
95    *           if the index given is outside the bounds of the collection
96    */
97   public void addServiceURL(final java.lang.String vServiceURL)
98           throws java.lang.IndexOutOfBoundsException
99   {
100     this._serviceURLList.addElement(vServiceURL);
101   }
102
103   /**
104    * 
105    * 
106    * @param index
107    * @param vServiceURL
108    * @throws java.lang.IndexOutOfBoundsException
109    *           if the index given is outside the bounds of the collection
110    */
111   public void addServiceURL(final int index,
112           final java.lang.String vServiceURL)
113           throws java.lang.IndexOutOfBoundsException
114   {
115     this._serviceURLList.add(index, vServiceURL);
116   }
117
118   /**
119    * Method enumerateServiceURL.
120    * 
121    * @return an Enumeration over all java.lang.String elements
122    */
123   public java.util.Enumeration enumerateServiceURL()
124   {
125     return this._serviceURLList.elements();
126   }
127
128   /**
129    * Returns the value of field 'description'. The field 'description' has the
130    * following description: Short description - as utf8 encoded text. This is
131    * usually displayed in the body of an HTML capable tooltip, so HTML tags may
132    * be embedded using standard UTF8 encoding.
133    * 
134    * 
135    * @return the value of field 'Description'.
136    */
137   public java.lang.String getDescription()
138   {
139     return this._description;
140   }
141
142   /**
143    * Returns the value of field 'name'. The field 'name' has the following
144    * description: The short name for the parameter set. This will be shown
145    * amongst the other presets for the web service.
146    * 
147    * 
148    * @return the value of field 'Name'.
149    */
150   public java.lang.String getName()
151   {
152     return this._name;
153   }
154
155   /**
156    * Returns the value of field 'parameters'. The field 'parameters' has the
157    * following description: UTF8 encoded string to be processed into a specific
158    * web services' parameter set. Note - newlines may be important to the
159    * structure of this file.
160    * 
161    * 
162    * @return the value of field 'Parameters'.
163    */
164   public java.lang.String getParameters()
165   {
166     return this._parameters;
167   }
168
169   /**
170    * Method getServiceURL.
171    * 
172    * @param index
173    * @throws java.lang.IndexOutOfBoundsException
174    *           if the index given is outside the bounds of the collection
175    * @return the value of the java.lang.String at the given index
176    */
177   public java.lang.String getServiceURL(final int index)
178           throws java.lang.IndexOutOfBoundsException
179   {
180     // check bounds for index
181     if (index < 0 || index >= this._serviceURLList.size())
182     {
183       throw new IndexOutOfBoundsException("getServiceURL: Index value '"
184               + index + "' not in range [0.."
185               + (this._serviceURLList.size() - 1) + "]");
186     }
187
188     return (java.lang.String) _serviceURLList.get(index);
189   }
190
191   /**
192    * Method getServiceURL.Returns the contents of the collection in an Array.
193    * <p>
194    * Note: Just in case the collection contents are changing in another thread,
195    * we pass a 0-length Array of the correct type into the API call. This way we
196    * <i>know</i> that the Array returned is of exactly the correct length.
197    * 
198    * @return this collection as an Array
199    */
200   public java.lang.String[] getServiceURL()
201   {
202     java.lang.String[] array = new java.lang.String[0];
203     return (java.lang.String[]) this._serviceURLList.toArray(array);
204   }
205
206   /**
207    * Method getServiceURLCount.
208    * 
209    * @return the size of this collection
210    */
211   public int getServiceURLCount()
212   {
213     return this._serviceURLList.size();
214   }
215
216   /**
217    * Returns the value of field 'version'. The field 'version' has the following
218    * description: A Jalview Web Service Parameter Set container version number.
219    * Version 1 created for storing Jaba user presets.
220    * 
221    * 
222    * @return the value of field 'Version'.
223    */
224   public java.lang.String getVersion()
225   {
226     return this._version;
227   }
228
229   /**
230    * Method isValid.
231    * 
232    * @return true if this object is valid according to the schema
233    */
234   public boolean isValid()
235   {
236     try
237     {
238       validate();
239     } catch (org.exolab.castor.xml.ValidationException vex)
240     {
241       return false;
242     }
243     return true;
244   }
245
246   /**
247    * 
248    * 
249    * @param out
250    * @throws org.exolab.castor.xml.MarshalException
251    *           if object is null or if any SAXException is thrown during
252    *           marshaling
253    * @throws org.exolab.castor.xml.ValidationException
254    *           if this object is an invalid instance according to the schema
255    */
256   public void marshal(final java.io.Writer out)
257           throws org.exolab.castor.xml.MarshalException,
258           org.exolab.castor.xml.ValidationException
259   {
260     Marshaller.marshal(this, out);
261   }
262
263   /**
264    * 
265    * 
266    * @param handler
267    * @throws java.io.IOException
268    *           if an IOException occurs during marshaling
269    * @throws org.exolab.castor.xml.ValidationException
270    *           if this object is an invalid instance according to the schema
271    * @throws org.exolab.castor.xml.MarshalException
272    *           if object is null or if any SAXException is thrown during
273    *           marshaling
274    */
275   public void marshal(final org.xml.sax.ContentHandler handler)
276           throws java.io.IOException,
277           org.exolab.castor.xml.MarshalException,
278           org.exolab.castor.xml.ValidationException
279   {
280     Marshaller.marshal(this, handler);
281   }
282
283   /**
284      */
285   public void removeAllServiceURL()
286   {
287     this._serviceURLList.clear();
288   }
289
290   /**
291    * Method removeServiceURL.
292    * 
293    * @param vServiceURL
294    * @return true if the object was removed from the collection.
295    */
296   public boolean removeServiceURL(final java.lang.String vServiceURL)
297   {
298     boolean removed = _serviceURLList.remove(vServiceURL);
299     return removed;
300   }
301
302   /**
303    * Method removeServiceURLAt.
304    * 
305    * @param index
306    * @return the element removed from the collection
307    */
308   public java.lang.String removeServiceURLAt(final int index)
309   {
310     java.lang.Object obj = this._serviceURLList.remove(index);
311     return (java.lang.String) obj;
312   }
313
314   /**
315    * Sets the value of field 'description'. The field 'description' has the
316    * following description: Short description - as utf8 encoded text. This is
317    * usually displayed in the body of an HTML capable tooltip, so HTML tags may
318    * be embedded using standard UTF8 encoding.
319    * 
320    * 
321    * @param description
322    *          the value of field 'description'.
323    */
324   public void setDescription(final java.lang.String description)
325   {
326     this._description = description;
327   }
328
329   /**
330    * Sets the value of field 'name'. The field 'name' has the following
331    * description: The short name for the parameter set. This will be shown
332    * amongst the other presets for the web service.
333    * 
334    * 
335    * @param name
336    *          the value of field 'name'.
337    */
338   public void setName(final java.lang.String name)
339   {
340     this._name = name;
341   }
342
343   /**
344    * Sets the value of field 'parameters'. The field 'parameters' has the
345    * following description: UTF8 encoded string to be processed into a specific
346    * web services' parameter set. Note - newlines may be important to the
347    * structure of this file.
348    * 
349    * 
350    * @param parameters
351    *          the value of field 'parameters'.
352    */
353   public void setParameters(final java.lang.String parameters)
354   {
355     this._parameters = parameters;
356   }
357
358   /**
359    * 
360    * 
361    * @param index
362    * @param vServiceURL
363    * @throws java.lang.IndexOutOfBoundsException
364    *           if the index given is outside the bounds of the collection
365    */
366   public void setServiceURL(final int index,
367           final java.lang.String vServiceURL)
368           throws java.lang.IndexOutOfBoundsException
369   {
370     // check bounds for index
371     if (index < 0 || index >= this._serviceURLList.size())
372     {
373       throw new IndexOutOfBoundsException("setServiceURL: Index value '"
374               + index + "' not in range [0.."
375               + (this._serviceURLList.size() - 1) + "]");
376     }
377
378     this._serviceURLList.set(index, vServiceURL);
379   }
380
381   /**
382    * 
383    * 
384    * @param vServiceURLArray
385    */
386   public void setServiceURL(final java.lang.String[] vServiceURLArray)
387   {
388     // -- copy array
389     _serviceURLList.clear();
390
391     for (int i = 0; i < vServiceURLArray.length; i++)
392     {
393       this._serviceURLList.add(vServiceURLArray[i]);
394     }
395   }
396
397   /**
398    * Sets the value of field 'version'. The field 'version' has the following
399    * description: A Jalview Web Service Parameter Set container version number.
400    * Version 1 created for storing Jaba user presets.
401    * 
402    * 
403    * @param version
404    *          the value of field 'version'.
405    */
406   public void setVersion(final java.lang.String version)
407   {
408     this._version = version;
409   }
410
411   /**
412    * Method unmarshal.
413    * 
414    * @param reader
415    * @throws org.exolab.castor.xml.MarshalException
416    *           if object is null or if any SAXException is thrown during
417    *           marshaling
418    * @throws org.exolab.castor.xml.ValidationException
419    *           if this object is an invalid instance according to the schema
420    * @return the unmarshaled
421    *         jalview.schemabinding.version2.WebServiceParameterSet
422    */
423   public static jalview.schemabinding.version2.WebServiceParameterSet unmarshal(
424           final java.io.Reader reader)
425           throws org.exolab.castor.xml.MarshalException,
426           org.exolab.castor.xml.ValidationException
427   {
428     return (jalview.schemabinding.version2.WebServiceParameterSet) Unmarshaller
429             .unmarshal(
430                     jalview.schemabinding.version2.WebServiceParameterSet.class,
431                     reader);
432   }
433
434   /**
435    * 
436    * 
437    * @throws org.exolab.castor.xml.ValidationException
438    *           if this object is an invalid instance according to the schema
439    */
440   public void validate() throws org.exolab.castor.xml.ValidationException
441   {
442     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
443     validator.validate(this);
444   }
445
446 }