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 * node identity and mapping data between tree
\r
19 * representations and vamsas document objects
\r
21 * @version $Revision$ $Date$
\r
23 public class Treenode extends uk.ac.vamsas.objects.core.NodeType
\r
24 implements java.io.Serializable
\r
28 //--------------------------/
\r
29 //- Class/Member Variables -/
\r
30 //--------------------------/
\r
33 * reference to one or more trees containing
\r
34 * the node being described.
\r
36 private java.util.Vector _treeId;
\r
39 * String uniquely identifying a particular
\r
40 * node in the referenced tree according to the format of
\r
41 * the tree representation that is referenced.
\r
44 private java.lang.String _nodespec;
\r
53 this._treeId = new java.util.Vector();
\r
65 * @throws java.lang.IndexOutOfBoundsException if the index
\r
66 * given is outside the bounds of the collection
\r
68 public void addTreeId(
\r
69 final java.lang.Object vTreeId)
\r
70 throws java.lang.IndexOutOfBoundsException {
\r
71 this._treeId.addElement(vTreeId);
\r
79 * @throws java.lang.IndexOutOfBoundsException if the index
\r
80 * given is outside the bounds of the collection
\r
82 public void addTreeId(
\r
84 final java.lang.Object vTreeId)
\r
85 throws java.lang.IndexOutOfBoundsException {
\r
86 this._treeId.add(index, vTreeId);
\r
90 * Method enumerateTreeId.
\r
92 * @return an Enumeration over all java.lang.Object elements
\r
94 public java.util.Enumeration enumerateTreeId(
\r
96 return this._treeId.elements();
\r
100 * Overrides the java.lang.Object.equals method.
\r
103 * @return true if the objects are equal.
\r
105 public boolean equals(
\r
106 final java.lang.Object obj) {
\r
110 if (super.equals(obj)==false)
\r
113 if (obj instanceof Treenode) {
\r
115 Treenode temp = (Treenode)obj;
\r
118 if (this._treeId != null) {
\r
119 if (temp._treeId == null) return false;
\r
120 if (this._treeId != temp._treeId) {
\r
121 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._treeId);
\r
122 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._treeId);
\r
123 if (thcycle!=tmcycle) {
\r
124 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); };
\r
125 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); };
\r
129 if (!this._treeId.equals(temp._treeId)) {
\r
130 org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId);
\r
131 org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId);
\r
134 org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId);
\r
135 org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId);
\r
138 } else if (temp._treeId != null)
\r
140 if (this._nodespec != null) {
\r
141 if (temp._nodespec == null) return false;
\r
142 if (this._nodespec != temp._nodespec) {
\r
143 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._nodespec);
\r
144 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._nodespec);
\r
145 if (thcycle!=tmcycle) {
\r
146 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); };
\r
147 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); };
\r
151 if (!this._nodespec.equals(temp._nodespec)) {
\r
152 org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec);
\r
153 org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec);
\r
156 org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec);
\r
157 org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec);
\r
160 } else if (temp._nodespec != null)
\r
168 * Returns the value of field 'nodespec'. The field 'nodespec'
\r
169 * has the following description: String uniquely identifying a
\r
171 * node in the referenced tree according to the format of
\r
172 * the tree representation that is referenced.
\r
175 * @return the value of field 'Nodespec'.
\r
177 public java.lang.String getNodespec(
\r
179 return this._nodespec;
\r
183 * Method getTreeId.
\r
186 * @throws java.lang.IndexOutOfBoundsException if the index
\r
187 * given is outside the bounds of the collection
\r
188 * @return the value of the java.lang.Object at the given index
\r
190 public java.lang.Object getTreeId(
\r
192 throws java.lang.IndexOutOfBoundsException {
\r
193 // check bounds for index
\r
194 if (index < 0 || index >= this._treeId.size()) {
\r
195 throw new IndexOutOfBoundsException("getTreeId: Index value '" + index + "' not in range [0.." + (this._treeId.size() - 1) + "]");
\r
198 return _treeId.get(index);
\r
202 * Method getTreeId.Returns the contents of the collection in
\r
203 * an Array. <p>Note: Just in case the collection contents
\r
204 * are changing in another thread, we pass a 0-length Array of
\r
205 * the correct type into the API call. This way we <i>know</i>
\r
206 * that the Array returned is of exactly the correct length.
\r
208 * @return this collection as an Array
\r
210 public java.lang.Object[] getTreeId(
\r
212 java.lang.Object[] array = new java.lang.Object[0];
\r
213 return (java.lang.Object[]) this._treeId.toArray(array);
\r
217 * Method getTreeIdAsReference.Returns a reference to
\r
218 * '_treeId'. No type checking is performed on any
\r
219 * modifications to the Vector.
\r
221 * @return a reference to the Vector backing this class
\r
223 public java.util.Vector getTreeIdAsReference(
\r
225 return this._treeId;
\r
229 * Method getTreeIdCount.
\r
231 * @return the size of this collection
\r
233 public int getTreeIdCount(
\r
235 return this._treeId.size();
\r
239 * Overrides the java.lang.Object.hashCode method.
\r
241 * The following steps came from <b>Effective Java Programming
\r
242 * Language Guide</b> by Joshua Bloch, Chapter 3
\r
244 * @return a hash code value for the object.
\r
246 public int hashCode(
\r
248 int result = super.hashCode();
\r
251 if (_treeId != null
\r
252 && !org.castor.util.CycleBreaker.startingToCycle(_treeId)) {
\r
253 result = 37 * result + _treeId.hashCode();
\r
254 org.castor.util.CycleBreaker.releaseCycleHandle(_treeId);
\r
256 if (_nodespec != null
\r
257 && !org.castor.util.CycleBreaker.startingToCycle(_nodespec)) {
\r
258 result = 37 * result + _nodespec.hashCode();
\r
259 org.castor.util.CycleBreaker.releaseCycleHandle(_nodespec);
\r
268 * @return true if this object is valid according to the schema
\r
270 public boolean isValid(
\r
274 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
284 * @throws org.exolab.castor.xml.MarshalException if object is
\r
285 * null or if any SAXException is thrown during marshaling
\r
286 * @throws org.exolab.castor.xml.ValidationException if this
\r
287 * object is an invalid instance according to the schema
\r
289 public void marshal(
\r
290 final java.io.Writer out)
\r
291 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
292 Marshaller.marshal(this, out);
\r
299 * @throws java.io.IOException if an IOException occurs during
\r
301 * @throws org.exolab.castor.xml.ValidationException if this
\r
302 * object is an invalid instance according to the schema
\r
303 * @throws org.exolab.castor.xml.MarshalException if object is
\r
304 * null or if any SAXException is thrown during marshaling
\r
306 public void marshal(
\r
307 final org.xml.sax.ContentHandler handler)
\r
308 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
309 Marshaller.marshal(this, handler);
\r
314 public void removeAllTreeId(
\r
316 this._treeId.clear();
\r
320 * Method removeTreeId.
\r
323 * @return true if the object was removed from the collection.
\r
325 public boolean removeTreeId(
\r
326 final java.lang.Object vTreeId) {
\r
327 boolean removed = _treeId.remove(vTreeId);
\r
332 * Method removeTreeIdAt.
\r
335 * @return the element removed from the collection
\r
337 public java.lang.Object removeTreeIdAt(
\r
339 java.lang.Object obj = this._treeId.remove(index);
\r
344 * Sets the value of field 'nodespec'. The field 'nodespec' has
\r
345 * the following description: String uniquely identifying a
\r
347 * node in the referenced tree according to the format of
\r
348 * the tree representation that is referenced.
\r
351 * @param nodespec the value of field 'nodespec'.
\r
353 public void setNodespec(
\r
354 final java.lang.String nodespec) {
\r
355 this._nodespec = nodespec;
\r
363 * @throws java.lang.IndexOutOfBoundsException if the index
\r
364 * given is outside the bounds of the collection
\r
366 public void setTreeId(
\r
368 final java.lang.Object vTreeId)
\r
369 throws java.lang.IndexOutOfBoundsException {
\r
370 // check bounds for index
\r
371 if (index < 0 || index >= this._treeId.size()) {
\r
372 throw new IndexOutOfBoundsException("setTreeId: Index value '" + index + "' not in range [0.." + (this._treeId.size() - 1) + "]");
\r
375 this._treeId.set(index, vTreeId);
\r
381 * @param vTreeIdArray
\r
383 public void setTreeId(
\r
384 final java.lang.Object[] vTreeIdArray) {
\r
388 for (int i = 0; i < vTreeIdArray.length; i++) {
\r
389 this._treeId.add(vTreeIdArray[i]);
\r
394 * Sets the value of '_treeId' by copying the given Vector. All
\r
395 * elements will be checked for type safety.
\r
397 * @param vTreeIdList the Vector to copy.
\r
399 public void setTreeId(
\r
400 final java.util.Vector vTreeIdList) {
\r
402 this._treeId.clear();
\r
404 this._treeId.addAll(vTreeIdList);
\r
408 * Sets the value of '_treeId' by setting it to the given
\r
409 * Vector. No type checking is performed.
\r
412 * @param treeIdVector the Vector to set.
\r
414 public void setTreeIdAsReference(
\r
415 final java.util.Vector treeIdVector) {
\r
416 this._treeId = treeIdVector;
\r
420 * Method unmarshal.
\r
423 * @throws org.exolab.castor.xml.MarshalException if object is
\r
424 * null or if any SAXException is thrown during marshaling
\r
425 * @throws org.exolab.castor.xml.ValidationException if this
\r
426 * object is an invalid instance according to the schema
\r
427 * @return the unmarshaled uk.ac.vamsas.objects.core.NodeType
\r
429 public static uk.ac.vamsas.objects.core.NodeType unmarshal(
\r
430 final java.io.Reader reader)
\r
431 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
432 return (uk.ac.vamsas.objects.core.NodeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Treenode.class, reader);
\r
438 * @throws org.exolab.castor.xml.ValidationException if this
\r
439 * object is an invalid instance according to the schema
\r
441 public void validate(
\r
443 throws org.exolab.castor.xml.ValidationException {
\r
444 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
445 validator.validate(this);
\r