refactored org to uk
[vamsas.git] / src / uk / ac / vamsas / objects / core / Sequence.java
1 /*
2  * This class was automatically generated with 
3  * <a href="http://www.castor.org">Castor 0.9.9M2</a>, using an XML
4  * Schema.
5  * $Id:Sequence.java 264 2006-12-14 17:42:54Z JimP $
6  */
7
8 package uk.ac.vamsas.objects.core;
9
10   //---------------------------------/
11  //- Imported classes and packages -/
12 //---------------------------------/
13
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import java.util.Enumeration;
19 import java.util.Vector;
20 import org.exolab.castor.xml.MarshalException;
21 import org.exolab.castor.xml.Marshaller;
22 import org.exolab.castor.xml.Unmarshaller;
23 import org.exolab.castor.xml.ValidationException;
24 import org.xml.sax.ContentHandler;
25
26 /**
27  * Class Sequence.
28  * 
29  * @version $Revision:264 $ $Date:2006-12-14 17:42:54 +0000 (Thu, 14 Dec 2006) $
30  */
31 public class Sequence extends uk.ac.vamsas.objects.core.SequenceType 
32 implements java.io.Serializable
33 {
34
35
36       //--------------------------/
37      //- Class/Member Variables -/
38     //--------------------------/
39
40     /**
41      * Primary Key for vamsas object referencing
42      *  
43      */
44     private java.lang.String _id;
45
46     /**
47      * symbol class for sequence
48      *  
49      */
50     private java.lang.String _dictionary;
51
52     /**
53      * Store a list of database references
54      *  for this sequence record - with optional mapping
55      *  from database sequence to the given sequence record 
56      */
57     private java.util.Vector _dbRefList;
58
59
60       //----------------/
61      //- Constructors -/
62     //----------------/
63
64     public Sequence() 
65      {
66         super();
67         _dbRefList = new Vector();
68     } //-- uk.ac.vamsas.objects.core.Sequence()
69
70
71       //-----------/
72      //- Methods -/
73     //-----------/
74
75     /**
76      * Method addDbRef
77      * 
78      * 
79      * 
80      * @param vDbRef
81      */
82     public void addDbRef(uk.ac.vamsas.objects.core.DbRef vDbRef)
83         throws java.lang.IndexOutOfBoundsException
84     {
85         _dbRefList.addElement(vDbRef);
86     } //-- void addDbRef(uk.ac.vamsas.objects.core.DbRef) 
87
88     /**
89      * Method addDbRef
90      * 
91      * 
92      * 
93      * @param index
94      * @param vDbRef
95      */
96     public void addDbRef(int index, uk.ac.vamsas.objects.core.DbRef vDbRef)
97         throws java.lang.IndexOutOfBoundsException
98     {
99         _dbRefList.insertElementAt(vDbRef, index);
100     } //-- void addDbRef(int, uk.ac.vamsas.objects.core.DbRef) 
101
102     /**
103      * Method enumerateDbRef
104      * 
105      * 
106      * 
107      * @return Enumeration
108      */
109     public java.util.Enumeration enumerateDbRef()
110     {
111         return _dbRefList.elements();
112     } //-- java.util.Enumeration enumerateDbRef() 
113
114     /**
115      * Note: hashCode() has not been overriden
116      * 
117      * @param obj
118      * @return boolean
119      */
120     public boolean equals(java.lang.Object obj)
121     {
122         if ( this == obj )
123             return true;
124         
125         if (super.equals(obj)==false)
126             return false;
127         
128         if (obj instanceof Sequence) {
129         
130             Sequence temp = (Sequence)obj;
131             if (this._id != null) {
132                 if (temp._id == null) return false;
133                 else if (!(this._id.equals(temp._id))) 
134                     return false;
135             }
136             else if (temp._id != null)
137                 return false;
138             if (this._dictionary != null) {
139                 if (temp._dictionary == null) return false;
140                 else if (!(this._dictionary.equals(temp._dictionary))) 
141                     return false;
142             }
143             else if (temp._dictionary != null)
144                 return false;
145             if (this._dbRefList != null) {
146                 if (temp._dbRefList == null) return false;
147                 else if (!(this._dbRefList.equals(temp._dbRefList))) 
148                     return false;
149             }
150             else if (temp._dbRefList != null)
151                 return false;
152             return true;
153         }
154         return false;
155     } //-- boolean equals(java.lang.Object) 
156
157     /**
158      * Method getDbRef
159      * 
160      * 
161      * 
162      * @param index
163      * @return DbRef
164      */
165     public uk.ac.vamsas.objects.core.DbRef getDbRef(int index)
166         throws java.lang.IndexOutOfBoundsException
167     {
168         //-- check bounds for index
169         if ((index < 0) || (index > _dbRefList.size())) {
170             throw new IndexOutOfBoundsException("getDbRef: Index value '"+index+"' not in range [0.."+_dbRefList.size()+ "]");
171         }
172         
173         return (uk.ac.vamsas.objects.core.DbRef) _dbRefList.elementAt(index);
174     } //-- uk.ac.vamsas.objects.core.DbRef getDbRef(int) 
175
176     /**
177      * Method getDbRef
178      * 
179      * 
180      * 
181      * @return DbRef
182      */
183     public uk.ac.vamsas.objects.core.DbRef[] getDbRef()
184     {
185         int size = _dbRefList.size();
186         uk.ac.vamsas.objects.core.DbRef[] mArray = new uk.ac.vamsas.objects.core.DbRef[size];
187         for (int index = 0; index < size; index++) {
188             mArray[index] = (uk.ac.vamsas.objects.core.DbRef) _dbRefList.elementAt(index);
189         }
190         return mArray;
191     } //-- uk.ac.vamsas.objects.core.DbRef[] getDbRef() 
192
193     /**
194      * Method getDbRefCount
195      * 
196      * 
197      * 
198      * @return int
199      */
200     public int getDbRefCount()
201     {
202         return _dbRefList.size();
203     } //-- int getDbRefCount() 
204
205     /**
206      * Returns the value of field 'dictionary'. The field
207      * 'dictionary' has the following description: symbol class for
208      * sequence
209      *  
210      * 
211      * @return String
212      * @return the value of field 'dictionary'.
213      */
214     public java.lang.String getDictionary()
215     {
216         return this._dictionary;
217     } //-- java.lang.String getDictionary() 
218
219     /**
220      * Returns the value of field 'id'. The field 'id' has the
221      * following description: Primary Key for vamsas object
222      * referencing
223      *  
224      * 
225      * @return String
226      * @return the value of field 'id'.
227      */
228     public java.lang.String getId()
229     {
230         return this._id;
231     } //-- java.lang.String getId() 
232
233     /**
234      * Method isValid
235      * 
236      * 
237      * 
238      * @return boolean
239      */
240     public boolean isValid()
241     {
242         try {
243             validate();
244         }
245         catch (org.exolab.castor.xml.ValidationException vex) {
246             return false;
247         }
248         return true;
249     } //-- boolean isValid() 
250
251     /**
252      * Method marshal
253      * 
254      * 
255      * 
256      * @param out
257      */
258     public void marshal(java.io.Writer out)
259         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
260     {
261         
262         Marshaller.marshal(this, out);
263     } //-- void marshal(java.io.Writer) 
264
265     /**
266      * Method marshal
267      * 
268      * 
269      * 
270      * @param handler
271      */
272     public void marshal(org.xml.sax.ContentHandler handler)
273         throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
274     {
275         
276         Marshaller.marshal(this, handler);
277     } //-- void marshal(org.xml.sax.ContentHandler) 
278
279     /**
280      * Method removeAllDbRef
281      * 
282      */
283     public void removeAllDbRef()
284     {
285         _dbRefList.removeAllElements();
286     } //-- void removeAllDbRef() 
287
288     /**
289      * Method removeDbRef
290      * 
291      * 
292      * 
293      * @param index
294      * @return DbRef
295      */
296     public uk.ac.vamsas.objects.core.DbRef removeDbRef(int index)
297     {
298         java.lang.Object obj = _dbRefList.elementAt(index);
299         _dbRefList.removeElementAt(index);
300         return (uk.ac.vamsas.objects.core.DbRef) obj;
301     } //-- uk.ac.vamsas.objects.core.DbRef removeDbRef(int) 
302
303     /**
304      * Method setDbRef
305      * 
306      * 
307      * 
308      * @param index
309      * @param vDbRef
310      */
311     public void setDbRef(int index, uk.ac.vamsas.objects.core.DbRef vDbRef)
312         throws java.lang.IndexOutOfBoundsException
313     {
314         //-- check bounds for index
315         if ((index < 0) || (index > _dbRefList.size())) {
316             throw new IndexOutOfBoundsException("setDbRef: Index value '"+index+"' not in range [0.."+_dbRefList.size()+ "]");
317         }
318         _dbRefList.setElementAt(vDbRef, index);
319     } //-- void setDbRef(int, uk.ac.vamsas.objects.core.DbRef) 
320
321     /**
322      * Method setDbRef
323      * 
324      * 
325      * 
326      * @param dbRefArray
327      */
328     public void setDbRef(uk.ac.vamsas.objects.core.DbRef[] dbRefArray)
329     {
330         //-- copy array
331         _dbRefList.removeAllElements();
332         for (int i = 0; i < dbRefArray.length; i++) {
333             _dbRefList.addElement(dbRefArray[i]);
334         }
335     } //-- void setDbRef(uk.ac.vamsas.objects.core.DbRef) 
336
337     /**
338      * Sets the value of field 'dictionary'. The field 'dictionary'
339      * has the following description: symbol class for sequence
340      *  
341      * 
342      * @param dictionary the value of field 'dictionary'.
343      */
344     public void setDictionary(java.lang.String dictionary)
345     {
346         this._dictionary = dictionary;
347     } //-- void setDictionary(java.lang.String) 
348
349     /**
350      * Sets the value of field 'id'. The field 'id' has the
351      * following description: Primary Key for vamsas object
352      * referencing
353      *  
354      * 
355      * @param id the value of field 'id'.
356      */
357     public void setId(java.lang.String id)
358     {
359         this._id = id;
360     } //-- void setId(java.lang.String) 
361
362     /**
363      * Method unmarshal
364      * 
365      * 
366      * 
367      * @param reader
368      * @return SequenceType
369      */
370     public static uk.ac.vamsas.objects.core.SequenceType unmarshal(java.io.Reader reader)
371         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
372     {
373         return (uk.ac.vamsas.objects.core.Sequence) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Sequence.class, reader);
374     } //-- uk.ac.vamsas.objects.core.SequenceType unmarshal(java.io.Reader) 
375
376     /**
377      * Method validate
378      * 
379      */
380     public void validate()
381         throws org.exolab.castor.xml.ValidationException
382     {
383         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
384         validator.validate(this);
385     } //-- void validate() 
386
387 }