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 Param 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 java.lang.String _content = "";
\r
51 private java.lang.String _name;
\r
54 * The type specifies how the property will be parsed. Empty property strings
\r
55 * are allowed, and can be used to prototype the input to a document. TODO:
\r
56 * specify allowed types
\r
58 private java.lang.String _type;
\r
60 // ----------------/
\r
61 // - Constructors -/
\r
62 // ----------------/
\r
74 * Overrides the java.lang.Object.equals method.
\r
77 * @return true if the objects are equal.
\r
79 public boolean equals(final java.lang.Object obj) {
\r
83 if (super.equals(obj) == false)
\r
86 if (obj instanceof Param) {
\r
88 Param temp = (Param) obj;
\r
91 if (this._content != null) {
\r
92 if (temp._content == null)
\r
94 if (this._content != temp._content) {
\r
95 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content);
\r
96 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content);
\r
97 if (thcycle != tmcycle) {
\r
99 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
103 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
109 if (!this._content.equals(temp._content)) {
\r
110 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
111 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
114 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
115 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
118 } else if (temp._content != null)
\r
120 if (this._name != null) {
\r
121 if (temp._name == null)
\r
123 if (this._name != temp._name) {
\r
124 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._name);
\r
125 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._name);
\r
126 if (thcycle != tmcycle) {
\r
128 org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
\r
132 org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
\r
138 if (!this._name.equals(temp._name)) {
\r
139 org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
\r
140 org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
\r
143 org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
\r
144 org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
\r
147 } else if (temp._name != null)
\r
149 if (this._type != null) {
\r
150 if (temp._type == null)
\r
152 if (this._type != temp._type) {
\r
153 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._type);
\r
154 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._type);
\r
155 if (thcycle != tmcycle) {
\r
157 org.castor.util.CycleBreaker.releaseCycleHandle(this._type);
\r
161 org.castor.util.CycleBreaker.releaseCycleHandle(temp._type);
\r
167 if (!this._type.equals(temp._type)) {
\r
168 org.castor.util.CycleBreaker.releaseCycleHandle(this._type);
\r
169 org.castor.util.CycleBreaker.releaseCycleHandle(temp._type);
\r
172 org.castor.util.CycleBreaker.releaseCycleHandle(this._type);
\r
173 org.castor.util.CycleBreaker.releaseCycleHandle(temp._type);
\r
176 } else if (temp._type != null)
\r
184 * Returns the value of field 'content'. The field 'content' has the following
\r
185 * description: internal content storage
\r
187 * @return the value of field 'Content'.
\r
189 public java.lang.String getContent() {
\r
190 return this._content;
\r
194 * Returns the value of field 'name'.
\r
196 * @return the value of field 'Name'.
\r
198 public java.lang.String getName() {
\r
203 * Returns the value of field 'type'. The field 'type' has the following
\r
204 * description: The type specifies how the property will be parsed. Empty
\r
205 * property strings are allowed, and can be used to prototype the input to a
\r
206 * document. TODO: specify allowed types
\r
208 * @return the value of field 'Type'.
\r
210 public java.lang.String getType() {
\r
215 * Overrides the java.lang.Object.hashCode method.
\r
217 * The following steps came from <b>Effective Java Programming Language
\r
218 * Guide</b> by Joshua Bloch, Chapter 3
\r
220 * @return a hash code value for the object.
\r
222 public int hashCode() {
\r
223 int result = super.hashCode();
\r
226 if (_content != null
\r
227 && !org.castor.util.CycleBreaker.startingToCycle(_content)) {
\r
228 result = 37 * result + _content.hashCode();
\r
229 org.castor.util.CycleBreaker.releaseCycleHandle(_content);
\r
231 if (_name != null && !org.castor.util.CycleBreaker.startingToCycle(_name)) {
\r
232 result = 37 * result + _name.hashCode();
\r
233 org.castor.util.CycleBreaker.releaseCycleHandle(_name);
\r
235 if (_type != null && !org.castor.util.CycleBreaker.startingToCycle(_type)) {
\r
236 result = 37 * result + _type.hashCode();
\r
237 org.castor.util.CycleBreaker.releaseCycleHandle(_type);
\r
246 * @return true if this object is valid according to the schema
\r
248 public boolean isValid() {
\r
251 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
261 * @throws org.exolab.castor.xml.MarshalException
\r
262 * if object is null or if any SAXException is thrown during
\r
264 * @throws org.exolab.castor.xml.ValidationException
\r
265 * if this object is an invalid instance according to the schema
\r
267 public void marshal(final java.io.Writer out)
\r
268 throws org.exolab.castor.xml.MarshalException,
\r
269 org.exolab.castor.xml.ValidationException {
\r
270 Marshaller.marshal(this, out);
\r
277 * @throws java.io.IOException
\r
278 * if an IOException occurs during marshaling
\r
279 * @throws org.exolab.castor.xml.ValidationException
\r
280 * if this object is an invalid instance according to the schema
\r
281 * @throws org.exolab.castor.xml.MarshalException
\r
282 * if object is null or if any SAXException is thrown during
\r
285 public void marshal(final org.xml.sax.ContentHandler handler)
\r
286 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
287 org.exolab.castor.xml.ValidationException {
\r
288 Marshaller.marshal(this, handler);
\r
292 * Sets the value of field 'content'. The field 'content' has the following
\r
293 * description: internal content storage
\r
296 * the value of field 'content'.
\r
298 public void setContent(final java.lang.String content) {
\r
299 this._content = content;
\r
303 * Sets the value of field 'name'.
\r
306 * the value of field 'name'.
\r
308 public void setName(final java.lang.String name) {
\r
313 * Sets the value of field 'type'. The field 'type' has the following
\r
314 * description: The type specifies how the property will be parsed. Empty
\r
315 * property strings are allowed, and can be used to prototype the input to a
\r
316 * document. TODO: specify allowed types
\r
319 * the value of field 'type'.
\r
321 public void setType(final java.lang.String type) {
\r
326 * Method unmarshal.
\r
329 * @throws org.exolab.castor.xml.MarshalException
\r
330 * if object is null or if any SAXException is thrown during
\r
332 * @throws org.exolab.castor.xml.ValidationException
\r
333 * if this object is an invalid instance according to the schema
\r
334 * @return the unmarshaled uk.ac.vamsas.objects.core.Param
\r
336 public static uk.ac.vamsas.objects.core.Param unmarshal(
\r
337 final java.io.Reader reader)
\r
338 throws org.exolab.castor.xml.MarshalException,
\r
339 org.exolab.castor.xml.ValidationException {
\r
340 return (uk.ac.vamsas.objects.core.Param) Unmarshaller.unmarshal(
\r
341 uk.ac.vamsas.objects.core.Param.class, reader);
\r
347 * @throws org.exolab.castor.xml.ValidationException
\r
348 * if this object is an invalid instance according to the schema
\r
350 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
351 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
352 validator.validate(this);
\r