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 MapRangeType.
\r
34 * @version $Revision$ $Date$
\r
36 public class MapRangeType extends uk.ac.vamsas.objects.core.RangeType implements
\r
37 java.io.Serializable {
\r
39 // --------------------------/
\r
40 // - Class/Member Variables -/
\r
41 // --------------------------/
\r
44 * number of dictionary symbol widths involved in each mapped position on this
\r
45 * sequence (for example, 3 for a dna sequence exon region that is being
\r
46 * mapped to a protein sequence). This is optional, since the unit can be
\r
47 * usually be inferred from the dictionary type of each sequence involved in
\r
53 * keeps track of state for field: _unit
\r
55 private boolean _has_unit;
\r
57 // ----------------/
\r
58 // - Constructors -/
\r
59 // ----------------/
\r
61 public MapRangeType() {
\r
71 public void deleteUnit() {
\r
72 this._has_unit = false;
\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 MapRangeType) {
\r
90 MapRangeType temp = (MapRangeType) obj;
\r
93 if (this._unit != temp._unit)
\r
95 if (this._has_unit != temp._has_unit)
\r
103 * Returns the value of field 'unit'. The field 'unit' has the following
\r
104 * description: number of dictionary symbol widths involved in each mapped
\r
105 * position on this sequence (for example, 3 for a dna sequence exon region
\r
106 * that is being mapped to a protein sequence). This is optional, since the
\r
107 * unit can be usually be inferred from the dictionary type of each sequence
\r
108 * involved in the mapping.
\r
110 * @return the value of field 'Unit'.
\r
112 public long getUnit() {
\r
119 * @return true if at least one Unit has been added
\r
121 public boolean hasUnit() {
\r
122 return this._has_unit;
\r
126 * Overrides the java.lang.Object.hashCode method.
\r
128 * The following steps came from <b>Effective Java Programming Language
\r
129 * Guide</b> by Joshua Bloch, Chapter 3
\r
131 * @return a hash code value for the object.
\r
133 public int hashCode() {
\r
134 int result = super.hashCode();
\r
137 result = 37 * result + (int) (_unit ^ (_unit >>> 32));
\r
145 * @return true if this object is valid according to the schema
\r
147 public boolean isValid() {
\r
150 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
160 * @throws org.exolab.castor.xml.MarshalException
\r
161 * if object is null or if any SAXException is thrown during
\r
163 * @throws org.exolab.castor.xml.ValidationException
\r
164 * if this object is an invalid instance according to the schema
\r
166 public void marshal(final java.io.Writer out)
\r
167 throws org.exolab.castor.xml.MarshalException,
\r
168 org.exolab.castor.xml.ValidationException {
\r
169 Marshaller.marshal(this, out);
\r
176 * @throws java.io.IOException
\r
177 * if an IOException occurs during marshaling
\r
178 * @throws org.exolab.castor.xml.ValidationException
\r
179 * if this object is an invalid instance according to the schema
\r
180 * @throws org.exolab.castor.xml.MarshalException
\r
181 * if object is null or if any SAXException is thrown during
\r
184 public void marshal(final org.xml.sax.ContentHandler handler)
\r
185 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
186 org.exolab.castor.xml.ValidationException {
\r
187 Marshaller.marshal(this, handler);
\r
191 * Sets the value of field 'unit'. The field 'unit' has the following
\r
192 * description: number of dictionary symbol widths involved in each mapped
\r
193 * position on this sequence (for example, 3 for a dna sequence exon region
\r
194 * that is being mapped to a protein sequence). This is optional, since the
\r
195 * unit can be usually be inferred from the dictionary type of each sequence
\r
196 * involved in the mapping.
\r
199 * the value of field 'unit'.
\r
201 public void setUnit(final long unit) {
\r
203 this._has_unit = true;
\r
207 * Method unmarshal.
\r
210 * @throws org.exolab.castor.xml.MarshalException
\r
211 * if object is null or if any SAXException is thrown during
\r
213 * @throws org.exolab.castor.xml.ValidationException
\r
214 * if this object is an invalid instance according to the schema
\r
215 * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType
\r
217 public static uk.ac.vamsas.objects.core.RangeType unmarshal(
\r
218 final java.io.Reader reader)
\r
219 throws org.exolab.castor.xml.MarshalException,
\r
220 org.exolab.castor.xml.ValidationException {
\r
221 return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(
\r
222 uk.ac.vamsas.objects.core.MapRangeType.class, reader);
\r
228 * @throws org.exolab.castor.xml.ValidationException
\r
229 * if this object is an invalid instance according to the schema
\r
231 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
232 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
233 validator.validate(this);
\r