2 * This file is part of the Vamsas Client version 0.1.
3 * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite,
4 * Andrew Waterhouse and Dominik Lindner.
6 * Earlier versions have also been incorporated into Jalview version 2.4
7 * since 2008, and TOPALi version 2 since 2007.
9 * The Vamsas Client is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * The Vamsas Client is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.
22 package uk.ac.vamsas.objects.core;
24 //---------------------------------/
25 //- Imported classes and packages -/
26 //---------------------------------/
28 import org.exolab.castor.xml.Marshaller;
29 import org.exolab.castor.xml.Unmarshaller;
34 * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007)
37 public class Newick extends uk.ac.vamsas.client.Vobject implements
38 java.io.Serializable {
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
45 * internal content storage
47 private java.lang.String _content = "";
52 private java.lang.String _title;
55 * Primary Key for vamsas object referencing
58 private java.lang.String _id;
63 private java.lang.String _modifiable;
79 * Overrides the java.lang.Object.equals method.
82 * @return true if the objects are equal.
84 public boolean equals(final java.lang.Object obj) {
88 if (super.equals(obj) == false)
91 if (obj instanceof Newick) {
93 Newick temp = (Newick) obj;
96 if (this._content != null) {
97 if (temp._content == null)
99 if (this._content != temp._content) {
100 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content);
101 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content);
102 if (thcycle != tmcycle) {
104 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
108 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
114 if (!this._content.equals(temp._content)) {
115 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
116 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
119 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
120 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
123 } else if (temp._content != null)
125 if (this._title != null) {
126 if (temp._title == null)
128 if (this._title != temp._title) {
129 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._title);
130 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._title);
131 if (thcycle != tmcycle) {
133 org.castor.util.CycleBreaker.releaseCycleHandle(this._title);
137 org.castor.util.CycleBreaker.releaseCycleHandle(temp._title);
143 if (!this._title.equals(temp._title)) {
144 org.castor.util.CycleBreaker.releaseCycleHandle(this._title);
145 org.castor.util.CycleBreaker.releaseCycleHandle(temp._title);
148 org.castor.util.CycleBreaker.releaseCycleHandle(this._title);
149 org.castor.util.CycleBreaker.releaseCycleHandle(temp._title);
152 } else if (temp._title != null)
154 if (this._id != null) {
155 if (temp._id == null)
157 if (this._id != temp._id) {
158 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id);
159 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id);
160 if (thcycle != tmcycle) {
162 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
166 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
172 if (!this._id.equals(temp._id)) {
173 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
174 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
177 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
178 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
181 } else if (temp._id != null)
183 if (this._modifiable != null) {
184 if (temp._modifiable == null)
186 if (this._modifiable != temp._modifiable) {
187 thcycle = org.castor.util.CycleBreaker
188 .startingToCycle(this._modifiable);
189 tmcycle = org.castor.util.CycleBreaker
190 .startingToCycle(temp._modifiable);
191 if (thcycle != tmcycle) {
193 org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable);
197 org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable);
203 if (!this._modifiable.equals(temp._modifiable)) {
204 org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable);
205 org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable);
208 org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable);
209 org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable);
212 } else if (temp._modifiable != null)
220 * Returns the value of field 'content'. The field 'content' has the following
221 * description: internal content storage
223 * @return the value of field 'Content'.
225 public java.lang.String getContent() {
226 return this._content;
230 * Returns the value of field 'id'. The field 'id' has the following
231 * description: Primary Key for vamsas object referencing
234 * @return the value of field 'Id'.
236 public java.lang.String getId() {
241 * Returns the value of field 'modifiable'.
243 * @return the value of field 'Modifiable'.
245 public java.lang.String getModifiable() {
246 return this._modifiable;
250 * Returns the value of field 'title'.
252 * @return the value of field 'Title'.
254 public java.lang.String getTitle() {
259 * Overrides the java.lang.Object.hashCode method.
261 * The following steps came from <b>Effective Java Programming Language
262 * Guide</b> by Joshua Bloch, Chapter 3
264 * @return a hash code value for the object.
266 public int hashCode() {
267 int result = super.hashCode();
271 && !org.castor.util.CycleBreaker.startingToCycle(_content)) {
272 result = 37 * result + _content.hashCode();
273 org.castor.util.CycleBreaker.releaseCycleHandle(_content);
275 if (_title != null && !org.castor.util.CycleBreaker.startingToCycle(_title)) {
276 result = 37 * result + _title.hashCode();
277 org.castor.util.CycleBreaker.releaseCycleHandle(_title);
279 if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
280 result = 37 * result + _id.hashCode();
281 org.castor.util.CycleBreaker.releaseCycleHandle(_id);
283 if (_modifiable != null
284 && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) {
285 result = 37 * result + _modifiable.hashCode();
286 org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable);
295 * @return true if this object is valid according to the schema
297 public boolean isValid() {
300 } catch (org.exolab.castor.xml.ValidationException vex) {
310 * @throws org.exolab.castor.xml.MarshalException
311 * if object is null or if any SAXException is thrown during
313 * @throws org.exolab.castor.xml.ValidationException
314 * if this object is an invalid instance according to the schema
316 public void marshal(final java.io.Writer out)
317 throws org.exolab.castor.xml.MarshalException,
318 org.exolab.castor.xml.ValidationException {
319 Marshaller.marshal(this, out);
326 * @throws java.io.IOException
327 * if an IOException occurs during marshaling
328 * @throws org.exolab.castor.xml.ValidationException
329 * if this object is an invalid instance according to the schema
330 * @throws org.exolab.castor.xml.MarshalException
331 * if object is null or if any SAXException is thrown during
334 public void marshal(final org.xml.sax.ContentHandler handler)
335 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
336 org.exolab.castor.xml.ValidationException {
337 Marshaller.marshal(this, handler);
341 * Sets the value of field 'content'. The field 'content' has the following
342 * description: internal content storage
345 * the value of field 'content'.
347 public void setContent(final java.lang.String content) {
348 this._content = content;
352 * Sets the value of field 'id'. The field 'id' has the following description:
353 * Primary Key for vamsas object referencing
357 * the value of field 'id'.
359 public void setId(final java.lang.String id) {
364 * Sets the value of field 'modifiable'.
367 * the value of field 'modifiable'.
369 public void setModifiable(final java.lang.String modifiable) {
370 this._modifiable = modifiable;
374 * Sets the value of field 'title'.
377 * the value of field 'title'.
379 public void setTitle(final java.lang.String title) {
387 * @throws org.exolab.castor.xml.MarshalException
388 * if object is null or if any SAXException is thrown during
390 * @throws org.exolab.castor.xml.ValidationException
391 * if this object is an invalid instance according to the schema
392 * @return the unmarshaled uk.ac.vamsas.objects.core.Newick
394 public static uk.ac.vamsas.objects.core.Newick unmarshal(
395 final java.io.Reader reader)
396 throws org.exolab.castor.xml.MarshalException,
397 org.exolab.castor.xml.ValidationException {
398 return (uk.ac.vamsas.objects.core.Newick) Unmarshaller.unmarshal(
399 uk.ac.vamsas.objects.core.Newick.class, reader);
405 * @throws org.exolab.castor.xml.ValidationException
406 * if this object is an invalid instance according to the schema
408 public void validate() throws org.exolab.castor.xml.ValidationException {
409 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
410 validator.validate(this);