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