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
5 * This file is part of Jalview.
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.
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.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.schemabinding.version2;
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
28 * Class WebServiceParameterSet.
30 * @version $Revision$ $Date$
32 public class WebServiceParameterSet implements java.io.Serializable
35 // --------------------------/
36 // - Class/Member Variables -/
37 // --------------------------/
40 * The short name for the parameter set. This will be shown amongst the other
41 * presets for the web service.
44 private java.lang.String _name;
47 * A Jalview Web Service Parameter Set container version number. Version 1
48 * created for storing Jaba user presets.
51 private java.lang.String _version;
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.
59 private java.lang.String _description;
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
67 private java.util.Vector _serviceURLList;
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.
74 private java.lang.String _parameters;
80 public WebServiceParameterSet()
83 this._serviceURLList = new java.util.Vector();
94 * @throws java.lang.IndexOutOfBoundsException
95 * if the index given is outside the bounds of the collection
97 public void addServiceURL(final java.lang.String vServiceURL)
98 throws java.lang.IndexOutOfBoundsException
100 this._serviceURLList.addElement(vServiceURL);
108 * @throws java.lang.IndexOutOfBoundsException
109 * if the index given is outside the bounds of the collection
111 public void addServiceURL(final int index,
112 final java.lang.String vServiceURL)
113 throws java.lang.IndexOutOfBoundsException
115 this._serviceURLList.add(index, vServiceURL);
119 * Method enumerateServiceURL.
121 * @return an Enumeration over all java.lang.String elements
123 public java.util.Enumeration enumerateServiceURL()
125 return this._serviceURLList.elements();
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.
135 * @return the value of field 'Description'.
137 public java.lang.String getDescription()
139 return this._description;
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.
148 * @return the value of field 'Name'.
150 public java.lang.String getName()
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.
162 * @return the value of field 'Parameters'.
164 public java.lang.String getParameters()
166 return this._parameters;
170 * Method getServiceURL.
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
177 public java.lang.String getServiceURL(final int index)
178 throws java.lang.IndexOutOfBoundsException
180 // check bounds for index
181 if (index < 0 || index >= this._serviceURLList.size())
183 throw new IndexOutOfBoundsException("getServiceURL: Index value '"
184 + index + "' not in range [0.."
185 + (this._serviceURLList.size() - 1) + "]");
188 return (java.lang.String) _serviceURLList.get(index);
192 * Method getServiceURL.Returns the contents of the collection in an Array.
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.
198 * @return this collection as an Array
200 public java.lang.String[] getServiceURL()
202 java.lang.String[] array = new java.lang.String[0];
203 return (java.lang.String[]) this._serviceURLList.toArray(array);
207 * Method getServiceURLCount.
209 * @return the size of this collection
211 public int getServiceURLCount()
213 return this._serviceURLList.size();
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.
222 * @return the value of field 'Version'.
224 public java.lang.String getVersion()
226 return this._version;
232 * @return true if this object is valid according to the schema
234 public boolean isValid()
239 } catch (org.exolab.castor.xml.ValidationException vex)
250 * @throws org.exolab.castor.xml.MarshalException
251 * if object is null or if any SAXException is thrown during
253 * @throws org.exolab.castor.xml.ValidationException
254 * if this object is an invalid instance according to the schema
256 public void marshal(final java.io.Writer out)
257 throws org.exolab.castor.xml.MarshalException,
258 org.exolab.castor.xml.ValidationException
260 Marshaller.marshal(this, out);
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
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
280 Marshaller.marshal(this, handler);
285 public void removeAllServiceURL()
287 this._serviceURLList.clear();
291 * Method removeServiceURL.
294 * @return true if the object was removed from the collection.
296 public boolean removeServiceURL(final java.lang.String vServiceURL)
298 boolean removed = _serviceURLList.remove(vServiceURL);
303 * Method removeServiceURLAt.
306 * @return the element removed from the collection
308 public java.lang.String removeServiceURLAt(final int index)
310 java.lang.Object obj = this._serviceURLList.remove(index);
311 return (java.lang.String) obj;
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.
322 * the value of field 'description'.
324 public void setDescription(final java.lang.String description)
326 this._description = description;
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.
336 * the value of field 'name'.
338 public void setName(final java.lang.String name)
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.
351 * the value of field 'parameters'.
353 public void setParameters(final java.lang.String parameters)
355 this._parameters = parameters;
363 * @throws java.lang.IndexOutOfBoundsException
364 * if the index given is outside the bounds of the collection
366 public void setServiceURL(final int index,
367 final java.lang.String vServiceURL)
368 throws java.lang.IndexOutOfBoundsException
370 // check bounds for index
371 if (index < 0 || index >= this._serviceURLList.size())
373 throw new IndexOutOfBoundsException("setServiceURL: Index value '"
374 + index + "' not in range [0.."
375 + (this._serviceURLList.size() - 1) + "]");
378 this._serviceURLList.set(index, vServiceURL);
384 * @param vServiceURLArray
386 public void setServiceURL(final java.lang.String[] vServiceURLArray)
389 _serviceURLList.clear();
391 for (int i = 0; i < vServiceURLArray.length; i++)
393 this._serviceURLList.add(vServiceURLArray[i]);
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.
404 * the value of field 'version'.
406 public void setVersion(final java.lang.String version)
408 this._version = version;
415 * @throws org.exolab.castor.xml.MarshalException
416 * if object is null or if any SAXException is thrown during
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
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
428 return (jalview.schemabinding.version2.WebServiceParameterSet) Unmarshaller
430 jalview.schemabinding.version2.WebServiceParameterSet.class,
437 * @throws org.exolab.castor.xml.ValidationException
438 * if this object is an invalid instance according to the schema
440 public void validate() throws org.exolab.castor.xml.ValidationException
442 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
443 validator.validate(this);