2 * This file is part of the Vamsas Client version 0.1.
\r
3 * Copyright 2009 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
32 * Two sets of ranges defined between objects - usually sequences, indicating
\r
33 * which regions on each are mapped.
\r
35 * @version $Revision$ $Date$
\r
37 public class MapType extends uk.ac.vamsas.client.Vobject implements
\r
38 java.io.Serializable {
\r
40 // --------------------------/
\r
41 // - Class/Member Variables -/
\r
42 // --------------------------/
\r
46 private uk.ac.vamsas.objects.core.Local _local;
\r
50 private uk.ac.vamsas.objects.core.Mapped _mapped;
\r
52 // ----------------/
\r
53 // - Constructors -/
\r
54 // ----------------/
\r
65 * Overrides the java.lang.Object.equals method.
\r
68 * @return true if the objects are equal.
\r
70 public boolean equals(final java.lang.Object obj) {
\r
74 if (super.equals(obj) == false)
\r
77 if (obj instanceof MapType) {
\r
79 MapType temp = (MapType) obj;
\r
82 if (this._local != null) {
\r
83 if (temp._local == null)
\r
85 if (this._local != temp._local) {
\r
86 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._local);
\r
87 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._local);
\r
88 if (thcycle != tmcycle) {
\r
90 org.castor.util.CycleBreaker.releaseCycleHandle(this._local);
\r
94 org.castor.util.CycleBreaker.releaseCycleHandle(temp._local);
\r
100 if (!this._local.equals(temp._local)) {
\r
101 org.castor.util.CycleBreaker.releaseCycleHandle(this._local);
\r
102 org.castor.util.CycleBreaker.releaseCycleHandle(temp._local);
\r
105 org.castor.util.CycleBreaker.releaseCycleHandle(this._local);
\r
106 org.castor.util.CycleBreaker.releaseCycleHandle(temp._local);
\r
109 } else if (temp._local != null)
\r
111 if (this._mapped != null) {
\r
112 if (temp._mapped == null)
\r
114 if (this._mapped != temp._mapped) {
\r
115 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._mapped);
\r
116 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._mapped);
\r
117 if (thcycle != tmcycle) {
\r
119 org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped);
\r
123 org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped);
\r
129 if (!this._mapped.equals(temp._mapped)) {
\r
130 org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped);
\r
131 org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped);
\r
134 org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped);
\r
135 org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped);
\r
138 } else if (temp._mapped != null)
\r
146 * Returns the value of field 'local'.
\r
148 * @return the value of field 'Local'.
\r
150 public uk.ac.vamsas.objects.core.Local getLocal() {
\r
151 return this._local;
\r
155 * Returns the value of field 'mapped'.
\r
157 * @return the value of field 'Mapped'.
\r
159 public uk.ac.vamsas.objects.core.Mapped getMapped() {
\r
160 return this._mapped;
\r
164 * Overrides the java.lang.Object.hashCode method.
\r
166 * The following steps came from <b>Effective Java Programming Language
\r
167 * Guide</b> by Joshua Bloch, Chapter 3
\r
169 * @return a hash code value for the object.
\r
171 public int hashCode() {
\r
172 int result = super.hashCode();
\r
175 if (_local != null && !org.castor.util.CycleBreaker.startingToCycle(_local)) {
\r
176 result = 37 * result + _local.hashCode();
\r
177 org.castor.util.CycleBreaker.releaseCycleHandle(_local);
\r
179 if (_mapped != null
\r
180 && !org.castor.util.CycleBreaker.startingToCycle(_mapped)) {
\r
181 result = 37 * result + _mapped.hashCode();
\r
182 org.castor.util.CycleBreaker.releaseCycleHandle(_mapped);
\r
191 * @return true if this object is valid according to the schema
\r
193 public boolean isValid() {
\r
196 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
206 * @throws org.exolab.castor.xml.MarshalException
\r
207 * if object is null or if any SAXException is thrown during
\r
209 * @throws org.exolab.castor.xml.ValidationException
\r
210 * if this object is an invalid instance according to the schema
\r
212 public void marshal(final java.io.Writer out)
\r
213 throws org.exolab.castor.xml.MarshalException,
\r
214 org.exolab.castor.xml.ValidationException {
\r
215 Marshaller.marshal(this, out);
\r
222 * @throws java.io.IOException
\r
223 * if an IOException occurs during marshaling
\r
224 * @throws org.exolab.castor.xml.ValidationException
\r
225 * if this object is an invalid instance according to the schema
\r
226 * @throws org.exolab.castor.xml.MarshalException
\r
227 * if object is null or if any SAXException is thrown during
\r
230 public void marshal(final org.xml.sax.ContentHandler handler)
\r
231 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
232 org.exolab.castor.xml.ValidationException {
\r
233 Marshaller.marshal(this, handler);
\r
237 * Sets the value of field 'local'.
\r
240 * the value of field 'local'.
\r
242 public void setLocal(final uk.ac.vamsas.objects.core.Local local) {
\r
243 this._local = local;
\r
247 * Sets the value of field 'mapped'.
\r
250 * the value of field 'mapped'.
\r
252 public void setMapped(final uk.ac.vamsas.objects.core.Mapped mapped) {
\r
253 this._mapped = mapped;
\r
257 * Method unmarshal.
\r
260 * @throws org.exolab.castor.xml.MarshalException
\r
261 * if object is null or if any SAXException is thrown during
\r
263 * @throws org.exolab.castor.xml.ValidationException
\r
264 * if this object is an invalid instance according to the schema
\r
265 * @return the unmarshaled uk.ac.vamsas.objects.core.MapType
\r
267 public static uk.ac.vamsas.objects.core.MapType unmarshal(
\r
268 final java.io.Reader reader)
\r
269 throws org.exolab.castor.xml.MarshalException,
\r
270 org.exolab.castor.xml.ValidationException {
\r
271 return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal(
\r
272 uk.ac.vamsas.objects.core.MapType.class, reader);
\r
278 * @throws org.exolab.castor.xml.ValidationException
\r
279 * if this object is an invalid instance according to the schema
\r
281 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
282 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
283 validator.validate(this);
\r