applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / core / Common.java
1 /*\r
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
5  * \r
6  * Earlier versions have also been incorporated into Jalview version 2.4 \r
7  * since 2008, and TOPALi version 2 since 2007.\r
8  * \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
13  *  \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
18  * \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
21  */\r
22 package uk.ac.vamsas.objects.core;\r
23 \r
24 //---------------------------------/\r
25 //- Imported classes and packages -/\r
26 //---------------------------------/\r
27 \r
28 import org.exolab.castor.xml.Marshaller;\r
29 import org.exolab.castor.xml.Unmarshaller;\r
30 \r
31 /**\r
32  * Class Common.\r
33  * \r
34  * @version $Revision$ $Date$\r
35  */\r
36 public class Common extends uk.ac.vamsas.objects.core.AppData implements\r
37     java.io.Serializable {\r
38 \r
39   // ----------------/\r
40   // - Constructors -/\r
41   // ----------------/\r
42 \r
43   public Common() {\r
44     super();\r
45   }\r
46 \r
47   // -----------/\r
48   // - Methods -/\r
49   // -----------/\r
50 \r
51   /**\r
52    * Overrides the java.lang.Object.equals method.\r
53    * \r
54    * @param obj\r
55    * @return true if the objects are equal.\r
56    */\r
57   public boolean equals(final java.lang.Object obj) {\r
58     if (this == obj)\r
59       return true;\r
60 \r
61     if (super.equals(obj) == false)\r
62       return false;\r
63 \r
64     if (obj instanceof Common) {\r
65 \r
66       return true;\r
67     }\r
68     return false;\r
69   }\r
70 \r
71   /**\r
72    * Overrides the java.lang.Object.hashCode method.\r
73    * <p>\r
74    * The following steps came from <b>Effective Java Programming Language\r
75    * Guide</b> by Joshua Bloch, Chapter 3\r
76    * \r
77    * @return a hash code value for the object.\r
78    */\r
79   public int hashCode() {\r
80     int result = super.hashCode();\r
81 \r
82     long tmp;\r
83 \r
84     return result;\r
85   }\r
86 \r
87   /**\r
88    * Method isValid.\r
89    * \r
90    * @return true if this object is valid according to the schema\r
91    */\r
92   public boolean isValid() {\r
93     try {\r
94       validate();\r
95     } catch (org.exolab.castor.xml.ValidationException vex) {\r
96       return false;\r
97     }\r
98     return true;\r
99   }\r
100 \r
101   /**\r
102    * \r
103    * \r
104    * @param out\r
105    * @throws org.exolab.castor.xml.MarshalException\r
106    *           if object is null or if any SAXException is thrown during\r
107    *           marshaling\r
108    * @throws org.exolab.castor.xml.ValidationException\r
109    *           if this object is an invalid instance according to the schema\r
110    */\r
111   public void marshal(final java.io.Writer out)\r
112       throws org.exolab.castor.xml.MarshalException,\r
113       org.exolab.castor.xml.ValidationException {\r
114     Marshaller.marshal(this, out);\r
115   }\r
116 \r
117   /**\r
118    * \r
119    * \r
120    * @param handler\r
121    * @throws java.io.IOException\r
122    *           if an IOException occurs during marshaling\r
123    * @throws org.exolab.castor.xml.ValidationException\r
124    *           if this object is an invalid instance according to the schema\r
125    * @throws org.exolab.castor.xml.MarshalException\r
126    *           if object is null or if any SAXException is thrown during\r
127    *           marshaling\r
128    */\r
129   public void marshal(final org.xml.sax.ContentHandler handler)\r
130       throws java.io.IOException, org.exolab.castor.xml.MarshalException,\r
131       org.exolab.castor.xml.ValidationException {\r
132     Marshaller.marshal(this, handler);\r
133   }\r
134 \r
135   /**\r
136    * Method unmarshal.\r
137    * \r
138    * @param reader\r
139    * @throws org.exolab.castor.xml.MarshalException\r
140    *           if object is null or if any SAXException is thrown during\r
141    *           marshaling\r
142    * @throws org.exolab.castor.xml.ValidationException\r
143    *           if this object is an invalid instance according to the schema\r
144    * @return the unmarshaled uk.ac.vamsas.objects.core.AppData\r
145    */\r
146   public static uk.ac.vamsas.objects.core.AppData unmarshal(\r
147       final java.io.Reader reader)\r
148       throws org.exolab.castor.xml.MarshalException,\r
149       org.exolab.castor.xml.ValidationException {\r
150     return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(\r
151         uk.ac.vamsas.objects.core.Common.class, reader);\r
152   }\r
153 \r
154   /**\r
155    * \r
156    * \r
157    * @throws org.exolab.castor.xml.ValidationException\r
158    *           if this object is an invalid instance according to the schema\r
159    */\r
160   public void validate() throws org.exolab.castor.xml.ValidationException {\r
161     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
162     validator.validate(this);\r
163   }\r
164 \r
165 }\r