2 * This file is part of the Vamsas Client version 0.1.
3 * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite,
4 * Andrew Waterhouse and Dominik Lindner.
6 * Earlier versions have also been incorporated into Jalview version 2.4
7 * since 2008, and TOPALi version 2 since 2007.
9 * The Vamsas Client is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * The Vamsas Client is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.
22 package uk.ac.vamsas.objects.core;
24 //---------------------------------/
25 //- Imported classes and packages -/
26 //---------------------------------/
28 import org.exolab.castor.xml.Marshaller;
29 import org.exolab.castor.xml.Unmarshaller;
34 * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007)
37 public class User extends uk.ac.vamsas.objects.core.AppData implements
38 java.io.Serializable {
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
47 private java.lang.String _fullname;
50 * Field _organization.
52 private java.lang.String _organization;
67 * Overrides the java.lang.Object.equals method.
70 * @return true if the objects are equal.
72 public boolean equals(final java.lang.Object obj) {
76 if (super.equals(obj) == false)
79 if (obj instanceof User) {
81 User temp = (User) obj;
84 if (this._fullname != null) {
85 if (temp._fullname == null)
87 if (this._fullname != temp._fullname) {
88 thcycle = org.castor.util.CycleBreaker
89 .startingToCycle(this._fullname);
90 tmcycle = org.castor.util.CycleBreaker
91 .startingToCycle(temp._fullname);
92 if (thcycle != tmcycle) {
94 org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname);
98 org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname);
104 if (!this._fullname.equals(temp._fullname)) {
105 org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname);
106 org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname);
109 org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname);
110 org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname);
113 } else if (temp._fullname != null)
115 if (this._organization != null) {
116 if (temp._organization == null)
118 if (this._organization != temp._organization) {
119 thcycle = org.castor.util.CycleBreaker
120 .startingToCycle(this._organization);
121 tmcycle = org.castor.util.CycleBreaker
122 .startingToCycle(temp._organization);
123 if (thcycle != tmcycle) {
125 org.castor.util.CycleBreaker
126 .releaseCycleHandle(this._organization);
130 org.castor.util.CycleBreaker
131 .releaseCycleHandle(temp._organization);
137 if (!this._organization.equals(temp._organization)) {
138 org.castor.util.CycleBreaker
139 .releaseCycleHandle(this._organization);
140 org.castor.util.CycleBreaker
141 .releaseCycleHandle(temp._organization);
144 org.castor.util.CycleBreaker.releaseCycleHandle(this._organization);
145 org.castor.util.CycleBreaker.releaseCycleHandle(temp._organization);
148 } else if (temp._organization != null)
156 * Returns the value of field 'fullname'.
158 * @return the value of field 'Fullname'.
160 public java.lang.String getFullname() {
161 return this._fullname;
165 * Returns the value of field 'organization'.
167 * @return the value of field 'Organization'.
169 public java.lang.String getOrganization() {
170 return this._organization;
174 * Overrides the java.lang.Object.hashCode method.
176 * The following steps came from <b>Effective Java Programming Language
177 * Guide</b> by Joshua Bloch, Chapter 3
179 * @return a hash code value for the object.
181 public int hashCode() {
182 int result = super.hashCode();
185 if (_fullname != null
186 && !org.castor.util.CycleBreaker.startingToCycle(_fullname)) {
187 result = 37 * result + _fullname.hashCode();
188 org.castor.util.CycleBreaker.releaseCycleHandle(_fullname);
190 if (_organization != null
191 && !org.castor.util.CycleBreaker.startingToCycle(_organization)) {
192 result = 37 * result + _organization.hashCode();
193 org.castor.util.CycleBreaker.releaseCycleHandle(_organization);
202 * @return true if this object is valid according to the schema
204 public boolean isValid() {
207 } catch (org.exolab.castor.xml.ValidationException vex) {
217 * @throws org.exolab.castor.xml.MarshalException
218 * if object is null or if any SAXException is thrown during
220 * @throws org.exolab.castor.xml.ValidationException
221 * if this object is an invalid instance according to the schema
223 public void marshal(final java.io.Writer out)
224 throws org.exolab.castor.xml.MarshalException,
225 org.exolab.castor.xml.ValidationException {
226 Marshaller.marshal(this, out);
233 * @throws java.io.IOException
234 * if an IOException occurs during marshaling
235 * @throws org.exolab.castor.xml.ValidationException
236 * if this object is an invalid instance according to the schema
237 * @throws org.exolab.castor.xml.MarshalException
238 * if object is null or if any SAXException is thrown during
241 public void marshal(final org.xml.sax.ContentHandler handler)
242 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
243 org.exolab.castor.xml.ValidationException {
244 Marshaller.marshal(this, handler);
248 * Sets the value of field 'fullname'.
251 * the value of field 'fullname'.
253 public void setFullname(final java.lang.String fullname) {
254 this._fullname = fullname;
258 * Sets the value of field 'organization'.
260 * @param organization
261 * the value of field 'organization'.
263 public void setOrganization(final java.lang.String organization) {
264 this._organization = organization;
271 * @throws org.exolab.castor.xml.MarshalException
272 * if object is null or if any SAXException is thrown during
274 * @throws org.exolab.castor.xml.ValidationException
275 * if this object is an invalid instance according to the schema
276 * @return the unmarshaled uk.ac.vamsas.objects.core.AppData
278 public static uk.ac.vamsas.objects.core.AppData unmarshal(
279 final java.io.Reader reader)
280 throws org.exolab.castor.xml.MarshalException,
281 org.exolab.castor.xml.ValidationException {
282 return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(
283 uk.ac.vamsas.objects.core.User.class, reader);
289 * @throws org.exolab.castor.xml.ValidationException
290 * if this object is an invalid instance according to the schema
292 public void validate() throws org.exolab.castor.xml.ValidationException {
293 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
294 validator.validate(this);