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
34 * @version $Revision$ $Date$
\r
36 public class AppData extends uk.ac.vamsas.client.Vobject implements
\r
37 java.io.Serializable {
\r
39 // --------------------------/
\r
40 // - Class/Member Variables -/
\r
41 // --------------------------/
\r
44 * Internal choice value storage
\r
46 private java.lang.Object _choiceValue;
\r
51 private byte[] _data;
\r
54 * Field _dataReference.
\r
56 private java.lang.String _dataReference;
\r
58 // ----------------/
\r
59 // - Constructors -/
\r
60 // ----------------/
\r
71 * Overrides the java.lang.Object.equals method.
\r
74 * @return true if the objects are equal.
\r
76 public boolean equals(final java.lang.Object obj) {
\r
80 if (super.equals(obj) == false)
\r
83 if (obj instanceof AppData) {
\r
85 AppData temp = (AppData) obj;
\r
88 if (this._choiceValue != null) {
\r
89 if (temp._choiceValue == null)
\r
91 if (this._choiceValue != temp._choiceValue) {
\r
92 thcycle = org.castor.util.CycleBreaker
\r
93 .startingToCycle(this._choiceValue);
\r
94 tmcycle = org.castor.util.CycleBreaker
\r
95 .startingToCycle(temp._choiceValue);
\r
96 if (thcycle != tmcycle) {
\r
98 org.castor.util.CycleBreaker
\r
99 .releaseCycleHandle(this._choiceValue);
\r
103 org.castor.util.CycleBreaker
\r
104 .releaseCycleHandle(temp._choiceValue);
\r
110 if (!this._choiceValue.equals(temp._choiceValue)) {
\r
111 org.castor.util.CycleBreaker
\r
112 .releaseCycleHandle(this._choiceValue);
\r
113 org.castor.util.CycleBreaker
\r
114 .releaseCycleHandle(temp._choiceValue);
\r
117 org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue);
\r
118 org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue);
\r
121 } else if (temp._choiceValue != null)
\r
123 if (this._data != null) {
\r
124 if (temp._data == null)
\r
126 if (this._data != temp._data) {
\r
127 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._data);
\r
128 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._data);
\r
129 if (thcycle != tmcycle) {
\r
131 org.castor.util.CycleBreaker.releaseCycleHandle(this._data);
\r
135 org.castor.util.CycleBreaker.releaseCycleHandle(temp._data);
\r
141 if (!java.util.Arrays.equals(this._data, temp._data)) {
\r
142 org.castor.util.CycleBreaker.releaseCycleHandle(this._data);
\r
143 org.castor.util.CycleBreaker.releaseCycleHandle(temp._data);
\r
146 org.castor.util.CycleBreaker.releaseCycleHandle(this._data);
\r
147 org.castor.util.CycleBreaker.releaseCycleHandle(temp._data);
\r
150 } else if (temp._data != null)
\r
152 if (this._dataReference != null) {
\r
153 if (temp._dataReference == null)
\r
155 if (this._dataReference != temp._dataReference) {
\r
156 thcycle = org.castor.util.CycleBreaker
\r
157 .startingToCycle(this._dataReference);
\r
158 tmcycle = org.castor.util.CycleBreaker
\r
159 .startingToCycle(temp._dataReference);
\r
160 if (thcycle != tmcycle) {
\r
162 org.castor.util.CycleBreaker
\r
163 .releaseCycleHandle(this._dataReference);
\r
167 org.castor.util.CycleBreaker
\r
168 .releaseCycleHandle(temp._dataReference);
\r
174 if (!this._dataReference.equals(temp._dataReference)) {
\r
175 org.castor.util.CycleBreaker
\r
176 .releaseCycleHandle(this._dataReference);
\r
177 org.castor.util.CycleBreaker
\r
178 .releaseCycleHandle(temp._dataReference);
\r
181 org.castor.util.CycleBreaker
\r
182 .releaseCycleHandle(this._dataReference);
\r
183 org.castor.util.CycleBreaker
\r
184 .releaseCycleHandle(temp._dataReference);
\r
187 } else if (temp._dataReference != null)
\r
195 * Returns the value of field 'choiceValue'. The field 'choiceValue' has the
\r
196 * following description: Internal choice value storage
\r
198 * @return the value of field 'ChoiceValue'.
\r
200 public java.lang.Object getChoiceValue() {
\r
201 return this._choiceValue;
\r
205 * Returns the value of field 'data'.
\r
207 * @return the value of field 'Data'.
\r
209 public byte[] getData() {
\r
214 * Returns the value of field 'dataReference'.
\r
216 * @return the value of field 'DataReference'.
\r
218 public java.lang.String getDataReference() {
\r
219 return this._dataReference;
\r
223 * Overrides the java.lang.Object.hashCode method.
\r
225 * The following steps came from <b>Effective Java Programming Language
\r
226 * Guide</b> by Joshua Bloch, Chapter 3
\r
228 * @return a hash code value for the object.
\r
230 public int hashCode() {
\r
231 int result = super.hashCode();
\r
234 if (_choiceValue != null
\r
235 && !org.castor.util.CycleBreaker.startingToCycle(_choiceValue)) {
\r
236 result = 37 * result + _choiceValue.hashCode();
\r
237 org.castor.util.CycleBreaker.releaseCycleHandle(_choiceValue);
\r
239 if (_data != null && !org.castor.util.CycleBreaker.startingToCycle(_data)) {
\r
240 result = 37 * result + _data.hashCode();
\r
241 org.castor.util.CycleBreaker.releaseCycleHandle(_data);
\r
243 if (_dataReference != null
\r
244 && !org.castor.util.CycleBreaker.startingToCycle(_dataReference)) {
\r
245 result = 37 * result + _dataReference.hashCode();
\r
246 org.castor.util.CycleBreaker.releaseCycleHandle(_dataReference);
\r
255 * @return true if this object is valid according to the schema
\r
257 public boolean isValid() {
\r
260 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
270 * @throws org.exolab.castor.xml.MarshalException
\r
271 * if object is null or if any SAXException is thrown during
\r
273 * @throws org.exolab.castor.xml.ValidationException
\r
274 * if this object is an invalid instance according to the schema
\r
276 public void marshal(final java.io.Writer out)
\r
277 throws org.exolab.castor.xml.MarshalException,
\r
278 org.exolab.castor.xml.ValidationException {
\r
279 Marshaller.marshal(this, out);
\r
286 * @throws java.io.IOException
\r
287 * if an IOException occurs during marshaling
\r
288 * @throws org.exolab.castor.xml.ValidationException
\r
289 * if this object is an invalid instance according to the schema
\r
290 * @throws org.exolab.castor.xml.MarshalException
\r
291 * if object is null or if any SAXException is thrown during
\r
294 public void marshal(final org.xml.sax.ContentHandler handler)
\r
295 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
296 org.exolab.castor.xml.ValidationException {
\r
297 Marshaller.marshal(this, handler);
\r
301 * Sets the value of field 'data'.
\r
304 * the value of field 'data'.
\r
306 public void setData(final byte[] data) {
\r
308 this._choiceValue = data;
\r
312 * Sets the value of field 'dataReference'.
\r
314 * @param dataReference
\r
315 * the value of field 'dataReference'.
\r
317 public void setDataReference(final java.lang.String dataReference) {
\r
318 this._dataReference = dataReference;
\r
319 this._choiceValue = dataReference;
\r
323 * Method unmarshal.
\r
326 * @throws org.exolab.castor.xml.MarshalException
\r
327 * if object is null or if any SAXException is thrown during
\r
329 * @throws org.exolab.castor.xml.ValidationException
\r
330 * if this object is an invalid instance according to the schema
\r
331 * @return the unmarshaled uk.ac.vamsas.objects.core.AppData
\r
333 public static uk.ac.vamsas.objects.core.AppData unmarshal(
\r
334 final java.io.Reader reader)
\r
335 throws org.exolab.castor.xml.MarshalException,
\r
336 org.exolab.castor.xml.ValidationException {
\r
337 return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(
\r
338 uk.ac.vamsas.objects.core.AppData.class, reader);
\r
344 * @throws org.exolab.castor.xml.ValidationException
\r
345 * if this object is an invalid instance according to the schema
\r
347 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
348 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
349 validator.validate(this);
\r