2 * This class was automatically generated with
\r
3 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
\r
8 package uk.ac.vamsas.objects.core;
\r
10 //---------------------------------/
\r
11 //- Imported classes and packages -/
\r
12 //---------------------------------/
\r
14 import org.exolab.castor.xml.Marshaller;
\r
15 import org.exolab.castor.xml.Unmarshaller;
\r
18 * This is annotation over the coordinate frame
\r
19 * defined by all the columns in the alignment.
\r
22 * @version $Revision$ $Date$
\r
24 public class AlignmentAnnotation extends uk.ac.vamsas.objects.core.RangeAnnotation
\r
25 implements java.io.Serializable
\r
29 //--------------------------/
\r
30 //- Class/Member Variables -/
\r
31 //--------------------------/
\r
34 * TODO: decide if this flag is
\r
35 * redundant - when true it would suggest that
\r
36 * the annotationElement values together form a
\r
39 private boolean _graph;
\r
42 * keeps track of state for field: _graph
\r
44 private boolean _has_graph;
\r
47 * annotation is associated with a
\r
48 * range on a particular group of alignment sequences
\r
50 private java.util.Vector _seqrefs;
\r
53 * Field _provenance.
\r
55 private uk.ac.vamsas.objects.core.Provenance _provenance;
\r
62 public AlignmentAnnotation() {
\r
64 this._seqrefs = new java.util.Vector();
\r
76 * @throws java.lang.IndexOutOfBoundsException if the index
\r
77 * given is outside the bounds of the collection
\r
79 public void addSeqrefs(
\r
80 final java.lang.Object vSeqrefs)
\r
81 throws java.lang.IndexOutOfBoundsException {
\r
82 this._seqrefs.addElement(vSeqrefs);
\r
90 * @throws java.lang.IndexOutOfBoundsException if the index
\r
91 * given is outside the bounds of the collection
\r
93 public void addSeqrefs(
\r
95 final java.lang.Object vSeqrefs)
\r
96 throws java.lang.IndexOutOfBoundsException {
\r
97 this._seqrefs.add(index, vSeqrefs);
\r
102 public void deleteGraph(
\r
104 this._has_graph= false;
\r
108 * Method enumerateSeqrefs.
\r
110 * @return an Enumeration over all java.lang.Object elements
\r
112 public java.util.Enumeration enumerateSeqrefs(
\r
114 return this._seqrefs.elements();
\r
118 * Overrides the java.lang.Object.equals method.
\r
121 * @return true if the objects are equal.
\r
123 public boolean equals(
\r
124 final java.lang.Object obj) {
\r
128 if (super.equals(obj)==false)
\r
131 if (obj instanceof AlignmentAnnotation) {
\r
133 AlignmentAnnotation temp = (AlignmentAnnotation)obj;
\r
134 if (this._graph != temp._graph)
\r
136 if (this._has_graph != temp._has_graph)
\r
138 if (this._seqrefs != null) {
\r
139 if (temp._seqrefs == null) return false;
\r
140 else if (!(this._seqrefs.equals(temp._seqrefs)))
\r
143 else if (temp._seqrefs != null)
\r
145 if (this._provenance != null) {
\r
146 if (temp._provenance == null) return false;
\r
147 else if (!(this._provenance.equals(temp._provenance)))
\r
150 else if (temp._provenance != null)
\r
158 * Returns the value of field 'graph'. The field 'graph' has
\r
159 * the following description: TODO: decide if this flag is
\r
160 * redundant - when true it would suggest that
\r
161 * the annotationElement values together form a
\r
164 * @return the value of field 'Graph'.
\r
166 public boolean getGraph(
\r
168 return this._graph;
\r
172 * Returns the value of field 'provenance'.
\r
174 * @return the value of field 'Provenance'.
\r
176 public uk.ac.vamsas.objects.core.Provenance getProvenance(
\r
178 return this._provenance;
\r
182 * Method getSeqrefs.
\r
185 * @throws java.lang.IndexOutOfBoundsException if the index
\r
186 * given is outside the bounds of the collection
\r
187 * @return the value of the java.lang.Object at the given index
\r
189 public java.lang.Object getSeqrefs(
\r
191 throws java.lang.IndexOutOfBoundsException {
\r
192 // check bounds for index
\r
193 if (index < 0 || index >= this._seqrefs.size()) {
\r
194 throw new IndexOutOfBoundsException("getSeqrefs: Index value '" + index + "' not in range [0.." + (this._seqrefs.size() - 1) + "]");
\r
197 return _seqrefs.get(index);
\r
201 * Method getSeqrefs.Returns the contents of the collection in
\r
202 * an Array. <p>Note: Just in case the collection contents
\r
203 * are changing in another thread, we pass a 0-length Array of
\r
204 * the correct type into the API call. This way we <i>know</i>
\r
205 * that the Array returned is of exactly the correct length.
\r
207 * @return this collection as an Array
\r
209 public java.lang.Object[] getSeqrefs(
\r
211 java.lang.Object[] array = new java.lang.Object[0];
\r
212 return (java.lang.Object[]) this._seqrefs.toArray(array);
\r
216 * Method getSeqrefsAsReference.Returns a reference to
\r
217 * '_seqrefs'. No type checking is performed on any
\r
218 * modifications to the Vector.
\r
220 * @return a reference to the Vector backing this class
\r
222 public java.util.Vector getSeqrefsAsReference(
\r
224 return this._seqrefs;
\r
228 * Method getSeqrefsCount.
\r
230 * @return the size of this collection
\r
232 public int getSeqrefsCount(
\r
234 return this._seqrefs.size();
\r
240 * @return true if at least one Graph has been added
\r
242 public boolean hasGraph(
\r
244 return this._has_graph;
\r
248 * Overrides the java.lang.Object.hashCode method.
\r
250 * The following steps came from <b>Effective Java Programming
\r
251 * Language Guide</b> by Joshua Bloch, Chapter 3
\r
253 * @return a hash code value for the object.
\r
255 public int hashCode(
\r
257 int result = super.hashCode();
\r
260 result = 37 * result + (_graph?0:1);
\r
261 if (_seqrefs != null) {
\r
262 result = 37 * result + _seqrefs.hashCode();
\r
264 if (_provenance != null) {
\r
265 result = 37 * result + _provenance.hashCode();
\r
272 * Returns the value of field 'graph'. The field 'graph' has
\r
273 * the following description: TODO: decide if this flag is
\r
274 * redundant - when true it would suggest that
\r
275 * the annotationElement values together form a
\r
278 * @return the value of field 'Graph'.
\r
280 public boolean isGraph(
\r
282 return this._graph;
\r
288 * @return true if this object is valid according to the schema
\r
290 public boolean isValid(
\r
294 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
304 * @throws org.exolab.castor.xml.MarshalException if object is
\r
305 * null or if any SAXException is thrown during marshaling
\r
306 * @throws org.exolab.castor.xml.ValidationException if this
\r
307 * object is an invalid instance according to the schema
\r
309 public void marshal(
\r
310 final java.io.Writer out)
\r
311 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
312 Marshaller.marshal(this, out);
\r
319 * @throws java.io.IOException if an IOException occurs during
\r
321 * @throws org.exolab.castor.xml.ValidationException if this
\r
322 * object is an invalid instance according to the schema
\r
323 * @throws org.exolab.castor.xml.MarshalException if object is
\r
324 * null or if any SAXException is thrown during marshaling
\r
326 public void marshal(
\r
327 final org.xml.sax.ContentHandler handler)
\r
328 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
329 Marshaller.marshal(this, handler);
\r
334 public void removeAllSeqrefs(
\r
336 this._seqrefs.clear();
\r
340 * Method removeSeqrefs.
\r
343 * @return true if the object was removed from the collection.
\r
345 public boolean removeSeqrefs(
\r
346 final java.lang.Object vSeqrefs) {
\r
347 boolean removed = _seqrefs.remove(vSeqrefs);
\r
352 * Method removeSeqrefsAt.
\r
355 * @return the element removed from the collection
\r
357 public java.lang.Object removeSeqrefsAt(
\r
359 java.lang.Object obj = this._seqrefs.remove(index);
\r
364 * Sets the value of field 'graph'. The field 'graph' has the
\r
365 * following description: TODO: decide if this flag is
\r
366 * redundant - when true it would suggest that
\r
367 * the annotationElement values together form a
\r
370 * @param graph the value of field 'graph'.
\r
372 public void setGraph(
\r
373 final boolean graph) {
\r
374 this._graph = graph;
\r
375 this._has_graph = true;
\r
379 * Sets the value of field 'provenance'.
\r
381 * @param provenance the value of field 'provenance'.
\r
383 public void setProvenance(
\r
384 final uk.ac.vamsas.objects.core.Provenance provenance) {
\r
385 this._provenance = provenance;
\r
393 * @throws java.lang.IndexOutOfBoundsException if the index
\r
394 * given is outside the bounds of the collection
\r
396 public void setSeqrefs(
\r
398 final java.lang.Object vSeqrefs)
\r
399 throws java.lang.IndexOutOfBoundsException {
\r
400 // check bounds for index
\r
401 if (index < 0 || index >= this._seqrefs.size()) {
\r
402 throw new IndexOutOfBoundsException("setSeqrefs: Index value '" + index + "' not in range [0.." + (this._seqrefs.size() - 1) + "]");
\r
405 this._seqrefs.set(index, vSeqrefs);
\r
411 * @param vSeqrefsArray
\r
413 public void setSeqrefs(
\r
414 final java.lang.Object[] vSeqrefsArray) {
\r
418 for (int i = 0; i < vSeqrefsArray.length; i++) {
\r
419 this._seqrefs.add(vSeqrefsArray[i]);
\r
424 * Sets the value of '_seqrefs' by copying the given Vector.
\r
425 * All elements will be checked for type safety.
\r
427 * @param vSeqrefsList the Vector to copy.
\r
429 public void setSeqrefs(
\r
430 final java.util.Vector vSeqrefsList) {
\r
432 this._seqrefs.clear();
\r
434 this._seqrefs.addAll(vSeqrefsList);
\r
438 * Sets the value of '_seqrefs' by setting it to the given
\r
439 * Vector. No type checking is performed.
\r
442 * @param seqrefsVector the Vector to set.
\r
444 public void setSeqrefsAsReference(
\r
445 final java.util.Vector seqrefsVector) {
\r
446 this._seqrefs = seqrefsVector;
\r
450 * Method unmarshal.
\r
453 * @throws org.exolab.castor.xml.MarshalException if object is
\r
454 * null or if any SAXException is thrown during marshaling
\r
455 * @throws org.exolab.castor.xml.ValidationException if this
\r
456 * object is an invalid instance according to the schema
\r
457 * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType
\r
459 public static uk.ac.vamsas.objects.core.RangeType unmarshal(
\r
460 final java.io.Reader reader)
\r
461 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
462 return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AlignmentAnnotation.class, reader);
\r
468 * @throws org.exolab.castor.xml.ValidationException if this
\r
469 * object is an invalid instance according to the schema
\r
471 public void validate(
\r
473 throws org.exolab.castor.xml.ValidationException {
\r
474 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
475 validator.validate(this);
\r