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 * Class SequenceMapping.
\r
34 * @version $Revision$ $Date$
\r
36 public class SequenceMapping extends uk.ac.vamsas.objects.core.MapType
\r
37 implements java.io.Serializable {
\r
39 // --------------------------/
\r
40 // - Class/Member Variables -/
\r
41 // --------------------------/
\r
44 * Object on which the local range is defined.
\r
46 private java.lang.Object _loc;
\r
49 * Object on which the mapped range is defined.
\r
51 private java.lang.Object _map;
\r
56 private java.lang.String _id;
\r
59 * Field _provenance.
\r
61 private uk.ac.vamsas.objects.core.Provenance _provenance;
\r
63 // ----------------/
\r
64 // - Constructors -/
\r
65 // ----------------/
\r
67 public SequenceMapping() {
\r
76 * Overrides the java.lang.Object.equals method.
\r
79 * @return true if the objects are equal.
\r
81 public boolean equals(final java.lang.Object obj) {
\r
85 if (super.equals(obj) == false)
\r
88 if (obj instanceof SequenceMapping) {
\r
90 SequenceMapping temp = (SequenceMapping) obj;
\r
93 if (this._loc != null) {
\r
94 if (temp._loc == null)
\r
96 if (this._loc != temp._loc) {
\r
97 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._loc);
\r
98 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._loc);
\r
99 if (thcycle != tmcycle) {
\r
101 org.castor.util.CycleBreaker.releaseCycleHandle(this._loc);
\r
105 org.castor.util.CycleBreaker.releaseCycleHandle(temp._loc);
\r
111 if (!this._loc.equals(temp._loc)) {
\r
112 org.castor.util.CycleBreaker.releaseCycleHandle(this._loc);
\r
113 org.castor.util.CycleBreaker.releaseCycleHandle(temp._loc);
\r
116 org.castor.util.CycleBreaker.releaseCycleHandle(this._loc);
\r
117 org.castor.util.CycleBreaker.releaseCycleHandle(temp._loc);
\r
120 } else if (temp._loc != null)
\r
122 if (this._map != null) {
\r
123 if (temp._map == null)
\r
125 if (this._map != temp._map) {
\r
126 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._map);
\r
127 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._map);
\r
128 if (thcycle != tmcycle) {
\r
130 org.castor.util.CycleBreaker.releaseCycleHandle(this._map);
\r
134 org.castor.util.CycleBreaker.releaseCycleHandle(temp._map);
\r
140 if (!this._map.equals(temp._map)) {
\r
141 org.castor.util.CycleBreaker.releaseCycleHandle(this._map);
\r
142 org.castor.util.CycleBreaker.releaseCycleHandle(temp._map);
\r
145 org.castor.util.CycleBreaker.releaseCycleHandle(this._map);
\r
146 org.castor.util.CycleBreaker.releaseCycleHandle(temp._map);
\r
149 } else if (temp._map != null)
\r
151 if (this._id != null) {
\r
152 if (temp._id == null)
\r
154 if (this._id != temp._id) {
\r
155 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id);
\r
156 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id);
\r
157 if (thcycle != tmcycle) {
\r
159 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
\r
163 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
\r
169 if (!this._id.equals(temp._id)) {
\r
170 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
\r
171 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
\r
174 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
\r
175 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
\r
178 } else if (temp._id != null)
\r
180 if (this._provenance != null) {
\r
181 if (temp._provenance == null)
\r
183 if (this._provenance != temp._provenance) {
\r
184 thcycle = org.castor.util.CycleBreaker
\r
185 .startingToCycle(this._provenance);
\r
186 tmcycle = org.castor.util.CycleBreaker
\r
187 .startingToCycle(temp._provenance);
\r
188 if (thcycle != tmcycle) {
\r
190 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
\r
194 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
\r
200 if (!this._provenance.equals(temp._provenance)) {
\r
201 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
\r
202 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
\r
205 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
\r
206 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
\r
209 } else if (temp._provenance != null)
\r
217 * Returns the value of field 'id'.
\r
219 * @return the value of field 'Id'.
\r
221 public java.lang.String getId() {
\r
226 * Returns the value of field 'loc'. The field 'loc' has the following
\r
227 * description: Object on which the local range is defined.
\r
229 * @return the value of field 'Loc'.
\r
231 public java.lang.Object getLoc() {
\r
236 * Returns the value of field 'map'. The field 'map' has the following
\r
237 * description: Object on which the mapped range is defined.
\r
239 * @return the value of field 'Map'.
\r
241 public java.lang.Object getMap() {
\r
246 * Returns the value of field 'provenance'.
\r
248 * @return the value of field 'Provenance'.
\r
250 public uk.ac.vamsas.objects.core.Provenance getProvenance() {
\r
251 return this._provenance;
\r
255 * Overrides the java.lang.Object.hashCode method.
\r
257 * The following steps came from <b>Effective Java Programming Language
\r
258 * Guide</b> by Joshua Bloch, Chapter 3
\r
260 * @return a hash code value for the object.
\r
262 public int hashCode() {
\r
263 int result = super.hashCode();
\r
266 if (_loc != null && !org.castor.util.CycleBreaker.startingToCycle(_loc)) {
\r
267 result = 37 * result + _loc.hashCode();
\r
268 org.castor.util.CycleBreaker.releaseCycleHandle(_loc);
\r
270 if (_map != null && !org.castor.util.CycleBreaker.startingToCycle(_map)) {
\r
271 result = 37 * result + _map.hashCode();
\r
272 org.castor.util.CycleBreaker.releaseCycleHandle(_map);
\r
274 if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
\r
275 result = 37 * result + _id.hashCode();
\r
276 org.castor.util.CycleBreaker.releaseCycleHandle(_id);
\r
278 if (_provenance != null
\r
279 && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {
\r
280 result = 37 * result + _provenance.hashCode();
\r
281 org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);
\r
290 * @return true if this object is valid according to the schema
\r
292 public boolean isValid() {
\r
295 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
305 * @throws org.exolab.castor.xml.MarshalException
\r
306 * if object is null or if any SAXException is thrown during
\r
308 * @throws org.exolab.castor.xml.ValidationException
\r
309 * if this object is an invalid instance according to the schema
\r
311 public void marshal(final java.io.Writer out)
\r
312 throws org.exolab.castor.xml.MarshalException,
\r
313 org.exolab.castor.xml.ValidationException {
\r
314 Marshaller.marshal(this, out);
\r
321 * @throws java.io.IOException
\r
322 * if an IOException occurs during marshaling
\r
323 * @throws org.exolab.castor.xml.ValidationException
\r
324 * if this object is an invalid instance according to the schema
\r
325 * @throws org.exolab.castor.xml.MarshalException
\r
326 * if object is null or if any SAXException is thrown during
\r
329 public void marshal(final org.xml.sax.ContentHandler handler)
\r
330 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
331 org.exolab.castor.xml.ValidationException {
\r
332 Marshaller.marshal(this, handler);
\r
336 * Sets the value of field 'id'.
\r
339 * the value of field 'id'.
\r
341 public void setId(final java.lang.String id) {
\r
346 * Sets the value of field 'loc'. The field 'loc' has the following
\r
347 * description: Object on which the local range is defined.
\r
350 * the value of field 'loc'.
\r
352 public void setLoc(final java.lang.Object loc) {
\r
357 * Sets the value of field 'map'. The field 'map' has the following
\r
358 * description: Object on which the mapped range is defined.
\r
361 * the value of field 'map'.
\r
363 public void setMap(final java.lang.Object map) {
\r
368 * Sets the value of field 'provenance'.
\r
370 * @param provenance
\r
371 * the value of field 'provenance'.
\r
373 public void setProvenance(
\r
374 final uk.ac.vamsas.objects.core.Provenance provenance) {
\r
375 this._provenance = provenance;
\r
379 * Method unmarshal.
\r
382 * @throws org.exolab.castor.xml.MarshalException
\r
383 * if object is null or if any SAXException is thrown during
\r
385 * @throws org.exolab.castor.xml.ValidationException
\r
386 * if this object is an invalid instance according to the schema
\r
387 * @return the unmarshaled uk.ac.vamsas.objects.core.MapType
\r
389 public static uk.ac.vamsas.objects.core.MapType unmarshal(
\r
390 final java.io.Reader reader)
\r
391 throws org.exolab.castor.xml.MarshalException,
\r
392 org.exolab.castor.xml.ValidationException {
\r
393 return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal(
\r
394 uk.ac.vamsas.objects.core.SequenceMapping.class, reader);
\r
400 * @throws org.exolab.castor.xml.ValidationException
\r
401 * if this object is an invalid instance according to the schema
\r
403 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
404 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
405 validator.validate(this);
\r