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 * base type for citing arbitrary links between vamsas objects
\r
20 * Optional human readable description of the relationship
\r
23 * @version $Revision$ $Date$
\r
25 public class ReferenceType extends uk.ac.vamsas.client.Vobject
\r
26 implements java.io.Serializable
\r
30 //--------------------------/
\r
31 //- Class/Member Variables -/
\r
32 //--------------------------/
\r
35 * internal content storage
\r
37 private java.lang.String _content = "";
\r
40 * Primary Key for vamsas object referencing
\r
42 private java.lang.String _id;
\r
45 * List of one or more vamsas object references
\r
47 private java.util.Vector _refs;
\r
54 public ReferenceType() {
\r
57 this._refs = new java.util.Vector();
\r
69 * @throws java.lang.IndexOutOfBoundsException if the index
\r
70 * given is outside the bounds of the collection
\r
72 public void addRefs(
\r
73 final java.lang.Object vRefs)
\r
74 throws java.lang.IndexOutOfBoundsException {
\r
75 this._refs.addElement(vRefs);
\r
83 * @throws java.lang.IndexOutOfBoundsException if the index
\r
84 * given is outside the bounds of the collection
\r
86 public void addRefs(
\r
88 final java.lang.Object vRefs)
\r
89 throws java.lang.IndexOutOfBoundsException {
\r
90 this._refs.add(index, vRefs);
\r
94 * Method enumerateRefs.
\r
96 * @return an Enumeration over all java.lang.Object elements
\r
98 public java.util.Enumeration enumerateRefs(
\r
100 return this._refs.elements();
\r
104 * Overrides the java.lang.Object.equals method.
\r
107 * @return true if the objects are equal.
\r
109 public boolean equals(
\r
110 final java.lang.Object obj) {
\r
114 if (super.equals(obj)==false)
\r
117 if (obj instanceof ReferenceType) {
\r
119 ReferenceType temp = (ReferenceType)obj;
\r
120 if (this._content != null) {
\r
121 if (temp._content == null) return false;
\r
122 else if (!(this._content.equals(temp._content)))
\r
125 else if (temp._content != null)
\r
127 if (this._id != null) {
\r
128 if (temp._id == null) return false;
\r
129 else if (!(this._id.equals(temp._id)))
\r
132 else if (temp._id != null)
\r
134 if (this._refs != null) {
\r
135 if (temp._refs == null) return false;
\r
136 else if (!(this._refs.equals(temp._refs)))
\r
139 else if (temp._refs != null)
\r
147 * Returns the value of field 'content'. The field 'content'
\r
148 * has the following description: internal content storage
\r
150 * @return the value of field 'Content'.
\r
152 public java.lang.String getContent(
\r
154 return this._content;
\r
158 * Returns the value of field 'id'. The field 'id' has the
\r
159 * following description: Primary Key for vamsas object
\r
162 * @return the value of field 'Id'.
\r
164 public java.lang.String getId(
\r
173 * @throws java.lang.IndexOutOfBoundsException if the index
\r
174 * given is outside the bounds of the collection
\r
175 * @return the value of the java.lang.Object at the given index
\r
177 public java.lang.Object getRefs(
\r
179 throws java.lang.IndexOutOfBoundsException {
\r
180 // check bounds for index
\r
181 if (index < 0 || index >= this._refs.size()) {
\r
182 throw new IndexOutOfBoundsException("getRefs: Index value '" + index + "' not in range [0.." + (this._refs.size() - 1) + "]");
\r
185 return _refs.get(index);
\r
189 * Method getRefs.Returns the contents of the collection in an
\r
190 * Array. <p>Note: Just in case the collection contents are
\r
191 * changing in another thread, we pass a 0-length Array of the
\r
192 * correct type into the API call. This way we <i>know</i>
\r
193 * that the Array returned is of exactly the correct length.
\r
195 * @return this collection as an Array
\r
197 public java.lang.Object[] getRefs(
\r
199 java.lang.Object[] array = new java.lang.Object[0];
\r
200 return (java.lang.Object[]) this._refs.toArray(array);
\r
204 * Method getRefsAsReference.Returns a reference to '_refs'. No
\r
205 * type checking is performed on any modifications to the
\r
208 * @return a reference to the Vector backing this class
\r
210 public java.util.Vector getRefsAsReference(
\r
216 * Method getRefsCount.
\r
218 * @return the size of this collection
\r
220 public int getRefsCount(
\r
222 return this._refs.size();
\r
226 * Overrides the java.lang.Object.hashCode method.
\r
228 * The following steps came from <b>Effective Java Programming
\r
229 * Language Guide</b> by Joshua Bloch, Chapter 3
\r
231 * @return a hash code value for the object.
\r
233 public int hashCode(
\r
235 int result = super.hashCode();
\r
238 if (_content != null) {
\r
239 result = 37 * result + _content.hashCode();
\r
242 result = 37 * result + _id.hashCode();
\r
244 if (_refs != null) {
\r
245 result = 37 * result + _refs.hashCode();
\r
254 * @return true if this object is valid according to the schema
\r
256 public boolean isValid(
\r
260 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
270 * @throws org.exolab.castor.xml.MarshalException if object is
\r
271 * null or if any SAXException is thrown during marshaling
\r
272 * @throws org.exolab.castor.xml.ValidationException if this
\r
273 * object is an invalid instance according to the schema
\r
275 public void marshal(
\r
276 final java.io.Writer out)
\r
277 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
278 Marshaller.marshal(this, out);
\r
285 * @throws java.io.IOException if an IOException occurs during
\r
287 * @throws org.exolab.castor.xml.ValidationException if this
\r
288 * object is an invalid instance according to the schema
\r
289 * @throws org.exolab.castor.xml.MarshalException if object is
\r
290 * null or if any SAXException is thrown during marshaling
\r
292 public void marshal(
\r
293 final org.xml.sax.ContentHandler handler)
\r
294 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
295 Marshaller.marshal(this, handler);
\r
300 public void removeAllRefs(
\r
302 this._refs.clear();
\r
306 * Method removeRefs.
\r
309 * @return true if the object was removed from the collection.
\r
311 public boolean removeRefs(
\r
312 final java.lang.Object vRefs) {
\r
313 boolean removed = _refs.remove(vRefs);
\r
318 * Method removeRefsAt.
\r
321 * @return the element removed from the collection
\r
323 public java.lang.Object removeRefsAt(
\r
325 java.lang.Object obj = this._refs.remove(index);
\r
330 * Sets the value of field 'content'. The field 'content' has
\r
331 * the following description: internal content storage
\r
333 * @param content the value of field 'content'.
\r
335 public void setContent(
\r
336 final java.lang.String content) {
\r
337 this._content = content;
\r
341 * Sets the value of field 'id'. The field 'id' has the
\r
342 * following description: Primary Key for vamsas object
\r
345 * @param id the value of field 'id'.
\r
348 final java.lang.String id) {
\r
357 * @throws java.lang.IndexOutOfBoundsException if the index
\r
358 * given is outside the bounds of the collection
\r
360 public void setRefs(
\r
362 final java.lang.Object vRefs)
\r
363 throws java.lang.IndexOutOfBoundsException {
\r
364 // check bounds for index
\r
365 if (index < 0 || index >= this._refs.size()) {
\r
366 throw new IndexOutOfBoundsException("setRefs: Index value '" + index + "' not in range [0.." + (this._refs.size() - 1) + "]");
\r
369 this._refs.set(index, vRefs);
\r
375 * @param vRefsArray
\r
377 public void setRefs(
\r
378 final java.lang.Object[] vRefsArray) {
\r
382 for (int i = 0; i < vRefsArray.length; i++) {
\r
383 this._refs.add(vRefsArray[i]);
\r
388 * Sets the value of '_refs' by copying the given Vector. All
\r
389 * elements will be checked for type safety.
\r
391 * @param vRefsList the Vector to copy.
\r
393 public void setRefs(
\r
394 final java.util.Vector vRefsList) {
\r
396 this._refs.clear();
\r
398 this._refs.addAll(vRefsList);
\r
402 * Sets the value of '_refs' by setting it to the given Vector.
\r
403 * No type checking is performed.
\r
406 * @param refsVector the Vector to set.
\r
408 public void setRefsAsReference(
\r
409 final java.util.Vector refsVector) {
\r
410 this._refs = refsVector;
\r
414 * Method unmarshal.
\r
417 * @throws org.exolab.castor.xml.MarshalException if object is
\r
418 * null or if any SAXException is thrown during marshaling
\r
419 * @throws org.exolab.castor.xml.ValidationException if this
\r
420 * object is an invalid instance according to the schema
\r
421 * @return the unmarshaled
\r
422 * uk.ac.vamsas.objects.core.ReferenceType
\r
424 public static uk.ac.vamsas.objects.core.ReferenceType unmarshal(
\r
425 final java.io.Reader reader)
\r
426 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
427 return (uk.ac.vamsas.objects.core.ReferenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.ReferenceType.class, reader);
\r
433 * @throws org.exolab.castor.xml.ValidationException if this
\r
434 * object is an invalid instance according to the schema
\r
436 public void validate(
\r
438 throws org.exolab.castor.xml.ValidationException {
\r
439 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
440 validator.validate(this);
\r