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 Link 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 _href;
\r
53 // ----------------/
\r
54 // - Constructors -/
\r
55 // ----------------/
\r
67 * Overrides the java.lang.Object.equals method.
\r
70 * @return true if the objects are equal.
\r
72 public boolean equals(final java.lang.Object obj) {
\r
76 if (super.equals(obj) == false)
\r
79 if (obj instanceof Link) {
\r
81 Link temp = (Link) obj;
\r
84 if (this._content != null) {
\r
85 if (temp._content == null)
\r
87 if (this._content != temp._content) {
\r
88 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content);
\r
89 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content);
\r
90 if (thcycle != tmcycle) {
\r
92 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
96 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
102 if (!this._content.equals(temp._content)) {
\r
103 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
104 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
107 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
108 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
111 } else if (temp._content != null)
\r
113 if (this._href != null) {
\r
114 if (temp._href == null)
\r
116 if (this._href != temp._href) {
\r
117 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._href);
\r
118 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._href);
\r
119 if (thcycle != tmcycle) {
\r
121 org.castor.util.CycleBreaker.releaseCycleHandle(this._href);
\r
125 org.castor.util.CycleBreaker.releaseCycleHandle(temp._href);
\r
131 if (!this._href.equals(temp._href)) {
\r
132 org.castor.util.CycleBreaker.releaseCycleHandle(this._href);
\r
133 org.castor.util.CycleBreaker.releaseCycleHandle(temp._href);
\r
136 org.castor.util.CycleBreaker.releaseCycleHandle(this._href);
\r
137 org.castor.util.CycleBreaker.releaseCycleHandle(temp._href);
\r
140 } else if (temp._href != null)
\r
148 * Returns the value of field 'content'. The field 'content' has the following
\r
149 * description: internal content storage
\r
151 * @return the value of field 'Content'.
\r
153 public java.lang.String getContent() {
\r
154 return this._content;
\r
158 * Returns the value of field 'href'. The field 'href' has the following
\r
159 * description: The URI
\r
161 * @return the value of field 'Href'.
\r
163 public java.lang.String getHref() {
\r
168 * Overrides the java.lang.Object.hashCode method.
\r
170 * The following steps came from <b>Effective Java Programming Language
\r
171 * Guide</b> by Joshua Bloch, Chapter 3
\r
173 * @return a hash code value for the object.
\r
175 public int hashCode() {
\r
176 int result = super.hashCode();
\r
179 if (_content != null
\r
180 && !org.castor.util.CycleBreaker.startingToCycle(_content)) {
\r
181 result = 37 * result + _content.hashCode();
\r
182 org.castor.util.CycleBreaker.releaseCycleHandle(_content);
\r
184 if (_href != null && !org.castor.util.CycleBreaker.startingToCycle(_href)) {
\r
185 result = 37 * result + _href.hashCode();
\r
186 org.castor.util.CycleBreaker.releaseCycleHandle(_href);
\r
195 * @return true if this object is valid according to the schema
\r
197 public boolean isValid() {
\r
200 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
210 * @throws org.exolab.castor.xml.MarshalException
\r
211 * if object is null or if any SAXException is thrown during
\r
213 * @throws org.exolab.castor.xml.ValidationException
\r
214 * if this object is an invalid instance according to the schema
\r
216 public void marshal(final java.io.Writer out)
\r
217 throws org.exolab.castor.xml.MarshalException,
\r
218 org.exolab.castor.xml.ValidationException {
\r
219 Marshaller.marshal(this, out);
\r
226 * @throws java.io.IOException
\r
227 * if an IOException occurs during marshaling
\r
228 * @throws org.exolab.castor.xml.ValidationException
\r
229 * if this object is an invalid instance according to the schema
\r
230 * @throws org.exolab.castor.xml.MarshalException
\r
231 * if object is null or if any SAXException is thrown during
\r
234 public void marshal(final org.xml.sax.ContentHandler handler)
\r
235 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
236 org.exolab.castor.xml.ValidationException {
\r
237 Marshaller.marshal(this, handler);
\r
241 * Sets the value of field 'content'. The field 'content' has the following
\r
242 * description: internal content storage
\r
245 * the value of field 'content'.
\r
247 public void setContent(final java.lang.String content) {
\r
248 this._content = content;
\r
252 * Sets the value of field 'href'. The field 'href' has the following
\r
253 * description: The URI
\r
256 * the value of field 'href'.
\r
258 public void setHref(final java.lang.String href) {
\r
263 * Method unmarshal.
\r
266 * @throws org.exolab.castor.xml.MarshalException
\r
267 * if object is null or if any SAXException is thrown during
\r
269 * @throws org.exolab.castor.xml.ValidationException
\r
270 * if this object is an invalid instance according to the schema
\r
271 * @return the unmarshaled uk.ac.vamsas.objects.core.Link
\r
273 public static uk.ac.vamsas.objects.core.Link unmarshal(
\r
274 final java.io.Reader reader)
\r
275 throws org.exolab.castor.xml.MarshalException,
\r
276 org.exolab.castor.xml.ValidationException {
\r
277 return (uk.ac.vamsas.objects.core.Link) Unmarshaller.unmarshal(
\r
278 uk.ac.vamsas.objects.core.Link.class, reader);
\r
284 * @throws org.exolab.castor.xml.ValidationException
\r
285 * if this object is an invalid instance according to the schema
\r
287 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
288 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
289 validator.validate(this);
\r