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 representations and
\r
19 * vamsas document objects
\r
22 * @version $Revision$ $Date$
\r
24 public class Treenode extends uk.ac.vamsas.objects.core.NodeType
\r
25 implements java.io.Serializable
\r
29 //--------------------------/
\r
30 //- Class/Member Variables -/
\r
31 //--------------------------/
\r
34 * reference to one or more trees containing the node being
\r
38 private java.util.Vector _treeId;
\r
41 * String uniquely identifying a particular node in the
\r
42 * referenced tree according to the format of the tree
\r
43 * representation that is referenced.
\r
46 private java.lang.String _nodespec;
\r
55 this._treeId = new java.util.Vector();
\r
67 * @throws java.lang.IndexOutOfBoundsException if the index
\r
68 * given is outside the bounds of the collection
\r
70 public void addTreeId(
\r
71 final java.lang.Object vTreeId)
\r
72 throws java.lang.IndexOutOfBoundsException {
\r
73 this._treeId.addElement(vTreeId);
\r
81 * @throws java.lang.IndexOutOfBoundsException if the index
\r
82 * given is outside the bounds of the collection
\r
84 public void addTreeId(
\r
86 final java.lang.Object vTreeId)
\r
87 throws java.lang.IndexOutOfBoundsException {
\r
88 this._treeId.add(index, vTreeId);
\r
92 * Method enumerateTreeId.
\r
94 * @return an Enumeration over all java.lang.Object elements
\r
96 public java.util.Enumeration enumerateTreeId(
\r
98 return this._treeId.elements();
\r
102 * Overrides the java.lang.Object.equals method.
\r
105 * @return true if the objects are equal.
\r
107 public boolean equals(
\r
108 final java.lang.Object obj) {
\r
112 if (super.equals(obj)==false)
\r
115 if (obj instanceof Treenode) {
\r
117 Treenode temp = (Treenode)obj;
\r
118 if (this._treeId != null) {
\r
119 if (temp._treeId == null) return false;
\r
120 else if (!(this._treeId.equals(temp._treeId)))
\r
123 else if (temp._treeId != null)
\r
125 if (this._nodespec != null) {
\r
126 if (temp._nodespec == null) return false;
\r
127 else if (!(this._nodespec.equals(temp._nodespec)))
\r
130 else if (temp._nodespec != null)
\r
138 * Returns the value of field 'nodespec'. The field 'nodespec'
\r
139 * has the following description: String uniquely identifying a
\r
140 * particular node in the referenced tree according to the
\r
141 * format of the tree representation that is referenced.
\r
144 * @return the value of field 'Nodespec'.
\r
146 public java.lang.String getNodespec(
\r
148 return this._nodespec;
\r
152 * Method getTreeId.
\r
155 * @throws java.lang.IndexOutOfBoundsException if the index
\r
156 * given is outside the bounds of the collection
\r
157 * @return the value of the java.lang.Object at the given index
\r
159 public java.lang.Object getTreeId(
\r
161 throws java.lang.IndexOutOfBoundsException {
\r
162 // check bounds for index
\r
163 if (index < 0 || index >= this._treeId.size()) {
\r
164 throw new IndexOutOfBoundsException("getTreeId: Index value '" + index + "' not in range [0.." + (this._treeId.size() - 1) + "]");
\r
167 return _treeId.get(index);
\r
171 * Method getTreeId.Returns the contents of the collection in
\r
172 * an Array. <p>Note: Just in case the collection contents
\r
173 * are changing in another thread, we pass a 0-length Array of
\r
174 * the correct type into the API call. This way we <i>know</i>
\r
175 * that the Array returned is of exactly the correct length.
\r
177 * @return this collection as an Array
\r
179 public java.lang.Object[] getTreeId(
\r
181 java.lang.Object[] array = new java.lang.Object[0];
\r
182 return (java.lang.Object[]) this._treeId.toArray(array);
\r
186 * Method getTreeIdAsReference.Returns a reference to
\r
187 * '_treeId'. No type checking is performed on any
\r
188 * modifications to the Vector.
\r
190 * @return a reference to the Vector backing this class
\r
192 public java.util.Vector getTreeIdAsReference(
\r
194 return this._treeId;
\r
198 * Method getTreeIdCount.
\r
200 * @return the size of this collection
\r
202 public int getTreeIdCount(
\r
204 return this._treeId.size();
\r
208 * Overrides the java.lang.Object.hashCode method.
\r
210 * The following steps came from <b>Effective Java Programming
\r
211 * Language Guide</b> by Joshua Bloch, Chapter 3
\r
213 * @return a hash code value for the object.
\r
215 public int hashCode(
\r
217 int result = super.hashCode();
\r
220 if (_treeId != null) {
\r
221 result = 37 * result + _treeId.hashCode();
\r
223 if (_nodespec != null) {
\r
224 result = 37 * result + _nodespec.hashCode();
\r
233 * @return true if this object is valid according to the schema
\r
235 public boolean isValid(
\r
239 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
249 * @throws org.exolab.castor.xml.MarshalException if object is
\r
250 * null or if any SAXException is thrown during marshaling
\r
251 * @throws org.exolab.castor.xml.ValidationException if this
\r
252 * object is an invalid instance according to the schema
\r
254 public void marshal(
\r
255 final java.io.Writer out)
\r
256 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
257 Marshaller.marshal(this, out);
\r
264 * @throws java.io.IOException if an IOException occurs during
\r
266 * @throws org.exolab.castor.xml.ValidationException if this
\r
267 * object is an invalid instance according to the schema
\r
268 * @throws org.exolab.castor.xml.MarshalException if object is
\r
269 * null or if any SAXException is thrown during marshaling
\r
271 public void marshal(
\r
272 final org.xml.sax.ContentHandler handler)
\r
273 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
274 Marshaller.marshal(this, handler);
\r
279 public void removeAllTreeId(
\r
281 this._treeId.clear();
\r
285 * Method removeTreeId.
\r
288 * @return true if the object was removed from the collection.
\r
290 public boolean removeTreeId(
\r
291 final java.lang.Object vTreeId) {
\r
292 boolean removed = _treeId.remove(vTreeId);
\r
297 * Method removeTreeIdAt.
\r
300 * @return the element removed from the collection
\r
302 public java.lang.Object removeTreeIdAt(
\r
304 java.lang.Object obj = this._treeId.remove(index);
\r
309 * Sets the value of field 'nodespec'. The field 'nodespec' has
\r
310 * the following description: String uniquely identifying a
\r
311 * particular node in the referenced tree according to the
\r
312 * format of the tree representation that is referenced.
\r
315 * @param nodespec the value of field 'nodespec'.
\r
317 public void setNodespec(
\r
318 final java.lang.String nodespec) {
\r
319 this._nodespec = nodespec;
\r
327 * @throws java.lang.IndexOutOfBoundsException if the index
\r
328 * given is outside the bounds of the collection
\r
330 public void setTreeId(
\r
332 final java.lang.Object vTreeId)
\r
333 throws java.lang.IndexOutOfBoundsException {
\r
334 // check bounds for index
\r
335 if (index < 0 || index >= this._treeId.size()) {
\r
336 throw new IndexOutOfBoundsException("setTreeId: Index value '" + index + "' not in range [0.." + (this._treeId.size() - 1) + "]");
\r
339 this._treeId.set(index, vTreeId);
\r
345 * @param vTreeIdArray
\r
347 public void setTreeId(
\r
348 final java.lang.Object[] vTreeIdArray) {
\r
352 for (int i = 0; i < vTreeIdArray.length; i++) {
\r
353 this._treeId.add(vTreeIdArray[i]);
\r
358 * Sets the value of '_treeId' by copying the given Vector. All
\r
359 * elements will be checked for type safety.
\r
361 * @param vTreeIdList the Vector to copy.
\r
363 public void setTreeId(
\r
364 final java.util.Vector vTreeIdList) {
\r
366 this._treeId.clear();
\r
368 this._treeId.addAll(vTreeIdList);
\r
372 * Sets the value of '_treeId' by setting it to the given
\r
373 * Vector. No type checking is performed.
\r
376 * @param treeIdVector the Vector to set.
\r
378 public void setTreeIdAsReference(
\r
379 final java.util.Vector treeIdVector) {
\r
380 this._treeId = treeIdVector;
\r
384 * Method unmarshal.
\r
387 * @throws org.exolab.castor.xml.MarshalException if object is
\r
388 * null or if any SAXException is thrown during marshaling
\r
389 * @throws org.exolab.castor.xml.ValidationException if this
\r
390 * object is an invalid instance according to the schema
\r
391 * @return the unmarshaled uk.ac.vamsas.objects.core.NodeType
\r
393 public static uk.ac.vamsas.objects.core.NodeType unmarshal(
\r
394 final java.io.Reader reader)
\r
395 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
396 return (uk.ac.vamsas.objects.core.NodeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Treenode.class, reader);
\r
402 * @throws org.exolab.castor.xml.ValidationException if this
\r
403 * object is an invalid instance according to the schema
\r
405 public void validate(
\r
407 throws org.exolab.castor.xml.ValidationException {
\r
408 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
409 validator.validate(this);
\r