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 * a region from start to end, with flag for inclusivity of terminii
\r
34 * @version $Revision$ $Date$
\r
36 public class Seg extends uk.ac.vamsas.client.Vobject implements
\r
37 java.io.Serializable {
\r
39 // --------------------------/
\r
40 // - Class/Member Variables -/
\r
41 // --------------------------/
\r
49 * keeps track of state for field: _start
\r
51 private boolean _has_start;
\r
59 * keeps track of state for field: _end
\r
61 private boolean _has_end;
\r
64 * when false, a consecutive range like 'start=1, end=2' means the region
\r
65 * lying after position 1 and before position 2
\r
68 private boolean _inclusive;
\r
71 * keeps track of state for field: _inclusive
\r
73 private boolean _has_inclusive;
\r
75 // ----------------/
\r
76 // - Constructors -/
\r
77 // ----------------/
\r
89 public void deleteEnd() {
\r
90 this._has_end = false;
\r
95 public void deleteInclusive() {
\r
96 this._has_inclusive = false;
\r
101 public void deleteStart() {
\r
102 this._has_start = false;
\r
106 * Overrides the java.lang.Object.equals method.
\r
109 * @return true if the objects are equal.
\r
111 public boolean equals(final java.lang.Object obj) {
\r
115 if (super.equals(obj) == false)
\r
118 if (obj instanceof Seg) {
\r
120 Seg temp = (Seg) obj;
\r
123 if (this._start != temp._start)
\r
125 if (this._has_start != temp._has_start)
\r
127 if (this._end != temp._end)
\r
129 if (this._has_end != temp._has_end)
\r
131 if (this._inclusive != temp._inclusive)
\r
133 if (this._has_inclusive != temp._has_inclusive)
\r
141 * Returns the value of field 'end'.
\r
143 * @return the value of field 'End'.
\r
145 public int getEnd() {
\r
150 * Returns the value of field 'inclusive'. The field 'inclusive' has the
\r
151 * following description: when false, a consecutive range like 'start=1,
\r
152 * end=2' means the region lying after position 1 and before position 2
\r
155 * @return the value of field 'Inclusive'.
\r
157 public boolean getInclusive() {
\r
158 return this._inclusive;
\r
162 * Returns the value of field 'start'.
\r
164 * @return the value of field 'Start'.
\r
166 public int getStart() {
\r
167 return this._start;
\r
173 * @return true if at least one End has been added
\r
175 public boolean hasEnd() {
\r
176 return this._has_end;
\r
180 * Method hasInclusive.
\r
182 * @return true if at least one Inclusive has been added
\r
184 public boolean hasInclusive() {
\r
185 return this._has_inclusive;
\r
191 * @return true if at least one Start has been added
\r
193 public boolean hasStart() {
\r
194 return this._has_start;
\r
198 * Overrides the java.lang.Object.hashCode method.
\r
200 * The following steps came from <b>Effective Java Programming Language
\r
201 * Guide</b> by Joshua Bloch, Chapter 3
\r
203 * @return a hash code value for the object.
\r
205 public int hashCode() {
\r
206 int result = super.hashCode();
\r
209 result = 37 * result + _start;
\r
210 result = 37 * result + _end;
\r
211 result = 37 * result + (_inclusive ? 0 : 1);
\r
217 * Returns the value of field 'inclusive'. The field 'inclusive' has the
\r
218 * following description: when false, a consecutive range like 'start=1,
\r
219 * end=2' means the region lying after position 1 and before position 2
\r
222 * @return the value of field 'Inclusive'.
\r
224 public boolean isInclusive() {
\r
225 return this._inclusive;
\r
231 * @return true if this object is valid according to the schema
\r
233 public boolean isValid() {
\r
236 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
246 * @throws org.exolab.castor.xml.MarshalException
\r
247 * if object is null or if any SAXException is thrown during
\r
249 * @throws org.exolab.castor.xml.ValidationException
\r
250 * if this object is an invalid instance according to the schema
\r
252 public void marshal(final java.io.Writer out)
\r
253 throws org.exolab.castor.xml.MarshalException,
\r
254 org.exolab.castor.xml.ValidationException {
\r
255 Marshaller.marshal(this, out);
\r
262 * @throws java.io.IOException
\r
263 * if an IOException occurs during marshaling
\r
264 * @throws org.exolab.castor.xml.ValidationException
\r
265 * if this object is an invalid instance according to the schema
\r
266 * @throws org.exolab.castor.xml.MarshalException
\r
267 * if object is null or if any SAXException is thrown during
\r
270 public void marshal(final org.xml.sax.ContentHandler handler)
\r
271 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
272 org.exolab.castor.xml.ValidationException {
\r
273 Marshaller.marshal(this, handler);
\r
277 * Sets the value of field 'end'.
\r
280 * the value of field 'end'.
\r
282 public void setEnd(final int end) {
\r
284 this._has_end = true;
\r
288 * Sets the value of field 'inclusive'. The field 'inclusive' has the
\r
289 * following description: when false, a consecutive range like 'start=1,
\r
290 * end=2' means the region lying after position 1 and before position 2
\r
294 * the value of field 'inclusive'.
\r
296 public void setInclusive(final boolean inclusive) {
\r
297 this._inclusive = inclusive;
\r
298 this._has_inclusive = true;
\r
302 * Sets the value of field 'start'.
\r
305 * the value of field 'start'.
\r
307 public void setStart(final int start) {
\r
308 this._start = start;
\r
309 this._has_start = true;
\r
313 * Method unmarshal.
\r
316 * @throws org.exolab.castor.xml.MarshalException
\r
317 * if object is null or if any SAXException is thrown during
\r
319 * @throws org.exolab.castor.xml.ValidationException
\r
320 * if this object is an invalid instance according to the schema
\r
321 * @return the unmarshaled uk.ac.vamsas.objects.core.Seg
\r
323 public static uk.ac.vamsas.objects.core.Seg unmarshal(
\r
324 final java.io.Reader reader)
\r
325 throws org.exolab.castor.xml.MarshalException,
\r
326 org.exolab.castor.xml.ValidationException {
\r
327 return (uk.ac.vamsas.objects.core.Seg) Unmarshaller.unmarshal(
\r
328 uk.ac.vamsas.objects.core.Seg.class, reader);
\r
334 * @throws org.exolab.castor.xml.ValidationException
\r
335 * if this object is an invalid instance according to the schema
\r
337 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
338 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
339 validator.validate(this);
\r