2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10 * of the License, or (at your option) any later version.
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.
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.
21 package jalview.schemabinding.version2;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
33 * Class WebServiceParameterSet.
35 * @version $Revision$ $Date$
37 public class WebServiceParameterSet implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
45 * The short name for the parameter set. This will be shown amongst the other
46 * presets for the web service.
49 private java.lang.String _name;
52 * A Jalview Web Service Parameter Set container version number. Version 1
53 * created for storing Jaba user presets.
56 private java.lang.String _version;
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.
64 private java.lang.String _description;
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
72 private java.util.Vector _serviceURLList;
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.
79 private java.lang.String _parameters;
85 public WebServiceParameterSet()
88 this._serviceURLList = new java.util.Vector();
99 * @throws java.lang.IndexOutOfBoundsException
100 * if the index given is outside the bounds of the collection
102 public void addServiceURL(final java.lang.String vServiceURL)
103 throws java.lang.IndexOutOfBoundsException
105 this._serviceURLList.addElement(vServiceURL);
113 * @throws java.lang.IndexOutOfBoundsException
114 * if the index given is outside the bounds of the collection
116 public void addServiceURL(final int index,
117 final java.lang.String vServiceURL)
118 throws java.lang.IndexOutOfBoundsException
120 this._serviceURLList.add(index, vServiceURL);
124 * Method enumerateServiceURL.
126 * @return an Enumeration over all java.lang.String elements
128 public java.util.Enumeration enumerateServiceURL()
130 return this._serviceURLList.elements();
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.
140 * @return the value of field 'Description'.
142 public java.lang.String getDescription()
144 return this._description;
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.
153 * @return the value of field 'Name'.
155 public java.lang.String getName()
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.
167 * @return the value of field 'Parameters'.
169 public java.lang.String getParameters()
171 return this._parameters;
175 * Method getServiceURL.
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
182 public java.lang.String getServiceURL(final int index)
183 throws java.lang.IndexOutOfBoundsException
185 // check bounds for index
186 if (index < 0 || index >= this._serviceURLList.size())
188 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
190 Integer.valueOf(index).toString(),
191 Integer.valueOf((this._serviceURLList.size() - 1)).toString()
195 return (java.lang.String) _serviceURLList.get(index);
199 * Method getServiceURL.Returns the contents of the collection in an Array.
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.
205 * @return this collection as an Array
207 public java.lang.String[] getServiceURL()
209 java.lang.String[] array = new java.lang.String[0];
210 return (java.lang.String[]) this._serviceURLList.toArray(array);
214 * Method getServiceURLCount.
216 * @return the size of this collection
218 public int getServiceURLCount()
220 return this._serviceURLList.size();
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.
229 * @return the value of field 'Version'.
231 public java.lang.String getVersion()
233 return this._version;
239 * @return true if this object is valid according to the schema
241 public boolean isValid()
246 } catch (org.exolab.castor.xml.ValidationException vex)
257 * @throws org.exolab.castor.xml.MarshalException
258 * if object is null or if any SAXException is thrown during
260 * @throws org.exolab.castor.xml.ValidationException
261 * if this object is an invalid instance according to the schema
263 public void marshal(final java.io.Writer out)
264 throws org.exolab.castor.xml.MarshalException,
265 org.exolab.castor.xml.ValidationException
267 Marshaller.marshal(this, out);
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
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
287 Marshaller.marshal(this, handler);
292 public void removeAllServiceURL()
294 this._serviceURLList.clear();
298 * Method removeServiceURL.
301 * @return true if the object was removed from the collection.
303 public boolean removeServiceURL(final java.lang.String vServiceURL)
305 boolean removed = _serviceURLList.remove(vServiceURL);
310 * Method removeServiceURLAt.
313 * @return the element removed from the collection
315 public java.lang.String removeServiceURLAt(final int index)
317 java.lang.Object obj = this._serviceURLList.remove(index);
318 return (java.lang.String) obj;
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.
329 * the value of field 'description'.
331 public void setDescription(final java.lang.String description)
333 this._description = description;
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.
343 * the value of field 'name'.
345 public void setName(final java.lang.String name)
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.
358 * the value of field 'parameters'.
360 public void setParameters(final java.lang.String parameters)
362 this._parameters = parameters;
370 * @throws java.lang.IndexOutOfBoundsException
371 * if the index given is outside the bounds of the collection
373 public void setServiceURL(final int index,
374 final java.lang.String vServiceURL)
375 throws java.lang.IndexOutOfBoundsException
377 // check bounds for index
378 if (index < 0 || index >= this._serviceURLList.size())
380 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
382 Integer.valueOf(index).toString(),
383 Integer.valueOf((this._serviceURLList.size() - 1)).toString()
387 this._serviceURLList.set(index, vServiceURL);
393 * @param vServiceURLArray
395 public void setServiceURL(final java.lang.String[] vServiceURLArray)
398 _serviceURLList.clear();
400 for (int i = 0; i < vServiceURLArray.length; i++)
402 this._serviceURLList.add(vServiceURLArray[i]);
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.
413 * the value of field 'version'.
415 public void setVersion(final java.lang.String version)
417 this._version = version;
424 * @throws org.exolab.castor.xml.MarshalException
425 * if object is null or if any SAXException is thrown during
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
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
437 return (jalview.schemabinding.version2.WebServiceParameterSet) Unmarshaller
439 jalview.schemabinding.version2.WebServiceParameterSet.class,
446 * @throws org.exolab.castor.xml.ValidationException
447 * if this object is an invalid instance according to the schema
449 public void validate() throws org.exolab.castor.xml.ValidationException
451 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
452 validator.validate(this);