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