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;
30 * @version $Revision$ $Date$
32 public class Feature implements java.io.Serializable
35 // --------------------------/
36 // - Class/Member Variables -/
37 // --------------------------/
45 * keeps track of state for field: _begin
47 private boolean _has_begin;
55 * keeps track of state for field: _end
57 private boolean _has_end;
62 private java.lang.String _type;
67 private java.lang.String _description;
72 private java.lang.String _status;
75 * Field _featureGroup.
77 private java.lang.String _featureGroup;
85 * keeps track of state for field: _score
87 private boolean _has_score;
90 * Field _otherDataList.
92 private java.util.Vector _otherDataList;
101 this._otherDataList = new java.util.Vector();
112 * @throws java.lang.IndexOutOfBoundsException
113 * if the index given is outside the bounds of the collection
115 public void addOtherData(
116 final jalview.schemabinding.version2.OtherData vOtherData)
117 throws java.lang.IndexOutOfBoundsException
119 this._otherDataList.addElement(vOtherData);
127 * @throws java.lang.IndexOutOfBoundsException
128 * if the index given is outside the bounds of the collection
130 public void addOtherData(final int index,
131 final jalview.schemabinding.version2.OtherData vOtherData)
132 throws java.lang.IndexOutOfBoundsException
134 this._otherDataList.add(index, vOtherData);
139 public void deleteBegin()
141 this._has_begin = false;
146 public void deleteEnd()
148 this._has_end = false;
153 public void deleteScore()
155 this._has_score = false;
159 * Method enumerateOtherData.
161 * @return an Enumeration over all jalview.schemabinding.version2.OtherData
164 public java.util.Enumeration enumerateOtherData()
166 return this._otherDataList.elements();
170 * Returns the value of field 'begin'.
172 * @return the value of field 'Begin'.
174 public int getBegin()
180 * Returns the value of field 'description'.
182 * @return the value of field 'Description'.
184 public java.lang.String getDescription()
186 return this._description;
190 * Returns the value of field 'end'.
192 * @return the value of field 'End'.
200 * Returns the value of field 'featureGroup'.
202 * @return the value of field 'FeatureGroup'.
204 public java.lang.String getFeatureGroup()
206 return this._featureGroup;
210 * Method getOtherData.
213 * @throws java.lang.IndexOutOfBoundsException
214 * if the index given is outside the bounds of the collection
215 * @return the value of the jalview.schemabinding.version2.OtherData at the
218 public jalview.schemabinding.version2.OtherData getOtherData(
219 final int index) throws java.lang.IndexOutOfBoundsException
221 // check bounds for index
222 if (index < 0 || index >= this._otherDataList.size())
224 throw new IndexOutOfBoundsException("getOtherData: Index value '"
225 + index + "' not in range [0.."
226 + (this._otherDataList.size() - 1) + "]");
229 return (jalview.schemabinding.version2.OtherData) _otherDataList
234 * Method getOtherData.Returns the contents of the collection in an Array.
236 * Note: Just in case the collection contents are changing in another thread,
237 * we pass a 0-length Array of the correct type into the API call. This way we
238 * <i>know</i> that the Array returned is of exactly the correct length.
240 * @return this collection as an Array
242 public jalview.schemabinding.version2.OtherData[] getOtherData()
244 jalview.schemabinding.version2.OtherData[] array = new jalview.schemabinding.version2.OtherData[0];
245 return (jalview.schemabinding.version2.OtherData[]) this._otherDataList
250 * Method getOtherDataCount.
252 * @return the size of this collection
254 public int getOtherDataCount()
256 return this._otherDataList.size();
260 * Returns the value of field 'score'.
262 * @return the value of field 'Score'.
264 public float getScore()
270 * Returns the value of field 'status'.
272 * @return the value of field 'Status'.
274 public java.lang.String getStatus()
280 * Returns the value of field 'type'.
282 * @return the value of field 'Type'.
284 public java.lang.String getType()
292 * @return true if at least one Begin has been added
294 public boolean hasBegin()
296 return this._has_begin;
302 * @return true if at least one End has been added
304 public boolean hasEnd()
306 return this._has_end;
312 * @return true if at least one Score has been added
314 public boolean hasScore()
316 return this._has_score;
322 * @return true if this object is valid according to the schema
324 public boolean isValid()
329 } catch (org.exolab.castor.xml.ValidationException vex)
340 * @throws org.exolab.castor.xml.MarshalException
341 * if object is null or if any SAXException is thrown during
343 * @throws org.exolab.castor.xml.ValidationException
344 * if this object is an invalid instance according to the schema
346 public void marshal(final java.io.Writer out)
347 throws org.exolab.castor.xml.MarshalException,
348 org.exolab.castor.xml.ValidationException
350 Marshaller.marshal(this, out);
357 * @throws java.io.IOException
358 * if an IOException occurs during marshaling
359 * @throws org.exolab.castor.xml.ValidationException
360 * if this object is an invalid instance according to the schema
361 * @throws org.exolab.castor.xml.MarshalException
362 * if object is null or if any SAXException is thrown during
365 public void marshal(final org.xml.sax.ContentHandler handler)
366 throws java.io.IOException,
367 org.exolab.castor.xml.MarshalException,
368 org.exolab.castor.xml.ValidationException
370 Marshaller.marshal(this, handler);
375 public void removeAllOtherData()
377 this._otherDataList.clear();
381 * Method removeOtherData.
384 * @return true if the object was removed from the collection.
386 public boolean removeOtherData(
387 final jalview.schemabinding.version2.OtherData vOtherData)
389 boolean removed = _otherDataList.remove(vOtherData);
394 * Method removeOtherDataAt.
397 * @return the element removed from the collection
399 public jalview.schemabinding.version2.OtherData removeOtherDataAt(
402 java.lang.Object obj = this._otherDataList.remove(index);
403 return (jalview.schemabinding.version2.OtherData) obj;
407 * Sets the value of field 'begin'.
410 * the value of field 'begin'.
412 public void setBegin(final int begin)
415 this._has_begin = true;
419 * Sets the value of field 'description'.
422 * the value of field 'description'.
424 public void setDescription(final java.lang.String description)
426 this._description = description;
430 * Sets the value of field 'end'.
433 * the value of field 'end'.
435 public void setEnd(final int end)
438 this._has_end = true;
442 * Sets the value of field 'featureGroup'.
444 * @param featureGroup
445 * the value of field 'featureGroup'.
447 public void setFeatureGroup(final java.lang.String featureGroup)
449 this._featureGroup = featureGroup;
457 * @throws java.lang.IndexOutOfBoundsException
458 * if the index given is outside the bounds of the collection
460 public void setOtherData(final int index,
461 final jalview.schemabinding.version2.OtherData vOtherData)
462 throws java.lang.IndexOutOfBoundsException
464 // check bounds for index
465 if (index < 0 || index >= this._otherDataList.size())
467 throw new IndexOutOfBoundsException("setOtherData: Index value '"
468 + index + "' not in range [0.."
469 + (this._otherDataList.size() - 1) + "]");
472 this._otherDataList.set(index, vOtherData);
478 * @param vOtherDataArray
480 public void setOtherData(
481 final jalview.schemabinding.version2.OtherData[] vOtherDataArray)
484 _otherDataList.clear();
486 for (int i = 0; i < vOtherDataArray.length; i++)
488 this._otherDataList.add(vOtherDataArray[i]);
493 * Sets the value of field 'score'.
496 * the value of field 'score'.
498 public void setScore(final float score)
501 this._has_score = true;
505 * Sets the value of field 'status'.
508 * the value of field 'status'.
510 public void setStatus(final java.lang.String status)
512 this._status = status;
516 * Sets the value of field 'type'.
519 * the value of field 'type'.
521 public void setType(final java.lang.String type)
530 * @throws org.exolab.castor.xml.MarshalException
531 * if object is null or if any SAXException is thrown during
533 * @throws org.exolab.castor.xml.ValidationException
534 * if this object is an invalid instance according to the schema
535 * @return the unmarshaled jalview.schemabinding.version2.Featur
537 public static jalview.schemabinding.version2.Feature unmarshal(
538 final java.io.Reader reader)
539 throws org.exolab.castor.xml.MarshalException,
540 org.exolab.castor.xml.ValidationException
542 return (jalview.schemabinding.version2.Feature) Unmarshaller.unmarshal(
543 jalview.schemabinding.version2.Feature.class, reader);
549 * @throws org.exolab.castor.xml.ValidationException
550 * if this object is an invalid instance according to the schema
552 public void validate() throws org.exolab.castor.xml.ValidationException
554 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
555 validator.validate(this);