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.binding;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
31 * @version $Revision$ $Date$
33 public class Annotation implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
43 private boolean _graph;
46 * keeps track of state for field: _graph
48 private boolean _has_graph;
53 private int _graphType;
56 * keeps track of state for field: _graphType
58 private boolean _has_graphType;
61 * Field _annotationElementList.
63 private java.util.Vector _annotationElementList;
68 private java.lang.String _label;
73 private java.lang.String _description;
82 this._annotationElementList = new java.util.Vector();
92 * @param vAnnotationElement
93 * @throws java.lang.IndexOutOfBoundsException
94 * if the index given is outside the bounds of the collection
96 public void addAnnotationElement(
97 final jalview.binding.AnnotationElement vAnnotationElement)
98 throws java.lang.IndexOutOfBoundsException
100 this._annotationElementList.addElement(vAnnotationElement);
107 * @param vAnnotationElement
108 * @throws java.lang.IndexOutOfBoundsException
109 * if the index given is outside the bounds of the collection
111 public void addAnnotationElement(final int index,
112 final jalview.binding.AnnotationElement vAnnotationElement)
113 throws java.lang.IndexOutOfBoundsException
115 this._annotationElementList.add(index, vAnnotationElement);
120 public void deleteGraph()
122 this._has_graph = false;
127 public void deleteGraphType()
129 this._has_graphType = false;
133 * Method enumerateAnnotationElement.
135 * @return an Enumeration over all jalview.binding.AnnotationElement elements
137 public java.util.Enumeration enumerateAnnotationElement()
139 return this._annotationElementList.elements();
143 * Method getAnnotationElement.
146 * @throws java.lang.IndexOutOfBoundsException
147 * if the index given is outside the bounds of the collection
148 * @return the value of the jalview.binding.AnnotationElement at the given
151 public jalview.binding.AnnotationElement getAnnotationElement(
152 final int index) throws java.lang.IndexOutOfBoundsException
154 // check bounds for index
155 if (index < 0 || index >= this._annotationElementList.size())
157 throw new IndexOutOfBoundsException(
158 "getAnnotationElement: Index value '" + index
159 + "' not in range [0.."
160 + (this._annotationElementList.size() - 1) + "]");
163 return (jalview.binding.AnnotationElement) _annotationElementList
168 * Method getAnnotationElement.Returns the contents of the collection in an
171 * Note: Just in case the collection contents are changing in another thread,
172 * we pass a 0-length Array of the correct type into the API call. This way we
173 * <i>know</i> that the Array returned is of exactly the correct length.
175 * @return this collection as an Array
177 public jalview.binding.AnnotationElement[] getAnnotationElement()
179 jalview.binding.AnnotationElement[] array = new jalview.binding.AnnotationElement[0];
180 return (jalview.binding.AnnotationElement[]) this._annotationElementList
185 * Method getAnnotationElementCount.
187 * @return the size of this collection
189 public int getAnnotationElementCount()
191 return this._annotationElementList.size();
195 * Returns the value of field 'description'.
197 * @return the value of field 'Description'.
199 public java.lang.String getDescription()
201 return this._description;
205 * Returns the value of field 'graph'.
207 * @return the value of field 'Graph'.
209 public boolean getGraph()
215 * Returns the value of field 'graphType'.
217 * @return the value of field 'GraphType'.
219 public int getGraphType()
221 return this._graphType;
225 * Returns the value of field 'label'.
227 * @return the value of field 'Label'.
229 public java.lang.String getLabel()
237 * @return true if at least one Graph has been added
239 public boolean hasGraph()
241 return this._has_graph;
245 * Method hasGraphType.
247 * @return true if at least one GraphType has been added
249 public boolean hasGraphType()
251 return this._has_graphType;
255 * Returns the value of field 'graph'.
257 * @return the value of field 'Graph'.
259 public boolean isGraph()
267 * @return true if this object is valid according to the schema
269 public boolean isValid()
274 } catch (org.exolab.castor.xml.ValidationException vex)
285 * @throws org.exolab.castor.xml.MarshalException
286 * if object is null or if any SAXException is thrown during
288 * @throws org.exolab.castor.xml.ValidationException
289 * if this object is an invalid instance according to the schema
291 public void marshal(final java.io.Writer out)
292 throws org.exolab.castor.xml.MarshalException,
293 org.exolab.castor.xml.ValidationException
295 Marshaller.marshal(this, out);
302 * @throws java.io.IOException
303 * if an IOException occurs during marshaling
304 * @throws org.exolab.castor.xml.ValidationException
305 * if this object is an invalid instance according to the schema
306 * @throws org.exolab.castor.xml.MarshalException
307 * if object is null or if any SAXException is thrown during
310 public void marshal(final org.xml.sax.ContentHandler handler)
311 throws java.io.IOException,
312 org.exolab.castor.xml.MarshalException,
313 org.exolab.castor.xml.ValidationException
315 Marshaller.marshal(this, handler);
320 public void removeAllAnnotationElement()
322 this._annotationElementList.clear();
326 * Method removeAnnotationElement.
328 * @param vAnnotationElement
329 * @return true if the object was removed from the collection.
331 public boolean removeAnnotationElement(
332 final jalview.binding.AnnotationElement vAnnotationElement)
334 boolean removed = _annotationElementList.remove(vAnnotationElement);
339 * Method removeAnnotationElementAt.
342 * @return the element removed from the collection
344 public jalview.binding.AnnotationElement removeAnnotationElementAt(
347 java.lang.Object obj = this._annotationElementList.remove(index);
348 return (jalview.binding.AnnotationElement) obj;
355 * @param vAnnotationElement
356 * @throws java.lang.IndexOutOfBoundsException
357 * if the index given is outside the bounds of the collection
359 public void setAnnotationElement(final int index,
360 final jalview.binding.AnnotationElement vAnnotationElement)
361 throws java.lang.IndexOutOfBoundsException
363 // check bounds for index
364 if (index < 0 || index >= this._annotationElementList.size())
366 throw new IndexOutOfBoundsException(
367 "setAnnotationElement: Index value '" + index
368 + "' not in range [0.."
369 + (this._annotationElementList.size() - 1) + "]");
372 this._annotationElementList.set(index, vAnnotationElement);
378 * @param vAnnotationElementArray
380 public void setAnnotationElement(
381 final jalview.binding.AnnotationElement[] vAnnotationElementArray)
384 _annotationElementList.clear();
386 for (int i = 0; i < vAnnotationElementArray.length; i++)
388 this._annotationElementList.add(vAnnotationElementArray[i]);
393 * Sets the value of field 'description'.
396 * the value of field 'description'.
398 public void setDescription(final java.lang.String description)
400 this._description = description;
404 * Sets the value of field 'graph'.
407 * the value of field 'graph'.
409 public void setGraph(final boolean graph)
412 this._has_graph = true;
416 * Sets the value of field 'graphType'.
419 * the value of field 'graphType'.
421 public void setGraphType(final int graphType)
423 this._graphType = graphType;
424 this._has_graphType = true;
428 * Sets the value of field 'label'.
431 * the value of field 'label'.
433 public void setLabel(final java.lang.String label)
442 * @throws org.exolab.castor.xml.MarshalException
443 * if object is null or if any SAXException is thrown during
445 * @throws org.exolab.castor.xml.ValidationException
446 * if this object is an invalid instance according to the schema
447 * @return the unmarshaled jalview.binding.Annotation
449 public static jalview.binding.Annotation unmarshal(
450 final java.io.Reader reader)
451 throws org.exolab.castor.xml.MarshalException,
452 org.exolab.castor.xml.ValidationException
454 return (jalview.binding.Annotation) Unmarshaller.unmarshal(
455 jalview.binding.Annotation.class, reader);
461 * @throws org.exolab.castor.xml.ValidationException
462 * if this object is an invalid instance according to the schema
464 public void validate() throws org.exolab.castor.xml.ValidationException
466 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
467 validator.validate(this);