2 * This file is part of the Vamsas Client version 0.2.
\r
3 * Copyright 2010 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 * Ordered set of optionally named float values for the whole annotation
\r
34 * @version $Revision$ $Date$
\r
36 public class Score extends uk.ac.vamsas.client.Vobject implements
\r
37 java.io.Serializable {
\r
39 // --------------------------/
\r
40 // - Class/Member Variables -/
\r
41 // --------------------------/
\r
44 * internal content storage
\r
46 private float _content;
\r
49 * keeps track of state for field: _content
\r
51 private boolean _has_content;
\r
56 private java.lang.String _name = "score";
\r
58 // ----------------/
\r
59 // - Constructors -/
\r
60 // ----------------/
\r
73 public void deleteContent() {
\r
74 this._has_content = false;
\r
78 * Overrides the java.lang.Object.equals method.
\r
81 * @return true if the objects are equal.
\r
83 public boolean equals(final java.lang.Object obj) {
\r
87 if (super.equals(obj) == false)
\r
90 if (obj instanceof Score) {
\r
92 Score temp = (Score) obj;
\r
95 if (this._content != temp._content)
\r
97 if (this._has_content != temp._has_content)
\r
99 if (this._name != null) {
\r
100 if (temp._name == null)
\r
102 if (this._name != temp._name) {
\r
103 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._name);
\r
104 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._name);
\r
105 if (thcycle != tmcycle) {
\r
107 org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
\r
111 org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
\r
117 if (!this._name.equals(temp._name)) {
\r
118 org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
\r
119 org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
\r
122 org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
\r
123 org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
\r
126 } else if (temp._name != null)
\r
134 * Returns the value of field 'content'. The field 'content' has the following
\r
135 * description: internal content storage
\r
137 * @return the value of field 'Content'.
\r
139 public float getContent() {
\r
140 return this._content;
\r
144 * Returns the value of field 'name'.
\r
146 * @return the value of field 'Name'.
\r
148 public java.lang.String getName() {
\r
153 * Method hasContent.
\r
155 * @return true if at least one Content has been added
\r
157 public boolean hasContent() {
\r
158 return this._has_content;
\r
162 * Overrides the java.lang.Object.hashCode method.
\r
164 * The following steps came from <b>Effective Java Programming Language
\r
165 * Guide</b> by Joshua Bloch, Chapter 3
\r
167 * @return a hash code value for the object.
\r
169 public int hashCode() {
\r
170 int result = super.hashCode();
\r
173 result = 37 * result + java.lang.Float.floatToIntBits(_content);
\r
174 if (_name != null && !org.castor.util.CycleBreaker.startingToCycle(_name)) {
\r
175 result = 37 * result + _name.hashCode();
\r
176 org.castor.util.CycleBreaker.releaseCycleHandle(_name);
\r
185 * @return true if this object is valid according to the schema
\r
187 public boolean isValid() {
\r
190 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
200 * @throws org.exolab.castor.xml.MarshalException
\r
201 * if object is null or if any SAXException is thrown during
\r
203 * @throws org.exolab.castor.xml.ValidationException
\r
204 * if this object is an invalid instance according to the schema
\r
206 public void marshal(final java.io.Writer out)
\r
207 throws org.exolab.castor.xml.MarshalException,
\r
208 org.exolab.castor.xml.ValidationException {
\r
209 Marshaller.marshal(this, out);
\r
216 * @throws java.io.IOException
\r
217 * if an IOException occurs during marshaling
\r
218 * @throws org.exolab.castor.xml.ValidationException
\r
219 * if this object is an invalid instance according to the schema
\r
220 * @throws org.exolab.castor.xml.MarshalException
\r
221 * if object is null or if any SAXException is thrown during
\r
224 public void marshal(final org.xml.sax.ContentHandler handler)
\r
225 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
226 org.exolab.castor.xml.ValidationException {
\r
227 Marshaller.marshal(this, handler);
\r
231 * Sets the value of field 'content'. The field 'content' has the following
\r
232 * description: internal content storage
\r
235 * the value of field 'content'.
\r
237 public void setContent(final float content) {
\r
238 this._content = content;
\r
239 this._has_content = true;
\r
243 * Sets the value of field 'name'.
\r
246 * the value of field 'name'.
\r
248 public void setName(final java.lang.String name) {
\r
253 * Method unmarshal.
\r
256 * @throws org.exolab.castor.xml.MarshalException
\r
257 * if object is null or if any SAXException is thrown during
\r
259 * @throws org.exolab.castor.xml.ValidationException
\r
260 * if this object is an invalid instance according to the schema
\r
261 * @return the unmarshaled uk.ac.vamsas.objects.core.Score
\r
263 public static uk.ac.vamsas.objects.core.Score unmarshal(
\r
264 final java.io.Reader reader)
\r
265 throws org.exolab.castor.xml.MarshalException,
\r
266 org.exolab.castor.xml.ValidationException {
\r
267 return (uk.ac.vamsas.objects.core.Score) Unmarshaller.unmarshal(
\r
268 uk.ac.vamsas.objects.core.Score.class, reader);
\r
274 * @throws org.exolab.castor.xml.ValidationException
\r
275 * if this object is an invalid instance according to the schema
\r
277 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
278 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
279 validator.validate(this);
\r