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
\r
48 * a range on a particular group of alignment
\r
51 private java.util.Vector _seqrefs;
\r
54 * Field _provenance.
\r
56 private uk.ac.vamsas.objects.core.Provenance _provenance;
\r
63 public AlignmentAnnotation() {
\r
65 this._seqrefs = new java.util.Vector();
\r
77 * @throws java.lang.IndexOutOfBoundsException if the index
\r
78 * given is outside the bounds of the collection
\r
80 public void addSeqrefs(
\r
81 final java.lang.Object vSeqrefs)
\r
82 throws java.lang.IndexOutOfBoundsException {
\r
83 this._seqrefs.addElement(vSeqrefs);
\r
91 * @throws java.lang.IndexOutOfBoundsException if the index
\r
92 * given is outside the bounds of the collection
\r
94 public void addSeqrefs(
\r
96 final java.lang.Object vSeqrefs)
\r
97 throws java.lang.IndexOutOfBoundsException {
\r
98 this._seqrefs.add(index, vSeqrefs);
\r
103 public void deleteGraph(
\r
105 this._has_graph= false;
\r
109 * Method enumerateSeqrefs.
\r
111 * @return an Enumeration over all java.lang.Object elements
\r
113 public java.util.Enumeration enumerateSeqrefs(
\r
115 return this._seqrefs.elements();
\r
119 * Overrides the java.lang.Object.equals method.
\r
122 * @return true if the objects are equal.
\r
124 public boolean equals(
\r
125 final java.lang.Object obj) {
\r
129 if (super.equals(obj)==false)
\r
132 if (obj instanceof AlignmentAnnotation) {
\r
134 AlignmentAnnotation temp = (AlignmentAnnotation)obj;
\r
137 if (this._graph != temp._graph)
\r
139 if (this._has_graph != temp._has_graph)
\r
141 if (this._seqrefs != null) {
\r
142 if (temp._seqrefs == null) return false;
\r
143 if (this._seqrefs != temp._seqrefs) {
\r
144 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._seqrefs);
\r
145 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._seqrefs);
\r
146 if (thcycle!=tmcycle) {
\r
147 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._seqrefs); };
\r
148 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqrefs); };
\r
152 if (!this._seqrefs.equals(temp._seqrefs)) {
\r
153 org.castor.util.CycleBreaker.releaseCycleHandle(this._seqrefs);
\r
154 org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqrefs);
\r
157 org.castor.util.CycleBreaker.releaseCycleHandle(this._seqrefs);
\r
158 org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqrefs);
\r
161 } else if (temp._seqrefs != null)
\r
163 if (this._provenance != null) {
\r
164 if (temp._provenance == null) return false;
\r
165 if (this._provenance != temp._provenance) {
\r
166 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance);
\r
167 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance);
\r
168 if (thcycle!=tmcycle) {
\r
169 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); };
\r
170 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); };
\r
174 if (!this._provenance.equals(temp._provenance)) {
\r
175 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
\r
176 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
\r
179 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
\r
180 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
\r
183 } else if (temp._provenance != null)
\r
191 * Returns the value of field 'graph'. The field 'graph' has
\r
192 * the following description: TODO: decide if this flag is
\r
193 * redundant - when true it would suggest that
\r
194 * the annotationElement values together form a
\r
197 * @return the value of field 'Graph'.
\r
199 public boolean getGraph(
\r
201 return this._graph;
\r
205 * Returns the value of field 'provenance'.
\r
207 * @return the value of field 'Provenance'.
\r
209 public uk.ac.vamsas.objects.core.Provenance getProvenance(
\r
211 return this._provenance;
\r
215 * Method getSeqrefs.
\r
218 * @throws java.lang.IndexOutOfBoundsException if the index
\r
219 * given is outside the bounds of the collection
\r
220 * @return the value of the java.lang.Object at the given index
\r
222 public java.lang.Object getSeqrefs(
\r
224 throws java.lang.IndexOutOfBoundsException {
\r
225 // check bounds for index
\r
226 if (index < 0 || index >= this._seqrefs.size()) {
\r
227 throw new IndexOutOfBoundsException("getSeqrefs: Index value '" + index + "' not in range [0.." + (this._seqrefs.size() - 1) + "]");
\r
230 return _seqrefs.get(index);
\r
234 * Method getSeqrefs.Returns the contents of the collection in
\r
235 * an Array. <p>Note: Just in case the collection contents
\r
236 * are changing in another thread, we pass a 0-length Array of
\r
237 * the correct type into the API call. This way we <i>know</i>
\r
238 * that the Array returned is of exactly the correct length.
\r
240 * @return this collection as an Array
\r
242 public java.lang.Object[] getSeqrefs(
\r
244 java.lang.Object[] array = new java.lang.Object[0];
\r
245 return (java.lang.Object[]) this._seqrefs.toArray(array);
\r
249 * Method getSeqrefsAsReference.Returns a reference to
\r
250 * '_seqrefs'. No type checking is performed on any
\r
251 * modifications to the Vector.
\r
253 * @return a reference to the Vector backing this class
\r
255 public java.util.Vector getSeqrefsAsReference(
\r
257 return this._seqrefs;
\r
261 * Method getSeqrefsCount.
\r
263 * @return the size of this collection
\r
265 public int getSeqrefsCount(
\r
267 return this._seqrefs.size();
\r
273 * @return true if at least one Graph has been added
\r
275 public boolean hasGraph(
\r
277 return this._has_graph;
\r
281 * Overrides the java.lang.Object.hashCode method.
\r
283 * The following steps came from <b>Effective Java Programming
\r
284 * Language Guide</b> by Joshua Bloch, Chapter 3
\r
286 * @return a hash code value for the object.
\r
288 public int hashCode(
\r
290 int result = super.hashCode();
\r
293 result = 37 * result + (_graph?0:1);
\r
294 if (_seqrefs != null
\r
295 && !org.castor.util.CycleBreaker.startingToCycle(_seqrefs)) {
\r
296 result = 37 * result + _seqrefs.hashCode();
\r
297 org.castor.util.CycleBreaker.releaseCycleHandle(_seqrefs);
\r
299 if (_provenance != null
\r
300 && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {
\r
301 result = 37 * result + _provenance.hashCode();
\r
302 org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);
\r
309 * Returns the value of field 'graph'. The field 'graph' has
\r
310 * the following description: TODO: decide if this flag is
\r
311 * redundant - when true it would suggest that
\r
312 * the annotationElement values together form a
\r
315 * @return the value of field 'Graph'.
\r
317 public boolean isGraph(
\r
319 return this._graph;
\r
325 * @return true if this object is valid according to the schema
\r
327 public boolean isValid(
\r
331 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
341 * @throws org.exolab.castor.xml.MarshalException if object is
\r
342 * null or if any SAXException is thrown during marshaling
\r
343 * @throws org.exolab.castor.xml.ValidationException if this
\r
344 * object is an invalid instance according to the schema
\r
346 public void marshal(
\r
347 final java.io.Writer out)
\r
348 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
349 Marshaller.marshal(this, out);
\r
356 * @throws java.io.IOException if an IOException occurs during
\r
358 * @throws org.exolab.castor.xml.ValidationException if this
\r
359 * object is an invalid instance according to the schema
\r
360 * @throws org.exolab.castor.xml.MarshalException if object is
\r
361 * null or if any SAXException is thrown during marshaling
\r
363 public void marshal(
\r
364 final org.xml.sax.ContentHandler handler)
\r
365 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
366 Marshaller.marshal(this, handler);
\r
371 public void removeAllSeqrefs(
\r
373 this._seqrefs.clear();
\r
377 * Method removeSeqrefs.
\r
380 * @return true if the object was removed from the collection.
\r
382 public boolean removeSeqrefs(
\r
383 final java.lang.Object vSeqrefs) {
\r
384 boolean removed = _seqrefs.remove(vSeqrefs);
\r
389 * Method removeSeqrefsAt.
\r
392 * @return the element removed from the collection
\r
394 public java.lang.Object removeSeqrefsAt(
\r
396 java.lang.Object obj = this._seqrefs.remove(index);
\r
401 * Sets the value of field 'graph'. The field 'graph' has the
\r
402 * following description: TODO: decide if this flag is
\r
403 * redundant - when true it would suggest that
\r
404 * the annotationElement values together form a
\r
407 * @param graph the value of field 'graph'.
\r
409 public void setGraph(
\r
410 final boolean graph) {
\r
411 this._graph = graph;
\r
412 this._has_graph = true;
\r
416 * Sets the value of field 'provenance'.
\r
418 * @param provenance the value of field 'provenance'.
\r
420 public void setProvenance(
\r
421 final uk.ac.vamsas.objects.core.Provenance provenance) {
\r
422 this._provenance = provenance;
\r
430 * @throws java.lang.IndexOutOfBoundsException if the index
\r
431 * given is outside the bounds of the collection
\r
433 public void setSeqrefs(
\r
435 final java.lang.Object vSeqrefs)
\r
436 throws java.lang.IndexOutOfBoundsException {
\r
437 // check bounds for index
\r
438 if (index < 0 || index >= this._seqrefs.size()) {
\r
439 throw new IndexOutOfBoundsException("setSeqrefs: Index value '" + index + "' not in range [0.." + (this._seqrefs.size() - 1) + "]");
\r
442 this._seqrefs.set(index, vSeqrefs);
\r
448 * @param vSeqrefsArray
\r
450 public void setSeqrefs(
\r
451 final java.lang.Object[] vSeqrefsArray) {
\r
455 for (int i = 0; i < vSeqrefsArray.length; i++) {
\r
456 this._seqrefs.add(vSeqrefsArray[i]);
\r
461 * Sets the value of '_seqrefs' by copying the given Vector.
\r
462 * All elements will be checked for type safety.
\r
464 * @param vSeqrefsList the Vector to copy.
\r
466 public void setSeqrefs(
\r
467 final java.util.Vector vSeqrefsList) {
\r
469 this._seqrefs.clear();
\r
471 this._seqrefs.addAll(vSeqrefsList);
\r
475 * Sets the value of '_seqrefs' by setting it to the given
\r
476 * Vector. No type checking is performed.
\r
479 * @param seqrefsVector the Vector to set.
\r
481 public void setSeqrefsAsReference(
\r
482 final java.util.Vector seqrefsVector) {
\r
483 this._seqrefs = seqrefsVector;
\r
487 * Method unmarshal.
\r
490 * @throws org.exolab.castor.xml.MarshalException if object is
\r
491 * null or if any SAXException is thrown during marshaling
\r
492 * @throws org.exolab.castor.xml.ValidationException if this
\r
493 * object is an invalid instance according to the schema
\r
494 * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType
\r
496 public static uk.ac.vamsas.objects.core.RangeType unmarshal(
\r
497 final java.io.Reader reader)
\r
498 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
499 return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AlignmentAnnotation.class, reader);
\r
505 * @throws org.exolab.castor.xml.ValidationException if this
\r
506 * object is an invalid instance according to the schema
\r
508 public void validate(
\r
510 throws org.exolab.castor.xml.ValidationException {
\r
511 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
512 validator.validate(this);
\r