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 AlignmentSequenceAnnotation.
\r
34 * @version $Revision$ $Date$
\r
36 public class AlignmentSequenceAnnotation extends
\r
37 uk.ac.vamsas.objects.core.RangeAnnotation implements java.io.Serializable {
\r
39 // --------------------------/
\r
40 // - Class/Member Variables -/
\r
41 // --------------------------/
\r
44 * TODO: decide if this flag is redundant - when true it would suggest that
\r
45 * the annotationElement values together form a graph
\r
48 private boolean _graph;
\r
51 * keeps track of state for field: _graph
\r
53 private boolean _has_graph;
\r
56 * Field _provenance.
\r
58 private uk.ac.vamsas.objects.core.Provenance _provenance;
\r
60 // ----------------/
\r
61 // - Constructors -/
\r
62 // ----------------/
\r
64 public AlignmentSequenceAnnotation() {
\r
74 public void deleteGraph() {
\r
75 this._has_graph = false;
\r
79 * Overrides the java.lang.Object.equals method.
\r
82 * @return true if the objects are equal.
\r
84 public boolean equals(final java.lang.Object obj) {
\r
88 if (super.equals(obj) == false)
\r
91 if (obj instanceof AlignmentSequenceAnnotation) {
\r
93 AlignmentSequenceAnnotation temp = (AlignmentSequenceAnnotation) obj;
\r
96 if (this._graph != temp._graph)
\r
98 if (this._has_graph != temp._has_graph)
\r
100 if (this._provenance != null) {
\r
101 if (temp._provenance == null)
\r
103 if (this._provenance != temp._provenance) {
\r
104 thcycle = org.castor.util.CycleBreaker
\r
105 .startingToCycle(this._provenance);
\r
106 tmcycle = org.castor.util.CycleBreaker
\r
107 .startingToCycle(temp._provenance);
\r
108 if (thcycle != tmcycle) {
\r
110 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
\r
114 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
\r
120 if (!this._provenance.equals(temp._provenance)) {
\r
121 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
\r
122 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
\r
125 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
\r
126 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
\r
129 } else if (temp._provenance != null)
\r
137 * Returns the value of field 'graph'. The field 'graph' has the following
\r
138 * description: TODO: decide if this flag is redundant - when true it would
\r
139 * suggest that the annotationElement values together form a graph
\r
142 * @return the value of field 'Graph'.
\r
144 public boolean getGraph() {
\r
145 return this._graph;
\r
149 * Returns the value of field 'provenance'.
\r
151 * @return the value of field 'Provenance'.
\r
153 public uk.ac.vamsas.objects.core.Provenance getProvenance() {
\r
154 return this._provenance;
\r
160 * @return true if at least one Graph has been added
\r
162 public boolean hasGraph() {
\r
163 return this._has_graph;
\r
167 * Overrides the java.lang.Object.hashCode method.
\r
169 * The following steps came from <b>Effective Java Programming Language
\r
170 * Guide</b> by Joshua Bloch, Chapter 3
\r
172 * @return a hash code value for the object.
\r
174 public int hashCode() {
\r
175 int result = super.hashCode();
\r
178 result = 37 * result + (_graph ? 0 : 1);
\r
179 if (_provenance != null
\r
180 && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {
\r
181 result = 37 * result + _provenance.hashCode();
\r
182 org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);
\r
189 * Returns the value of field 'graph'. The field 'graph' has the following
\r
190 * description: TODO: decide if this flag is redundant - when true it would
\r
191 * suggest that the annotationElement values together form a graph
\r
194 * @return the value of field 'Graph'.
\r
196 public boolean isGraph() {
\r
197 return this._graph;
\r
203 * @return true if this object is valid according to the schema
\r
205 public boolean isValid() {
\r
208 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
218 * @throws org.exolab.castor.xml.MarshalException
\r
219 * if object is null or if any SAXException is thrown during
\r
221 * @throws org.exolab.castor.xml.ValidationException
\r
222 * if this object is an invalid instance according to the schema
\r
224 public void marshal(final java.io.Writer out)
\r
225 throws org.exolab.castor.xml.MarshalException,
\r
226 org.exolab.castor.xml.ValidationException {
\r
227 Marshaller.marshal(this, out);
\r
234 * @throws java.io.IOException
\r
235 * if an IOException occurs during marshaling
\r
236 * @throws org.exolab.castor.xml.ValidationException
\r
237 * if this object is an invalid instance according to the schema
\r
238 * @throws org.exolab.castor.xml.MarshalException
\r
239 * if object is null or if any SAXException is thrown during
\r
242 public void marshal(final org.xml.sax.ContentHandler handler)
\r
243 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
244 org.exolab.castor.xml.ValidationException {
\r
245 Marshaller.marshal(this, handler);
\r
249 * Sets the value of field 'graph'. The field 'graph' has the following
\r
250 * description: TODO: decide if this flag is redundant - when true it would
\r
251 * suggest that the annotationElement values together form a graph
\r
255 * the value of field 'graph'.
\r
257 public void setGraph(final boolean graph) {
\r
258 this._graph = graph;
\r
259 this._has_graph = true;
\r
263 * Sets the value of field 'provenance'.
\r
265 * @param provenance
\r
266 * the value of field 'provenance'.
\r
268 public void setProvenance(
\r
269 final uk.ac.vamsas.objects.core.Provenance provenance) {
\r
270 this._provenance = provenance;
\r
274 * Method unmarshal.
\r
277 * @throws org.exolab.castor.xml.MarshalException
\r
278 * if object is null or if any SAXException is thrown during
\r
280 * @throws org.exolab.castor.xml.ValidationException
\r
281 * if this object is an invalid instance according to the schema
\r
282 * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType
\r
284 public static uk.ac.vamsas.objects.core.RangeType unmarshal(
\r
285 final java.io.Reader reader)
\r
286 throws org.exolab.castor.xml.MarshalException,
\r
287 org.exolab.castor.xml.ValidationException {
\r
288 return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(
\r
289 uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class, reader);
\r
295 * @throws org.exolab.castor.xml.ValidationException
\r
296 * if this object is an invalid instance according to the schema
\r
298 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
299 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
300 validator.validate(this);
\r