2 * This file is part of the Vamsas Client version 0.1.
\r
3 * Copyright 2009 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 * Discrete symbol - possibly graphically represented
\r
35 * @version $Revision$ $Date$
\r
37 public class Glyph extends uk.ac.vamsas.client.Vobject implements
\r
38 java.io.Serializable {
\r
40 // --------------------------/
\r
41 // - Class/Member Variables -/
\r
42 // --------------------------/
\r
45 * internal content storage
\r
47 private java.lang.String _content = "";
\r
50 * specifies the symbol dictionary for this glyph - eg utf8 (the default),
\r
51 * aasecstr_3 or kd_hydrophobicity - the content is not validated so
\r
52 * applications must ensure they gracefully deal with invalid entries here
\r
54 private java.lang.String _dict = "utf8";
\r
56 // ----------------/
\r
57 // - Constructors -/
\r
58 // ----------------/
\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 Glyph) {
\r
85 Glyph temp = (Glyph) obj;
\r
88 if (this._content != null) {
\r
89 if (temp._content == null)
\r
91 if (this._content != temp._content) {
\r
92 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content);
\r
93 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content);
\r
94 if (thcycle != tmcycle) {
\r
96 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
100 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
106 if (!this._content.equals(temp._content)) {
\r
107 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
108 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
111 org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
\r
112 org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
\r
115 } else if (temp._content != null)
\r
117 if (this._dict != null) {
\r
118 if (temp._dict == null)
\r
120 if (this._dict != temp._dict) {
\r
121 thcycle = org.castor.util.CycleBreaker.startingToCycle(this._dict);
\r
122 tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._dict);
\r
123 if (thcycle != tmcycle) {
\r
125 org.castor.util.CycleBreaker.releaseCycleHandle(this._dict);
\r
129 org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict);
\r
135 if (!this._dict.equals(temp._dict)) {
\r
136 org.castor.util.CycleBreaker.releaseCycleHandle(this._dict);
\r
137 org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict);
\r
140 org.castor.util.CycleBreaker.releaseCycleHandle(this._dict);
\r
141 org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict);
\r
144 } else if (temp._dict != null)
\r
152 * Returns the value of field 'content'. The field 'content' has the following
\r
153 * description: internal content storage
\r
155 * @return the value of field 'Content'.
\r
157 public java.lang.String getContent() {
\r
158 return this._content;
\r
162 * Returns the value of field 'dict'. The field 'dict' has the following
\r
163 * description: specifies the symbol dictionary for this glyph - eg utf8 (the
\r
164 * default), aasecstr_3 or kd_hydrophobicity - the content is not validated so
\r
165 * applications must ensure they gracefully deal with invalid entries here
\r
167 * @return the value of field 'Dict'.
\r
169 public java.lang.String getDict() {
\r
174 * Overrides the java.lang.Object.hashCode method.
\r
176 * The following steps came from <b>Effective Java Programming Language
\r
177 * Guide</b> by Joshua Bloch, Chapter 3
\r
179 * @return a hash code value for the object.
\r
181 public int hashCode() {
\r
182 int result = super.hashCode();
\r
185 if (_content != null
\r
186 && !org.castor.util.CycleBreaker.startingToCycle(_content)) {
\r
187 result = 37 * result + _content.hashCode();
\r
188 org.castor.util.CycleBreaker.releaseCycleHandle(_content);
\r
190 if (_dict != null && !org.castor.util.CycleBreaker.startingToCycle(_dict)) {
\r
191 result = 37 * result + _dict.hashCode();
\r
192 org.castor.util.CycleBreaker.releaseCycleHandle(_dict);
\r
201 * @return true if this object is valid according to the schema
\r
203 public boolean isValid() {
\r
206 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
216 * @throws org.exolab.castor.xml.MarshalException
\r
217 * if object is null or if any SAXException is thrown during
\r
219 * @throws org.exolab.castor.xml.ValidationException
\r
220 * if this object is an invalid instance according to the schema
\r
222 public void marshal(final java.io.Writer out)
\r
223 throws org.exolab.castor.xml.MarshalException,
\r
224 org.exolab.castor.xml.ValidationException {
\r
225 Marshaller.marshal(this, out);
\r
232 * @throws java.io.IOException
\r
233 * if an IOException occurs during marshaling
\r
234 * @throws org.exolab.castor.xml.ValidationException
\r
235 * if this object is an invalid instance according to the schema
\r
236 * @throws org.exolab.castor.xml.MarshalException
\r
237 * if object is null or if any SAXException is thrown during
\r
240 public void marshal(final org.xml.sax.ContentHandler handler)
\r
241 throws java.io.IOException, org.exolab.castor.xml.MarshalException,
\r
242 org.exolab.castor.xml.ValidationException {
\r
243 Marshaller.marshal(this, handler);
\r
247 * Sets the value of field 'content'. The field 'content' has the following
\r
248 * description: internal content storage
\r
251 * the value of field 'content'.
\r
253 public void setContent(final java.lang.String content) {
\r
254 this._content = content;
\r
258 * Sets the value of field 'dict'. The field 'dict' has the following
\r
259 * description: specifies the symbol dictionary for this glyph - eg utf8 (the
\r
260 * default), aasecstr_3 or kd_hydrophobicity - the content is not validated so
\r
261 * applications must ensure they gracefully deal with invalid entries here
\r
264 * the value of field 'dict'.
\r
266 public void setDict(final java.lang.String dict) {
\r
271 * Method unmarshal.
\r
274 * @throws org.exolab.castor.xml.MarshalException
\r
275 * if object is null or if any SAXException is thrown during
\r
277 * @throws org.exolab.castor.xml.ValidationException
\r
278 * if this object is an invalid instance according to the schema
\r
279 * @return the unmarshaled uk.ac.vamsas.objects.core.Glyph
\r
281 public static uk.ac.vamsas.objects.core.Glyph unmarshal(
\r
282 final java.io.Reader reader)
\r
283 throws org.exolab.castor.xml.MarshalException,
\r
284 org.exolab.castor.xml.ValidationException {
\r
285 return (uk.ac.vamsas.objects.core.Glyph) Unmarshaller.unmarshal(
\r
286 uk.ac.vamsas.objects.core.Glyph.class, reader);
\r
292 * @throws org.exolab.castor.xml.ValidationException
\r
293 * if this object is an invalid instance according to the schema
\r
295 public void validate() throws org.exolab.castor.xml.ValidationException {
\r
296 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
297 validator.validate(this);
\r