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 * the local mapType maps from the parent sequence coordinate frame to the
\r
33 * reference frame defined by the dbRef element. The mapped mapType is the
\r
34 * mapped range defined on the dbRef element's reference frame. Conventionally,
\r
35 * the unit attribute defaults to 1, or will be inferred from the local
\r
36 * sequence's dictionary type and any dictionary type associated with the
\r
37 * database being mapped to. However, it may be used to avoid ambiguity.
\r
40 * @version $Revision$ $Date$
\r
42 public class Map extends uk.ac.vamsas.objects.core.MapType implements
\r
43 java.io.Serializable {
\r
45 // --------------------------/
\r
46 // - Class/Member Variables -/
\r
47 // --------------------------/
\r
52 private java.lang.String _id;
\r
54 // ----------------/
\r
55 // - Constructors -/
\r
56 // ----------------/
\r
67 * Overrides the java.lang.Object.equals method.
\r
70 * @return true if the objects are equal.
\r
72 public boolean equals(final java.lang.Object obj) {
\r
76 if (super.equals(obj) == false)
\r
79 if (obj instanceof Map) {
\r
81 Map temp = (Map) obj;
\r
84 if (this._id != null) {
\r
85 if (temp._id == null)
\r
87 if (this._id != temp._id) {
\r
88 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id);
\r
89 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id);
\r
90 if (thcycle != tmcycle) {
\r
92 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
\r
96 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
\r
102 if (!this._id.equals(temp._id)) {
\r
103 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
\r
104 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
\r
107 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
\r
108 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
\r
111 } else if (temp._id != null)
\r
119 * Returns the value of field 'id'.
\r
121 * @return the value of field 'Id'.
\r
123 public java.lang.String getId() {
\r
128 * Overrides the java.lang.Object.hashCode method.
\r
130 * The following steps came from <b>Effective Java Programming Language
\r
131 * Guide</b> by Joshua Bloch, Chapter 3
\r
133 * @return a hash code value for the object.
\r
135 public int hashCode() {
\r
136 int result = super.hashCode();
\r
139 if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
\r
140 result = 37 * result + _id.hashCode();
\r
141 org.castor.util.CycleBreaker.releaseCycleHandle(_id);
\r
150 * @return true if this object is valid according to the schema
\r
152 public boolean isValid() {
\r
155 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
165 * @throws org.exolab.castor.xml.MarshalException
\r
166 * if object is null or if any SAXException is thrown during
\r
168 * @throws org.exolab.castor.xml.ValidationException
\r
169 * if this object is an invalid instance according to the schema
\r
171 public void marshal(final java.io.Writer out)
\r
172 throws org.exolab.castor.xml.MarshalException,
\r
173 org.exolab.castor.xml.ValidationException {
\r
174 Marshaller.marshal(this, out);
\r
181 * @throws java.io.IOException
\r
182 * if an IOException occurs during marshaling
\r
183 * @throws org.exolab.castor.xml.ValidationException
\r
184 * if this object is an invalid instance according to the schema
\r
185 * @throws org.exolab.castor.xml.MarshalException
\r
186 * if object is null or if any SAXException is thrown during
\r
189 public void marshal(final org.xml.sax.ContentHandler handler)
\r
190 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
191 org.exolab.castor.xml.ValidationException {
\r
192 Marshaller.marshal(this, handler);
\r
196 * Sets the value of field 'id'.
\r
199 * the value of field 'id'.
\r
201 public void setId(final java.lang.String id) {
\r
206 * Method unmarshal.
\r
209 * @throws org.exolab.castor.xml.MarshalException
\r
210 * if object is null or if any SAXException is thrown during
\r
212 * @throws org.exolab.castor.xml.ValidationException
\r
213 * if this object is an invalid instance according to the schema
\r
214 * @return the unmarshaled uk.ac.vamsas.objects.core.MapType
\r
216 public static uk.ac.vamsas.objects.core.MapType unmarshal(
\r
217 final java.io.Reader reader)
\r
218 throws org.exolab.castor.xml.MarshalException,
\r
219 org.exolab.castor.xml.ValidationException {
\r
220 return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal(
\r
221 uk.ac.vamsas.objects.core.Map.class, reader);
\r
227 * @throws org.exolab.castor.xml.ValidationException
\r
228 * if this object is an invalid instance according to the schema
\r
230 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
231 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
232 validator.validate(this);
\r