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;
35 * @version $Revision$ $Date$
37 public class Feature implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
50 * keeps track of state for field: _begin
52 private boolean _has_begin;
60 * keeps track of state for field: _end
62 private boolean _has_end;
67 private java.lang.String _type;
72 private java.lang.String _description;
77 private java.lang.String _status;
80 * Field _featureGroup.
82 private java.lang.String _featureGroup;
90 * keeps track of state for field: _score
92 private boolean _has_score;
95 * Field _otherDataList.
97 private java.util.Vector _otherDataList;
106 this._otherDataList = new java.util.Vector();
117 * @throws java.lang.IndexOutOfBoundsException
118 * if the index given is outside the bounds of the collection
120 public void addOtherData(
121 final jalview.schemabinding.version2.OtherData vOtherData)
122 throws java.lang.IndexOutOfBoundsException
124 this._otherDataList.addElement(vOtherData);
132 * @throws java.lang.IndexOutOfBoundsException
133 * if the index given is outside the bounds of the collection
135 public void addOtherData(final int index,
136 final jalview.schemabinding.version2.OtherData vOtherData)
137 throws java.lang.IndexOutOfBoundsException
139 this._otherDataList.add(index, vOtherData);
144 public void deleteBegin()
146 this._has_begin = false;
151 public void deleteEnd()
153 this._has_end = false;
158 public void deleteScore()
160 this._has_score = false;
164 * Method enumerateOtherData.
166 * @return an Enumeration over all jalview.schemabinding.version2.OtherData
169 public java.util.Enumeration enumerateOtherData()
171 return this._otherDataList.elements();
175 * Returns the value of field 'begin'.
177 * @return the value of field 'Begin'.
179 public int getBegin()
185 * Returns the value of field 'description'.
187 * @return the value of field 'Description'.
189 public java.lang.String getDescription()
191 return this._description;
195 * Returns the value of field 'end'.
197 * @return the value of field 'End'.
205 * Returns the value of field 'featureGroup'.
207 * @return the value of field 'FeatureGroup'.
209 public java.lang.String getFeatureGroup()
211 return this._featureGroup;
215 * Method getOtherData.
218 * @throws java.lang.IndexOutOfBoundsException
219 * if the index given is outside the bounds of the collection
220 * @return the value of the jalview.schemabinding.version2.OtherData at the
223 public jalview.schemabinding.version2.OtherData getOtherData(
224 final int index) throws java.lang.IndexOutOfBoundsException
226 // check bounds for index
227 if (index < 0 || index >= this._otherDataList.size())
229 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
231 Integer.valueOf(index).toString(),
232 Integer.valueOf((this._otherDataList.size() - 1)).toString()
236 return (jalview.schemabinding.version2.OtherData) _otherDataList
241 * Method getOtherData.Returns the contents of the collection in an Array.
243 * Note: Just in case the collection contents are changing in another thread,
244 * we pass a 0-length Array of the correct type into the API call. This way we
245 * <i>know</i> that the Array returned is of exactly the correct length.
247 * @return this collection as an Array
249 public jalview.schemabinding.version2.OtherData[] getOtherData()
251 jalview.schemabinding.version2.OtherData[] array = new jalview.schemabinding.version2.OtherData[0];
252 return (jalview.schemabinding.version2.OtherData[]) this._otherDataList
257 * Method getOtherDataCount.
259 * @return the size of this collection
261 public int getOtherDataCount()
263 return this._otherDataList.size();
267 * Returns the value of field 'score'.
269 * @return the value of field 'Score'.
271 public float getScore()
277 * Returns the value of field 'status'.
279 * @return the value of field 'Status'.
281 public java.lang.String getStatus()
287 * Returns the value of field 'type'.
289 * @return the value of field 'Type'.
291 public java.lang.String getType()
299 * @return true if at least one Begin has been added
301 public boolean hasBegin()
303 return this._has_begin;
309 * @return true if at least one End has been added
311 public boolean hasEnd()
313 return this._has_end;
319 * @return true if at least one Score has been added
321 public boolean hasScore()
323 return this._has_score;
329 * @return true if this object is valid according to the schema
331 public boolean isValid()
336 } catch (org.exolab.castor.xml.ValidationException vex)
347 * @throws org.exolab.castor.xml.MarshalException
348 * if object is null or if any SAXException is thrown during
350 * @throws org.exolab.castor.xml.ValidationException
351 * if this object is an invalid instance according to the schema
353 public void marshal(final java.io.Writer out)
354 throws org.exolab.castor.xml.MarshalException,
355 org.exolab.castor.xml.ValidationException
357 Marshaller.marshal(this, out);
364 * @throws java.io.IOException
365 * if an IOException occurs during marshaling
366 * @throws org.exolab.castor.xml.ValidationException
367 * if this object is an invalid instance according to the schema
368 * @throws org.exolab.castor.xml.MarshalException
369 * if object is null or if any SAXException is thrown during
372 public void marshal(final org.xml.sax.ContentHandler handler)
373 throws java.io.IOException,
374 org.exolab.castor.xml.MarshalException,
375 org.exolab.castor.xml.ValidationException
377 Marshaller.marshal(this, handler);
382 public void removeAllOtherData()
384 this._otherDataList.clear();
388 * Method removeOtherData.
391 * @return true if the object was removed from the collection.
393 public boolean removeOtherData(
394 final jalview.schemabinding.version2.OtherData vOtherData)
396 boolean removed = _otherDataList.remove(vOtherData);
401 * Method removeOtherDataAt.
404 * @return the element removed from the collection
406 public jalview.schemabinding.version2.OtherData removeOtherDataAt(
409 java.lang.Object obj = this._otherDataList.remove(index);
410 return (jalview.schemabinding.version2.OtherData) obj;
414 * Sets the value of field 'begin'.
417 * the value of field 'begin'.
419 public void setBegin(final int begin)
422 this._has_begin = true;
426 * Sets the value of field 'description'.
429 * the value of field 'description'.
431 public void setDescription(final java.lang.String description)
433 this._description = description;
437 * Sets the value of field 'end'.
440 * the value of field 'end'.
442 public void setEnd(final int end)
445 this._has_end = true;
449 * Sets the value of field 'featureGroup'.
451 * @param featureGroup
452 * the value of field 'featureGroup'.
454 public void setFeatureGroup(final java.lang.String featureGroup)
456 this._featureGroup = featureGroup;
464 * @throws java.lang.IndexOutOfBoundsException
465 * if the index given is outside the bounds of the collection
467 public void setOtherData(final int index,
468 final jalview.schemabinding.version2.OtherData vOtherData)
469 throws java.lang.IndexOutOfBoundsException
471 // check bounds for index
472 if (index < 0 || index >= this._otherDataList.size())
474 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
476 Integer.valueOf(index).toString(),
477 Integer.valueOf((this._otherDataList.size() - 1)).toString()
481 this._otherDataList.set(index, vOtherData);
487 * @param vOtherDataArray
489 public void setOtherData(
490 final jalview.schemabinding.version2.OtherData[] vOtherDataArray)
493 _otherDataList.clear();
495 for (int i = 0; i < vOtherDataArray.length; i++)
497 this._otherDataList.add(vOtherDataArray[i]);
502 * Sets the value of field 'score'.
505 * the value of field 'score'.
507 public void setScore(final float score)
510 this._has_score = true;
514 * Sets the value of field 'status'.
517 * the value of field 'status'.
519 public void setStatus(final java.lang.String status)
521 this._status = status;
525 * Sets the value of field 'type'.
528 * the value of field 'type'.
530 public void setType(final java.lang.String type)
539 * @throws org.exolab.castor.xml.MarshalException
540 * if object is null or if any SAXException is thrown during
542 * @throws org.exolab.castor.xml.ValidationException
543 * if this object is an invalid instance according to the schema
544 * @return the unmarshaled jalview.schemabinding.version2.Featur
546 public static jalview.schemabinding.version2.Feature unmarshal(
547 final java.io.Reader reader)
548 throws org.exolab.castor.xml.MarshalException,
549 org.exolab.castor.xml.ValidationException
551 return (jalview.schemabinding.version2.Feature) Unmarshaller.unmarshal(
552 jalview.schemabinding.version2.Feature.class, reader);
558 * @throws org.exolab.castor.xml.ValidationException
559 * if this object is an invalid instance according to the schema
561 public void validate() throws org.exolab.castor.xml.ValidationException
563 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
564 validator.validate(this);