2 * This file is part of the Vamsas Client version 0.2.
\r
3 * Copyright 2010 by Jim Procter, Iain Milne, Pierre Marguerite,
\r
4 * Andrew Waterhouse and Dominik Lindner.
\r
6 * Earlier versions have also been incorporated into Jalview version 2.4
\r
7 * since 2008, and TOPALi version 2 since 2007.
\r
9 * The Vamsas Client is free software: you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation, either version 3 of the License, or
\r
12 * (at your option) any later version.
\r
14 * The Vamsas Client is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public License
\r
20 * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.
\r
22 package uk.ac.vamsas.objects.core;
\r
24 //---------------------------------/
\r
25 //- Imported classes and packages -/
\r
26 //---------------------------------/
\r
28 import org.exolab.castor.xml.Marshaller;
\r
29 import org.exolab.castor.xml.Unmarshaller;
\r
34 * @version $Revision$ $Date$
\r
36 public class Instance extends uk.ac.vamsas.objects.core.AppData implements
\r
37 java.io.Serializable {
\r
39 // --------------------------/
\r
40 // - Class/Member Variables -/
\r
41 // --------------------------/
\r
46 private java.lang.String _urn;
\r
48 // ----------------/
\r
49 // - Constructors -/
\r
50 // ----------------/
\r
61 * Overrides the java.lang.Object.equals method.
\r
64 * @return true if the objects are equal.
\r
66 public boolean equals(final java.lang.Object obj) {
\r
70 if (super.equals(obj) == false)
\r
73 if (obj instanceof Instance) {
\r
75 Instance temp = (Instance) obj;
\r
78 if (this._urn != null) {
\r
79 if (temp._urn == null)
\r
81 if (this._urn != temp._urn) {
\r
82 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._urn);
\r
83 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._urn);
\r
84 if (thcycle != tmcycle) {
\r
86 org.castor.util.CycleBreaker.releaseCycleHandle(this._urn);
\r
90 org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn);
\r
96 if (!this._urn.equals(temp._urn)) {
\r
97 org.castor.util.CycleBreaker.releaseCycleHandle(this._urn);
\r
98 org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn);
\r
101 org.castor.util.CycleBreaker.releaseCycleHandle(this._urn);
\r
102 org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn);
\r
105 } else if (temp._urn != null)
\r
113 * Returns the value of field 'urn'.
\r
115 * @return the value of field 'Urn'.
\r
117 public java.lang.String getUrn() {
\r
122 * Overrides the java.lang.Object.hashCode method.
\r
124 * The following steps came from <b>Effective Java Programming Language
\r
125 * Guide</b> by Joshua Bloch, Chapter 3
\r
127 * @return a hash code value for the object.
\r
129 public int hashCode() {
\r
130 int result = super.hashCode();
\r
133 if (_urn != null && !org.castor.util.CycleBreaker.startingToCycle(_urn)) {
\r
134 result = 37 * result + _urn.hashCode();
\r
135 org.castor.util.CycleBreaker.releaseCycleHandle(_urn);
\r
144 * @return true if this object is valid according to the schema
\r
146 public boolean isValid() {
\r
149 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
159 * @throws org.exolab.castor.xml.MarshalException
\r
160 * if object is null or if any SAXException is thrown during
\r
162 * @throws org.exolab.castor.xml.ValidationException
\r
163 * if this object is an invalid instance according to the schema
\r
165 public void marshal(final java.io.Writer out)
\r
166 throws org.exolab.castor.xml.MarshalException,
\r
167 org.exolab.castor.xml.ValidationException {
\r
168 Marshaller.marshal(this, out);
\r
175 * @throws java.io.IOException
\r
176 * if an IOException occurs during marshaling
\r
177 * @throws org.exolab.castor.xml.ValidationException
\r
178 * if this object is an invalid instance according to the schema
\r
179 * @throws org.exolab.castor.xml.MarshalException
\r
180 * if object is null or if any SAXException is thrown during
\r
183 public void marshal(final org.xml.sax.ContentHandler handler)
\r
184 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
185 org.exolab.castor.xml.ValidationException {
\r
186 Marshaller.marshal(this, handler);
\r
190 * Sets the value of field 'urn'.
\r
193 * the value of field 'urn'.
\r
195 public void setUrn(final java.lang.String urn) {
\r
200 * Method unmarshal.
\r
203 * @throws org.exolab.castor.xml.MarshalException
\r
204 * if object is null or if any SAXException is thrown during
\r
206 * @throws org.exolab.castor.xml.ValidationException
\r
207 * if this object is an invalid instance according to the schema
\r
208 * @return the unmarshaled uk.ac.vamsas.objects.core.AppData
\r
210 public static uk.ac.vamsas.objects.core.AppData unmarshal(
\r
211 final java.io.Reader reader)
\r
212 throws org.exolab.castor.xml.MarshalException,
\r
213 org.exolab.castor.xml.ValidationException {
\r
214 return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(
\r
215 uk.ac.vamsas.objects.core.Instance.class, reader);
\r
221 * @throws org.exolab.castor.xml.ValidationException
\r
222 * if this object is an invalid instance according to the schema
\r
224 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
225 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
226 validator.validate(this);
\r