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
19 * Optional human readable description of the relationship
\r
22 * @version $Revision$ $Date$
\r
24 public class ReferenceType extends uk.ac.vamsas.client.Vobject
\r
25 implements java.io.Serializable
\r
29 //--------------------------/
\r
30 //- Class/Member Variables -/
\r
31 //--------------------------/
\r
34 * internal content storage
\r
36 private java.lang.String _content = "";
\r
39 * Primary Key for vamsas object referencing
\r
42 private java.lang.String _id;
\r
45 * List of one or more vamsas object
\r
48 private java.util.Vector _refs;
\r
55 public ReferenceType() {
\r
58 this._refs = new java.util.Vector();
\r
70 * @throws java.lang.IndexOutOfBoundsException if the index
\r
71 * given is outside the bounds of the collection
\r
73 public void addRefs(
\r
74 final java.lang.Object vRefs)
\r
75 throws java.lang.IndexOutOfBoundsException {
\r
76 this._refs.addElement(vRefs);
\r
84 * @throws java.lang.IndexOutOfBoundsException if the index
\r
85 * given is outside the bounds of the collection
\r
87 public void addRefs(
\r
89 final java.lang.Object vRefs)
\r
90 throws java.lang.IndexOutOfBoundsException {
\r
91 this._refs.add(index, vRefs);
\r
95 * Method enumerateRefs.
\r
97 * @return an Enumeration over all java.lang.Object elements
\r
99 public java.util.Enumeration enumerateRefs(
\r
101 return this._refs.elements();
\r
105 * Overrides the java.lang.Object.equals method.
\r
108 * @return true if the objects are equal.
\r
110 public boolean equals(
\r
111 final java.lang.Object obj) {
\r
115 if (super.equals(obj)==false)
\r
118 if (obj instanceof ReferenceType) {
\r
120 ReferenceType temp = (ReferenceType)obj;
\r
123 if (this._content != null) {
\r
124 if (temp._content == null) return false;
\r
125 if (this._content != temp._content) {
\r
126 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content);
\r
127 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content);
\r
128 if (thcycle!=tmcycle) {
\r
129 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); };
\r
130 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); };
\r
134 if (!this._content.equals(temp._content)) {
\r
135 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
136 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
139 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
140 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
143 } else if (temp._content != null)
\r
145 if (this._id != null) {
\r
146 if (temp._id == null) return false;
\r
147 if (this._id != temp._id) {
\r
148 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id);
\r
149 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id);
\r
150 if (thcycle!=tmcycle) {
\r
151 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); };
\r
152 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); };
\r
156 if (!this._id.equals(temp._id)) {
\r
157 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
\r
158 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
\r
161 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
\r
162 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
\r
165 } else if (temp._id != null)
\r
167 if (this._refs != null) {
\r
168 if (temp._refs == null) return false;
\r
169 if (this._refs != temp._refs) {
\r
170 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._refs);
\r
171 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._refs);
\r
172 if (thcycle!=tmcycle) {
\r
173 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._refs); };
\r
174 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._refs); };
\r
178 if (!this._refs.equals(temp._refs)) {
\r
179 org.castor.util.CycleBreaker.releaseCycleHandle(this._refs);
\r
180 org.castor.util.CycleBreaker.releaseCycleHandle(temp._refs);
\r
183 org.castor.util.CycleBreaker.releaseCycleHandle(this._refs);
\r
184 org.castor.util.CycleBreaker.releaseCycleHandle(temp._refs);
\r
187 } else if (temp._refs != null)
\r
195 * Returns the value of field 'content'. The field 'content'
\r
196 * has the following description: internal content storage
\r
198 * @return the value of field 'Content'.
\r
200 public java.lang.String getContent(
\r
202 return this._content;
\r
206 * Returns the value of field 'id'. The field 'id' has the
\r
207 * following description: Primary Key for vamsas object
\r
211 * @return the value of field 'Id'.
\r
213 public java.lang.String getId(
\r
222 * @throws java.lang.IndexOutOfBoundsException if the index
\r
223 * given is outside the bounds of the collection
\r
224 * @return the value of the java.lang.Object at the given index
\r
226 public java.lang.Object getRefs(
\r
228 throws java.lang.IndexOutOfBoundsException {
\r
229 // check bounds for index
\r
230 if (index < 0 || index >= this._refs.size()) {
\r
231 throw new IndexOutOfBoundsException("getRefs: Index value '" + index + "' not in range [0.." + (this._refs.size() - 1) + "]");
\r
234 return _refs.get(index);
\r
238 * Method getRefs.Returns the contents of the collection in an
\r
239 * Array. <p>Note: Just in case the collection contents are
\r
240 * changing in another thread, we pass a 0-length Array of the
\r
241 * correct type into the API call. This way we <i>know</i>
\r
242 * that the Array returned is of exactly the correct length.
\r
244 * @return this collection as an Array
\r
246 public java.lang.Object[] getRefs(
\r
248 java.lang.Object[] array = new java.lang.Object[0];
\r
249 return (java.lang.Object[]) this._refs.toArray(array);
\r
253 * Method getRefsAsReference.Returns a reference to '_refs'. No
\r
254 * type checking is performed on any modifications to the
\r
257 * @return a reference to the Vector backing this class
\r
259 public java.util.Vector getRefsAsReference(
\r
265 * Method getRefsCount.
\r
267 * @return the size of this collection
\r
269 public int getRefsCount(
\r
271 return this._refs.size();
\r
275 * Overrides the java.lang.Object.hashCode method.
\r
277 * The following steps came from <b>Effective Java Programming
\r
278 * Language Guide</b> by Joshua Bloch, Chapter 3
\r
280 * @return a hash code value for the object.
\r
282 public int hashCode(
\r
284 int result = super.hashCode();
\r
287 if (_content != null
\r
288 && !org.castor.util.CycleBreaker.startingToCycle(_content)) {
\r
289 result = 37 * result + _content.hashCode();
\r
290 org.castor.util.CycleBreaker.releaseCycleHandle(_content);
\r
293 && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
\r
294 result = 37 * result + _id.hashCode();
\r
295 org.castor.util.CycleBreaker.releaseCycleHandle(_id);
\r
298 && !org.castor.util.CycleBreaker.startingToCycle(_refs)) {
\r
299 result = 37 * result + _refs.hashCode();
\r
300 org.castor.util.CycleBreaker.releaseCycleHandle(_refs);
\r
309 * @return true if this object is valid according to the schema
\r
311 public boolean isValid(
\r
315 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
325 * @throws org.exolab.castor.xml.MarshalException if object is
\r
326 * null or if any SAXException is thrown during marshaling
\r
327 * @throws org.exolab.castor.xml.ValidationException if this
\r
328 * object is an invalid instance according to the schema
\r
330 public void marshal(
\r
331 final java.io.Writer out)
\r
332 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
333 Marshaller.marshal(this, out);
\r
340 * @throws java.io.IOException if an IOException occurs during
\r
342 * @throws org.exolab.castor.xml.ValidationException if this
\r
343 * object is an invalid instance according to the schema
\r
344 * @throws org.exolab.castor.xml.MarshalException if object is
\r
345 * null or if any SAXException is thrown during marshaling
\r
347 public void marshal(
\r
348 final org.xml.sax.ContentHandler handler)
\r
349 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
350 Marshaller.marshal(this, handler);
\r
355 public void removeAllRefs(
\r
357 this._refs.clear();
\r
361 * Method removeRefs.
\r
364 * @return true if the object was removed from the collection.
\r
366 public boolean removeRefs(
\r
367 final java.lang.Object vRefs) {
\r
368 boolean removed = _refs.remove(vRefs);
\r
373 * Method removeRefsAt.
\r
376 * @return the element removed from the collection
\r
378 public java.lang.Object removeRefsAt(
\r
380 java.lang.Object obj = this._refs.remove(index);
\r
385 * Sets the value of field 'content'. The field 'content' has
\r
386 * the following description: internal content storage
\r
388 * @param content the value of field 'content'.
\r
390 public void setContent(
\r
391 final java.lang.String content) {
\r
392 this._content = content;
\r
396 * Sets the value of field 'id'. The field 'id' has the
\r
397 * following description: Primary Key for vamsas object
\r
401 * @param id the value of field 'id'.
\r
404 final java.lang.String id) {
\r
413 * @throws java.lang.IndexOutOfBoundsException if the index
\r
414 * given is outside the bounds of the collection
\r
416 public void setRefs(
\r
418 final java.lang.Object vRefs)
\r
419 throws java.lang.IndexOutOfBoundsException {
\r
420 // check bounds for index
\r
421 if (index < 0 || index >= this._refs.size()) {
\r
422 throw new IndexOutOfBoundsException("setRefs: Index value '" + index + "' not in range [0.." + (this._refs.size() - 1) + "]");
\r
425 this._refs.set(index, vRefs);
\r
431 * @param vRefsArray
\r
433 public void setRefs(
\r
434 final java.lang.Object[] vRefsArray) {
\r
438 for (int i = 0; i < vRefsArray.length; i++) {
\r
439 this._refs.add(vRefsArray[i]);
\r
444 * Sets the value of '_refs' by copying the given Vector. All
\r
445 * elements will be checked for type safety.
\r
447 * @param vRefsList the Vector to copy.
\r
449 public void setRefs(
\r
450 final java.util.Vector vRefsList) {
\r
452 this._refs.clear();
\r
454 this._refs.addAll(vRefsList);
\r
458 * Sets the value of '_refs' by setting it to the given Vector.
\r
459 * No type checking is performed.
\r
462 * @param refsVector the Vector to set.
\r
464 public void setRefsAsReference(
\r
465 final java.util.Vector refsVector) {
\r
466 this._refs = refsVector;
\r
470 * Method unmarshal.
\r
473 * @throws org.exolab.castor.xml.MarshalException if object is
\r
474 * null or if any SAXException is thrown during marshaling
\r
475 * @throws org.exolab.castor.xml.ValidationException if this
\r
476 * object is an invalid instance according to the schema
\r
477 * @return the unmarshaled
\r
478 * uk.ac.vamsas.objects.core.ReferenceType
\r
480 public static uk.ac.vamsas.objects.core.ReferenceType unmarshal(
\r
481 final java.io.Reader reader)
\r
482 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
483 return (uk.ac.vamsas.objects.core.ReferenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.ReferenceType.class, reader);
\r
489 * @throws org.exolab.castor.xml.ValidationException if this
\r
490 * object is an invalid instance according to the schema
\r
492 public void validate(
\r
494 throws org.exolab.castor.xml.ValidationException {
\r
495 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
496 validator.validate(this);
\r