2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
\r
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.schemabinding.version2;
\r
20 //---------------------------------/
\r
21 //- Imported classes and packages -/
\r
22 //---------------------------------/
\r
24 import org.exolab.castor.xml.Marshaller;
\r
25 import org.exolab.castor.xml.Unmarshaller;
\r
30 * @version $Revision$ $Date$
\r
32 public class Feature implements java.io.Serializable
\r
35 // --------------------------/
\r
36 // - Class/Member Variables -/
\r
37 // --------------------------/
\r
45 * keeps track of state for field: _begin
\r
47 private boolean _has_begin;
\r
55 * keeps track of state for field: _end
\r
57 private boolean _has_end;
\r
62 private java.lang.String _type;
\r
65 * Field _description.
\r
67 private java.lang.String _description;
\r
72 private java.lang.String _status;
\r
75 * Field _featureGroup.
\r
77 private java.lang.String _featureGroup;
\r
82 private float _score;
\r
85 * keeps track of state for field: _score
\r
87 private boolean _has_score;
\r
90 * Field _otherDataList.
\r
92 private java.util.Vector _otherDataList;
\r
94 // ----------------/
\r
95 // - Constructors -/
\r
96 // ----------------/
\r
101 this._otherDataList = new java.util.Vector();
\r
111 * @param vOtherData
\r
112 * @throws java.lang.IndexOutOfBoundsException
\r
113 * if the index given is outside the bounds of the collection
\r
115 public void addOtherData(
\r
116 final jalview.schemabinding.version2.OtherData vOtherData)
\r
117 throws java.lang.IndexOutOfBoundsException
\r
119 this._otherDataList.addElement(vOtherData);
\r
126 * @param vOtherData
\r
127 * @throws java.lang.IndexOutOfBoundsException
\r
128 * if the index given is outside the bounds of the collection
\r
130 public void addOtherData(final int index,
\r
131 final jalview.schemabinding.version2.OtherData vOtherData)
\r
132 throws java.lang.IndexOutOfBoundsException
\r
134 this._otherDataList.add(index, vOtherData);
\r
139 public void deleteBegin()
\r
141 this._has_begin = false;
\r
146 public void deleteEnd()
\r
148 this._has_end = false;
\r
153 public void deleteScore()
\r
155 this._has_score = false;
\r
159 * Method enumerateOtherData.
\r
161 * @return an Enumeration over all jalview.schemabinding.version2.OtherData
\r
164 public java.util.Enumeration enumerateOtherData()
\r
166 return this._otherDataList.elements();
\r
170 * Returns the value of field 'begin'.
\r
172 * @return the value of field 'Begin'.
\r
174 public int getBegin()
\r
176 return this._begin;
\r
180 * Returns the value of field 'description'.
\r
182 * @return the value of field 'Description'.
\r
184 public java.lang.String getDescription()
\r
186 return this._description;
\r
190 * Returns the value of field 'end'.
\r
192 * @return the value of field 'End'.
\r
194 public int getEnd()
\r
200 * Returns the value of field 'featureGroup'.
\r
202 * @return the value of field 'FeatureGroup'.
\r
204 public java.lang.String getFeatureGroup()
\r
206 return this._featureGroup;
\r
210 * Method getOtherData.
\r
213 * @throws java.lang.IndexOutOfBoundsException
\r
214 * if the index given is outside the bounds of the collection
\r
215 * @return the value of the jalview.schemabinding.version2.OtherData at the
\r
218 public jalview.schemabinding.version2.OtherData getOtherData(
\r
219 final int index) throws java.lang.IndexOutOfBoundsException
\r
221 // check bounds for index
\r
222 if (index < 0 || index >= this._otherDataList.size())
\r
224 throw new IndexOutOfBoundsException("getOtherData: Index value '"
\r
225 + index + "' not in range [0.."
\r
226 + (this._otherDataList.size() - 1) + "]");
\r
229 return (jalview.schemabinding.version2.OtherData) _otherDataList
\r
234 * Method getOtherData.Returns the contents of the collection in an Array.
\r
236 * Note: Just in case the collection contents are changing in another thread,
\r
237 * we pass a 0-length Array of the correct type into the API call. This way we
\r
238 * <i>know</i> that the Array returned is of exactly the correct length.
\r
240 * @return this collection as an Array
\r
242 public jalview.schemabinding.version2.OtherData[] getOtherData()
\r
244 jalview.schemabinding.version2.OtherData[] array = new jalview.schemabinding.version2.OtherData[0];
\r
245 return (jalview.schemabinding.version2.OtherData[]) this._otherDataList
\r
250 * Method getOtherDataCount.
\r
252 * @return the size of this collection
\r
254 public int getOtherDataCount()
\r
256 return this._otherDataList.size();
\r
260 * Returns the value of field 'score'.
\r
262 * @return the value of field 'Score'.
\r
264 public float getScore()
\r
266 return this._score;
\r
270 * Returns the value of field 'status'.
\r
272 * @return the value of field 'Status'.
\r
274 public java.lang.String getStatus()
\r
276 return this._status;
\r
280 * Returns the value of field 'type'.
\r
282 * @return the value of field 'Type'.
\r
284 public java.lang.String getType()
\r
292 * @return true if at least one Begin has been added
\r
294 public boolean hasBegin()
\r
296 return this._has_begin;
\r
302 * @return true if at least one End has been added
\r
304 public boolean hasEnd()
\r
306 return this._has_end;
\r
312 * @return true if at least one Score has been added
\r
314 public boolean hasScore()
\r
316 return this._has_score;
\r
322 * @return true if this object is valid according to the schema
\r
324 public boolean isValid()
\r
329 } catch (org.exolab.castor.xml.ValidationException vex)
\r
340 * @throws org.exolab.castor.xml.MarshalException
\r
341 * if object is null or if any SAXException is thrown during
\r
343 * @throws org.exolab.castor.xml.ValidationException
\r
344 * if this object is an invalid instance according to the schema
\r
346 public void marshal(final java.io.Writer out)
\r
347 throws org.exolab.castor.xml.MarshalException,
\r
348 org.exolab.castor.xml.ValidationException
\r
350 Marshaller.marshal(this, out);
\r
357 * @throws java.io.IOException
\r
358 * if an IOException occurs during marshaling
\r
359 * @throws org.exolab.castor.xml.ValidationException
\r
360 * if this object is an invalid instance according to the schema
\r
361 * @throws org.exolab.castor.xml.MarshalException
\r
362 * if object is null or if any SAXException is thrown during
\r
365 public void marshal(final org.xml.sax.ContentHandler handler)
\r
366 throws java.io.IOException,
\r
367 org.exolab.castor.xml.MarshalException,
\r
368 org.exolab.castor.xml.ValidationException
\r
370 Marshaller.marshal(this, handler);
\r
375 public void removeAllOtherData()
\r
377 this._otherDataList.clear();
\r
381 * Method removeOtherData.
\r
383 * @param vOtherData
\r
384 * @return true if the object was removed from the collection.
\r
386 public boolean removeOtherData(
\r
387 final jalview.schemabinding.version2.OtherData vOtherData)
\r
389 boolean removed = _otherDataList.remove(vOtherData);
\r
394 * Method removeOtherDataAt.
\r
397 * @return the element removed from the collection
\r
399 public jalview.schemabinding.version2.OtherData removeOtherDataAt(
\r
402 java.lang.Object obj = this._otherDataList.remove(index);
\r
403 return (jalview.schemabinding.version2.OtherData) obj;
\r
407 * Sets the value of field 'begin'.
\r
410 * the value of field 'begin'.
\r
412 public void setBegin(final int begin)
\r
414 this._begin = begin;
\r
415 this._has_begin = true;
\r
419 * Sets the value of field 'description'.
\r
421 * @param description
\r
422 * the value of field 'description'.
\r
424 public void setDescription(final java.lang.String description)
\r
426 this._description = description;
\r
430 * Sets the value of field 'end'.
\r
433 * the value of field 'end'.
\r
435 public void setEnd(final int end)
\r
438 this._has_end = true;
\r
442 * Sets the value of field 'featureGroup'.
\r
444 * @param featureGroup
\r
445 * the value of field 'featureGroup'.
\r
447 public void setFeatureGroup(final java.lang.String featureGroup)
\r
449 this._featureGroup = featureGroup;
\r
456 * @param vOtherData
\r
457 * @throws java.lang.IndexOutOfBoundsException
\r
458 * if the index given is outside the bounds of the collection
\r
460 public void setOtherData(final int index,
\r
461 final jalview.schemabinding.version2.OtherData vOtherData)
\r
462 throws java.lang.IndexOutOfBoundsException
\r
464 // check bounds for index
\r
465 if (index < 0 || index >= this._otherDataList.size())
\r
467 throw new IndexOutOfBoundsException("setOtherData: Index value '"
\r
468 + index + "' not in range [0.."
\r
469 + (this._otherDataList.size() - 1) + "]");
\r
472 this._otherDataList.set(index, vOtherData);
\r
478 * @param vOtherDataArray
\r
480 public void setOtherData(
\r
481 final jalview.schemabinding.version2.OtherData[] vOtherDataArray)
\r
484 _otherDataList.clear();
\r
486 for (int i = 0; i < vOtherDataArray.length; i++)
\r
488 this._otherDataList.add(vOtherDataArray[i]);
\r
493 * Sets the value of field 'score'.
\r
496 * the value of field 'score'.
\r
498 public void setScore(final float score)
\r
500 this._score = score;
\r
501 this._has_score = true;
\r
505 * Sets the value of field 'status'.
\r
508 * the value of field 'status'.
\r
510 public void setStatus(final java.lang.String status)
\r
512 this._status = status;
\r
516 * Sets the value of field 'type'.
\r
519 * the value of field 'type'.
\r
521 public void setType(final java.lang.String type)
\r
527 * Method unmarshal.
\r
530 * @throws org.exolab.castor.xml.MarshalException
\r
531 * if object is null or if any SAXException is thrown during
\r
533 * @throws org.exolab.castor.xml.ValidationException
\r
534 * if this object is an invalid instance according to the schema
\r
535 * @return the unmarshaled jalview.schemabinding.version2.Featur
\r
537 public static jalview.schemabinding.version2.Feature unmarshal(
\r
538 final java.io.Reader reader)
\r
539 throws org.exolab.castor.xml.MarshalException,
\r
540 org.exolab.castor.xml.ValidationException
\r
542 return (jalview.schemabinding.version2.Feature) Unmarshaller.unmarshal(
\r
543 jalview.schemabinding.version2.Feature.class, reader);
\r
549 * @throws org.exolab.castor.xml.ValidationException
\r
550 * if this object is an invalid instance according to the schema
\r
552 public void validate() throws org.exolab.castor.xml.ValidationException
\r
554 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
555 validator.validate(this);
\r