2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.schemabinding.version2;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
29 * Class WebServiceParameterSet.
31 * @version $Revision$ $Date$
33 public class WebServiceParameterSet implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
41 * The short name for the parameter set. This will be shown amongst the other
42 * presets for the web service.
45 private java.lang.String _name;
48 * A Jalview Web Service Parameter Set container version number. Version 1
49 * created for storing Jaba user presets.
52 private java.lang.String _version;
55 * Short description - as utf8 encoded text. This is usually displayed in the
56 * body of an HTML capable tooltip, so HTML tags may be embedded using
57 * standard UTF8 encoding.
60 private java.lang.String _description;
63 * URL for which the parameter set is valid. Jalview will use it to match up
64 * parameter sets to service instances that can parse the parameter set
68 private java.util.Vector _serviceURLList;
71 * UTF8 encoded string to be processed into a specific web services' parameter
72 * set. Note - newlines may be important to the structure of this file.
75 private java.lang.String _parameters;
81 public WebServiceParameterSet()
84 this._serviceURLList = new java.util.Vector();
95 * @throws java.lang.IndexOutOfBoundsException
96 * if the index given is outside the bounds of the collection
98 public void addServiceURL(final java.lang.String vServiceURL)
99 throws java.lang.IndexOutOfBoundsException
101 this._serviceURLList.addElement(vServiceURL);
109 * @throws java.lang.IndexOutOfBoundsException
110 * if the index given is outside the bounds of the collection
112 public void addServiceURL(final int index,
113 final java.lang.String vServiceURL)
114 throws java.lang.IndexOutOfBoundsException
116 this._serviceURLList.add(index, vServiceURL);
120 * Method enumerateServiceURL.
122 * @return an Enumeration over all java.lang.String elements
124 public java.util.Enumeration enumerateServiceURL()
126 return this._serviceURLList.elements();
130 * Returns the value of field 'description'. The field 'description' has the
131 * following description: Short description - as utf8 encoded text. This is
132 * usually displayed in the body of an HTML capable tooltip, so HTML tags may
133 * be embedded using standard UTF8 encoding.
136 * @return the value of field 'Description'.
138 public java.lang.String getDescription()
140 return this._description;
144 * Returns the value of field 'name'. The field 'name' has the following
145 * description: The short name for the parameter set. This will be shown
146 * amongst the other presets for the web service.
149 * @return the value of field 'Name'.
151 public java.lang.String getName()
157 * Returns the value of field 'parameters'. The field 'parameters' has the
158 * following description: UTF8 encoded string to be processed into a specific
159 * web services' parameter set. Note - newlines may be important to the
160 * structure of this file.
163 * @return the value of field 'Parameters'.
165 public java.lang.String getParameters()
167 return this._parameters;
171 * Method getServiceURL.
174 * @throws java.lang.IndexOutOfBoundsException
175 * if the index given is outside the bounds of the collection
176 * @return the value of the java.lang.String at the given index
178 public java.lang.String getServiceURL(final int index)
179 throws java.lang.IndexOutOfBoundsException
181 // check bounds for index
182 if (index < 0 || index >= this._serviceURLList.size())
184 throw new IndexOutOfBoundsException("getServiceURL: Index value '"
185 + index + "' not in range [0.."
186 + (this._serviceURLList.size() - 1) + "]");
189 return (java.lang.String) _serviceURLList.get(index);
193 * Method getServiceURL.Returns the contents of the collection in an Array.
195 * Note: Just in case the collection contents are changing in another thread,
196 * we pass a 0-length Array of the correct type into the API call. This way we
197 * <i>know</i> that the Array returned is of exactly the correct length.
199 * @return this collection as an Array
201 public java.lang.String[] getServiceURL()
203 java.lang.String[] array = new java.lang.String[0];
204 return (java.lang.String[]) this._serviceURLList.toArray(array);
208 * Method getServiceURLCount.
210 * @return the size of this collection
212 public int getServiceURLCount()
214 return this._serviceURLList.size();
218 * Returns the value of field 'version'. The field 'version' has the following
219 * description: A Jalview Web Service Parameter Set container version number.
220 * Version 1 created for storing Jaba user presets.
223 * @return the value of field 'Version'.
225 public java.lang.String getVersion()
227 return this._version;
233 * @return true if this object is valid according to the schema
235 public boolean isValid()
240 } catch (org.exolab.castor.xml.ValidationException vex)
251 * @throws org.exolab.castor.xml.MarshalException
252 * if object is null or if any SAXException is thrown during
254 * @throws org.exolab.castor.xml.ValidationException
255 * if this object is an invalid instance according to the schema
257 public void marshal(final java.io.Writer out)
258 throws org.exolab.castor.xml.MarshalException,
259 org.exolab.castor.xml.ValidationException
261 Marshaller.marshal(this, out);
268 * @throws java.io.IOException
269 * if an IOException occurs during marshaling
270 * @throws org.exolab.castor.xml.ValidationException
271 * if this object is an invalid instance according to the schema
272 * @throws org.exolab.castor.xml.MarshalException
273 * if object is null or if any SAXException is thrown during
276 public void marshal(final org.xml.sax.ContentHandler handler)
277 throws java.io.IOException,
278 org.exolab.castor.xml.MarshalException,
279 org.exolab.castor.xml.ValidationException
281 Marshaller.marshal(this, handler);
286 public void removeAllServiceURL()
288 this._serviceURLList.clear();
292 * Method removeServiceURL.
295 * @return true if the object was removed from the collection.
297 public boolean removeServiceURL(final java.lang.String vServiceURL)
299 boolean removed = _serviceURLList.remove(vServiceURL);
304 * Method removeServiceURLAt.
307 * @return the element removed from the collection
309 public java.lang.String removeServiceURLAt(final int index)
311 java.lang.Object obj = this._serviceURLList.remove(index);
312 return (java.lang.String) obj;
316 * Sets the value of field 'description'. The field 'description' has the
317 * following description: Short description - as utf8 encoded text. This is
318 * usually displayed in the body of an HTML capable tooltip, so HTML tags may
319 * be embedded using standard UTF8 encoding.
323 * the value of field 'description'.
325 public void setDescription(final java.lang.String description)
327 this._description = description;
331 * Sets the value of field 'name'. The field 'name' has the following
332 * description: The short name for the parameter set. This will be shown
333 * amongst the other presets for the web service.
337 * the value of field 'name'.
339 public void setName(final java.lang.String name)
345 * Sets the value of field 'parameters'. The field 'parameters' has the
346 * following description: UTF8 encoded string to be processed into a specific
347 * web services' parameter set. Note - newlines may be important to the
348 * structure of this file.
352 * the value of field 'parameters'.
354 public void setParameters(final java.lang.String parameters)
356 this._parameters = parameters;
364 * @throws java.lang.IndexOutOfBoundsException
365 * if the index given is outside the bounds of the collection
367 public void setServiceURL(final int index,
368 final java.lang.String vServiceURL)
369 throws java.lang.IndexOutOfBoundsException
371 // check bounds for index
372 if (index < 0 || index >= this._serviceURLList.size())
374 throw new IndexOutOfBoundsException("setServiceURL: Index value '"
375 + index + "' not in range [0.."
376 + (this._serviceURLList.size() - 1) + "]");
379 this._serviceURLList.set(index, vServiceURL);
385 * @param vServiceURLArray
387 public void setServiceURL(final java.lang.String[] vServiceURLArray)
390 _serviceURLList.clear();
392 for (int i = 0; i < vServiceURLArray.length; i++)
394 this._serviceURLList.add(vServiceURLArray[i]);
399 * Sets the value of field 'version'. The field 'version' has the following
400 * description: A Jalview Web Service Parameter Set container version number.
401 * Version 1 created for storing Jaba user presets.
405 * the value of field 'version'.
407 public void setVersion(final java.lang.String version)
409 this._version = version;
416 * @throws org.exolab.castor.xml.MarshalException
417 * if object is null or if any SAXException is thrown during
419 * @throws org.exolab.castor.xml.ValidationException
420 * if this object is an invalid instance according to the schema
421 * @return the unmarshaled
422 * jalview.schemabinding.version2.WebServiceParameterSet
424 public static jalview.schemabinding.version2.WebServiceParameterSet unmarshal(
425 final java.io.Reader reader)
426 throws org.exolab.castor.xml.MarshalException,
427 org.exolab.castor.xml.ValidationException
429 return (jalview.schemabinding.version2.WebServiceParameterSet) Unmarshaller
431 jalview.schemabinding.version2.WebServiceParameterSet.class,
438 * @throws org.exolab.castor.xml.ValidationException
439 * if this object is an invalid instance according to the schema
441 public void validate() throws org.exolab.castor.xml.ValidationException
443 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
444 validator.validate(this);