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