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