1a89b6cec3e3ad206435619cacf4d3098759e56a
[vamsas.git] / src / uk / ac / vamsas / objects / core / SequenceType.java
1 /*
2  * This class was automatically generated with 
3  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
4  * Schema.
5  * $Id$
6  */
7
8 package uk.ac.vamsas.objects.core;
9
10   //---------------------------------/
11  //- Imported classes and packages -/
12 //---------------------------------/
13
14 import org.exolab.castor.xml.Marshaller;
15 import org.exolab.castor.xml.Unmarshaller;
16
17 /**
18  * Class SequenceType.
19  * 
20  * @version $Revision$ $Date$
21  */
22 public class SequenceType extends uk.ac.vamsas.client.Vobject 
23 implements java.io.Serializable
24 {
25
26
27       //--------------------------/
28      //- Class/Member Variables -/
29     //--------------------------/
30
31     /**
32      * Field _start.
33      */
34     private long _start;
35
36     /**
37      * keeps track of state for field: _start
38      */
39     private boolean _has_start;
40
41     /**
42      * Field _end.
43      */
44     private long _end;
45
46     /**
47      * keeps track of state for field: _end
48      */
49     private boolean _has_end;
50
51     /**
52      * Field _sequence.
53      */
54     private java.lang.String _sequence;
55
56     /**
57      * Field _name.
58      */
59     private java.lang.String _name;
60
61     /**
62      * Field _description.
63      */
64     private java.lang.String _description;
65
66     /**
67      * additional typed properties 
68      */
69     private java.util.Vector _propertyList;
70
71
72       //----------------/
73      //- Constructors -/
74     //----------------/
75
76     public SequenceType() {
77         super();
78         this._propertyList = new java.util.Vector();
79     }
80
81
82       //-----------/
83      //- Methods -/
84     //-----------/
85
86     /**
87      * 
88      * 
89      * @param vProperty
90      * @throws java.lang.IndexOutOfBoundsException if the index
91      * given is outside the bounds of the collection
92      */
93     public void addProperty(
94             final uk.ac.vamsas.objects.core.Property vProperty)
95     throws java.lang.IndexOutOfBoundsException {
96         this._propertyList.addElement(vProperty);
97     }
98
99     /**
100      * 
101      * 
102      * @param index
103      * @param vProperty
104      * @throws java.lang.IndexOutOfBoundsException if the index
105      * given is outside the bounds of the collection
106      */
107     public void addProperty(
108             final int index,
109             final uk.ac.vamsas.objects.core.Property vProperty)
110     throws java.lang.IndexOutOfBoundsException {
111         this._propertyList.add(index, vProperty);
112     }
113
114     /**
115      */
116     public void deleteEnd(
117     ) {
118         this._has_end= false;
119     }
120
121     /**
122      */
123     public void deleteStart(
124     ) {
125         this._has_start= false;
126     }
127
128     /**
129      * Method enumerateProperty.
130      * 
131      * @return an Enumeration over all
132      * uk.ac.vamsas.objects.core.Property elements
133      */
134     public java.util.Enumeration enumerateProperty(
135     ) {
136         return this._propertyList.elements();
137     }
138
139     /**
140      * Overrides the java.lang.Object.equals method.
141      * 
142      * @param obj
143      * @return true if the objects are equal.
144      */
145     public boolean equals(
146             final java.lang.Object obj) {
147         if ( this == obj )
148             return true;
149         
150         if (super.equals(obj)==false)
151             return false;
152         
153         if (obj instanceof SequenceType) {
154         
155             SequenceType temp = (SequenceType)obj;
156             boolean thcycle;
157             boolean tmcycle;
158             if (this._start != temp._start)
159                 return false;
160             if (this._has_start != temp._has_start)
161                 return false;
162             if (this._end != temp._end)
163                 return false;
164             if (this._has_end != temp._has_end)
165                 return false;
166             if (this._sequence != null) {
167                 if (temp._sequence == null) return false;
168                 if (this._sequence != temp._sequence) {
169                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._sequence);
170                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._sequence);
171                     if (thcycle!=tmcycle) {
172                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence); };
173                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence); };
174                         return false;
175                     }
176                     if (!thcycle) {
177                         if (!this._sequence.equals(temp._sequence)) {
178                             org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence);
179                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence);
180                             return false;
181                         }
182                         org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence);
183                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence);
184                     }
185                 }
186             } else if (temp._sequence != null)
187                 return false;
188             if (this._name != null) {
189                 if (temp._name == null) return false;
190                 if (this._name != temp._name) {
191                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._name);
192                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._name);
193                     if (thcycle!=tmcycle) {
194                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._name); };
195                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); };
196                         return false;
197                     }
198                     if (!thcycle) {
199                         if (!this._name.equals(temp._name)) {
200                             org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
201                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
202                             return false;
203                         }
204                         org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
205                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
206                     }
207                 }
208             } else if (temp._name != null)
209                 return false;
210             if (this._description != null) {
211                 if (temp._description == null) return false;
212                 if (this._description != temp._description) {
213                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._description);
214                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._description);
215                     if (thcycle!=tmcycle) {
216                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._description); };
217                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); };
218                         return false;
219                     }
220                     if (!thcycle) {
221                         if (!this._description.equals(temp._description)) {
222                             org.castor.util.CycleBreaker.releaseCycleHandle(this._description);
223                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._description);
224                             return false;
225                         }
226                         org.castor.util.CycleBreaker.releaseCycleHandle(this._description);
227                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._description);
228                     }
229                 }
230             } else if (temp._description != null)
231                 return false;
232             if (this._propertyList != null) {
233                 if (temp._propertyList == null) return false;
234                 if (this._propertyList != temp._propertyList) {
235                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList);
236                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList);
237                     if (thcycle!=tmcycle) {
238                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); };
239                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); };
240                         return false;
241                     }
242                     if (!thcycle) {
243                         if (!this._propertyList.equals(temp._propertyList)) {
244                             org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList);
245                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList);
246                             return false;
247                         }
248                         org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList);
249                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList);
250                     }
251                 }
252             } else if (temp._propertyList != null)
253                 return false;
254             return true;
255         }
256         return false;
257     }
258
259     /**
260      * Returns the value of field 'description'.
261      * 
262      * @return the value of field 'Description'.
263      */
264     public java.lang.String getDescription(
265     ) {
266         return this._description;
267     }
268
269     /**
270      * Returns the value of field 'end'.
271      * 
272      * @return the value of field 'End'.
273      */
274     public long getEnd(
275     ) {
276         return this._end;
277     }
278
279     /**
280      * Returns the value of field 'name'.
281      * 
282      * @return the value of field 'Name'.
283      */
284     public java.lang.String getName(
285     ) {
286         return this._name;
287     }
288
289     /**
290      * Method getProperty.
291      * 
292      * @param index
293      * @throws java.lang.IndexOutOfBoundsException if the index
294      * given is outside the bounds of the collection
295      * @return the value of the uk.ac.vamsas.objects.core.Property
296      * at the given index
297      */
298     public uk.ac.vamsas.objects.core.Property getProperty(
299             final int index)
300     throws java.lang.IndexOutOfBoundsException {
301         // check bounds for index
302         if (index < 0 || index >= this._propertyList.size()) {
303             throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
304         }
305         
306         return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index);
307     }
308
309     /**
310      * Method getProperty.Returns the contents of the collection in
311      * an Array.  <p>Note:  Just in case the collection contents
312      * are changing in another thread, we pass a 0-length Array of
313      * the correct type into the API call.  This way we <i>know</i>
314      * that the Array returned is of exactly the correct length.
315      * 
316      * @return this collection as an Array
317      */
318     public uk.ac.vamsas.objects.core.Property[] getProperty(
319     ) {
320         uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0];
321         return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array);
322     }
323
324     /**
325      * Method getPropertyAsReference.Returns a reference to
326      * '_propertyList'. No type checking is performed on any
327      * modifications to the Vector.
328      * 
329      * @return a reference to the Vector backing this class
330      */
331     public java.util.Vector getPropertyAsReference(
332     ) {
333         return this._propertyList;
334     }
335
336     /**
337      * Method getPropertyCount.
338      * 
339      * @return the size of this collection
340      */
341     public int getPropertyCount(
342     ) {
343         return this._propertyList.size();
344     }
345
346     /**
347      * Returns the value of field 'sequence'.
348      * 
349      * @return the value of field 'Sequence'.
350      */
351     public java.lang.String getSequence(
352     ) {
353         return this._sequence;
354     }
355
356     /**
357      * Returns the value of field 'start'.
358      * 
359      * @return the value of field 'Start'.
360      */
361     public long getStart(
362     ) {
363         return this._start;
364     }
365
366     /**
367      * Method hasEnd.
368      * 
369      * @return true if at least one End has been added
370      */
371     public boolean hasEnd(
372     ) {
373         return this._has_end;
374     }
375
376     /**
377      * Method hasStart.
378      * 
379      * @return true if at least one Start has been added
380      */
381     public boolean hasStart(
382     ) {
383         return this._has_start;
384     }
385
386     /**
387      * Overrides the java.lang.Object.hashCode method.
388      * <p>
389      * The following steps came from <b>Effective Java Programming
390      * Language Guide</b> by Joshua Bloch, Chapter 3
391      * 
392      * @return a hash code value for the object.
393      */
394     public int hashCode(
395     ) {
396         int result = super.hashCode();
397         
398         long tmp;
399         result = 37 * result + (int)(_start^(_start>>>32));
400         result = 37 * result + (int)(_end^(_end>>>32));
401         if (_sequence != null
402             && !org.castor.util.CycleBreaker.startingToCycle(_sequence)) {
403            result = 37 * result + _sequence.hashCode();
404            org.castor.util.CycleBreaker.releaseCycleHandle(_sequence);
405         }
406         if (_name != null
407             && !org.castor.util.CycleBreaker.startingToCycle(_name)) {
408            result = 37 * result + _name.hashCode();
409            org.castor.util.CycleBreaker.releaseCycleHandle(_name);
410         }
411         if (_description != null
412             && !org.castor.util.CycleBreaker.startingToCycle(_description)) {
413            result = 37 * result + _description.hashCode();
414            org.castor.util.CycleBreaker.releaseCycleHandle(_description);
415         }
416         if (_propertyList != null
417             && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) {
418            result = 37 * result + _propertyList.hashCode();
419            org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList);
420         }
421         
422         return result;
423     }
424
425     /**
426      * Method isValid.
427      * 
428      * @return true if this object is valid according to the schema
429      */
430     public boolean isValid(
431     ) {
432         try {
433             validate();
434         } catch (org.exolab.castor.xml.ValidationException vex) {
435             return false;
436         }
437         return true;
438     }
439
440     /**
441      * 
442      * 
443      * @param out
444      * @throws org.exolab.castor.xml.MarshalException if object is
445      * null or if any SAXException is thrown during marshaling
446      * @throws org.exolab.castor.xml.ValidationException if this
447      * object is an invalid instance according to the schema
448      */
449     public void marshal(
450             final java.io.Writer out)
451     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
452         Marshaller.marshal(this, out);
453     }
454
455     /**
456      * 
457      * 
458      * @param handler
459      * @throws java.io.IOException if an IOException occurs during
460      * marshaling
461      * @throws org.exolab.castor.xml.ValidationException if this
462      * object is an invalid instance according to the schema
463      * @throws org.exolab.castor.xml.MarshalException if object is
464      * null or if any SAXException is thrown during marshaling
465      */
466     public void marshal(
467             final org.xml.sax.ContentHandler handler)
468     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
469         Marshaller.marshal(this, handler);
470     }
471
472     /**
473      */
474     public void removeAllProperty(
475     ) {
476         this._propertyList.clear();
477     }
478
479     /**
480      * Method removeProperty.
481      * 
482      * @param vProperty
483      * @return true if the object was removed from the collection.
484      */
485     public boolean removeProperty(
486             final uk.ac.vamsas.objects.core.Property vProperty) {
487         boolean removed = _propertyList.remove(vProperty);
488         return removed;
489     }
490
491     /**
492      * Method removePropertyAt.
493      * 
494      * @param index
495      * @return the element removed from the collection
496      */
497     public uk.ac.vamsas.objects.core.Property removePropertyAt(
498             final int index) {
499         java.lang.Object obj = this._propertyList.remove(index);
500         return (uk.ac.vamsas.objects.core.Property) obj;
501     }
502
503     /**
504      * Sets the value of field 'description'.
505      * 
506      * @param description the value of field 'description'.
507      */
508     public void setDescription(
509             final java.lang.String description) {
510         this._description = description;
511     }
512
513     /**
514      * Sets the value of field 'end'.
515      * 
516      * @param end the value of field 'end'.
517      */
518     public void setEnd(
519             final long end) {
520         this._end = end;
521         this._has_end = true;
522     }
523
524     /**
525      * Sets the value of field 'name'.
526      * 
527      * @param name the value of field 'name'.
528      */
529     public void setName(
530             final java.lang.String name) {
531         this._name = name;
532     }
533
534     /**
535      * 
536      * 
537      * @param index
538      * @param vProperty
539      * @throws java.lang.IndexOutOfBoundsException if the index
540      * given is outside the bounds of the collection
541      */
542     public void setProperty(
543             final int index,
544             final uk.ac.vamsas.objects.core.Property vProperty)
545     throws java.lang.IndexOutOfBoundsException {
546         // check bounds for index
547         if (index < 0 || index >= this._propertyList.size()) {
548             throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
549         }
550         
551         this._propertyList.set(index, vProperty);
552     }
553
554     /**
555      * 
556      * 
557      * @param vPropertyArray
558      */
559     public void setProperty(
560             final uk.ac.vamsas.objects.core.Property[] vPropertyArray) {
561         //-- copy array
562         _propertyList.clear();
563         
564         for (int i = 0; i < vPropertyArray.length; i++) {
565                 this._propertyList.add(vPropertyArray[i]);
566         }
567     }
568
569     /**
570      * Sets the value of '_propertyList' by copying the given
571      * Vector. All elements will be checked for type safety.
572      * 
573      * @param vPropertyList the Vector to copy.
574      */
575     public void setProperty(
576             final java.util.Vector vPropertyList) {
577         // copy vector
578         this._propertyList.clear();
579         
580         this._propertyList.addAll(vPropertyList);
581     }
582
583     /**
584      * Sets the value of '_propertyList' by setting it to the given
585      * Vector. No type checking is performed.
586      * @deprecated
587      * 
588      * @param propertyVector the Vector to set.
589      */
590     public void setPropertyAsReference(
591             final java.util.Vector propertyVector) {
592         this._propertyList = propertyVector;
593     }
594
595     /**
596      * Sets the value of field 'sequence'.
597      * 
598      * @param sequence the value of field 'sequence'.
599      */
600     public void setSequence(
601             final java.lang.String sequence) {
602         this._sequence = sequence;
603     }
604
605     /**
606      * Sets the value of field 'start'.
607      * 
608      * @param start the value of field 'start'.
609      */
610     public void setStart(
611             final long start) {
612         this._start = start;
613         this._has_start = true;
614     }
615
616     /**
617      * Method unmarshal.
618      * 
619      * @param reader
620      * @throws org.exolab.castor.xml.MarshalException if object is
621      * null or if any SAXException is thrown during marshaling
622      * @throws org.exolab.castor.xml.ValidationException if this
623      * object is an invalid instance according to the schema
624      * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp
625      */
626     public static uk.ac.vamsas.objects.core.SequenceType unmarshal(
627             final java.io.Reader reader)
628     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
629         return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.SequenceType.class, reader);
630     }
631
632     /**
633      * 
634      * 
635      * @throws org.exolab.castor.xml.ValidationException if this
636      * object is an invalid instance according to the schema
637      */
638     public void validate(
639     )
640     throws org.exolab.castor.xml.ValidationException {
641         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
642         validator.validate(this);
643     }
644
645 }