6cfeec070d432de314fe636575a1f4425e35cc4c
[vamsas.git] / src / uk / ac / vamsas / objects / core / Instance.java
1 /*\r
2  * This class was automatically generated with \r
3  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML\r
4  * Schema.\r
5  * $Id$\r
6  */\r
7 \r
8 package uk.ac.vamsas.objects.core;\r
9 \r
10   //---------------------------------/\r
11  //- Imported classes and packages -/\r
12 //---------------------------------/\r
13 \r
14 import org.exolab.castor.xml.Marshaller;\r
15 import org.exolab.castor.xml.Unmarshaller;\r
16 \r
17 /**\r
18  * Class Instance.\r
19  * \r
20  * @version $Revision$ $Date$\r
21  */\r
22 public class Instance extends uk.ac.vamsas.objects.core.AppData \r
23 implements java.io.Serializable\r
24 {\r
25 \r
26 \r
27       //--------------------------/\r
28      //- Class/Member Variables -/\r
29     //--------------------------/\r
30 \r
31     /**\r
32      * Field _urn.\r
33      */\r
34     private java.lang.String _urn;\r
35 \r
36 \r
37       //----------------/\r
38      //- Constructors -/\r
39     //----------------/\r
40 \r
41     public Instance() {\r
42         super();\r
43     }\r
44 \r
45 \r
46       //-----------/\r
47      //- Methods -/\r
48     //-----------/\r
49 \r
50     /**\r
51      * Overrides the java.lang.Object.equals method.\r
52      * \r
53      * @param obj\r
54      * @return true if the objects are equal.\r
55      */\r
56     public boolean equals(\r
57             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 Instance) {\r
65         \r
66             Instance temp = (Instance)obj;\r
67             if (this._urn != null) {\r
68                 if (temp._urn == null) return false;\r
69                 else if (!(this._urn.equals(temp._urn))) \r
70                     return false;\r
71             }\r
72             else if (temp._urn != null)\r
73                 return false;\r
74             return true;\r
75         }\r
76         return false;\r
77     }\r
78 \r
79     /**\r
80      * Returns the value of field 'urn'.\r
81      * \r
82      * @return the value of field 'Urn'.\r
83      */\r
84     public java.lang.String getUrn(\r
85     ) {\r
86         return this._urn;\r
87     }\r
88 \r
89     /**\r
90      * Overrides the java.lang.Object.hashCode method.\r
91      * <p>\r
92      * The following steps came from <b>Effective Java Programming\r
93      * Language Guide</b> by Joshua Bloch, Chapter 3\r
94      * \r
95      * @return a hash code value for the object.\r
96      */\r
97     public int hashCode(\r
98     ) {\r
99         int result = super.hashCode();\r
100         \r
101         long tmp;\r
102         if (_urn != null) {\r
103            result = 37 * result + _urn.hashCode();\r
104         }\r
105         \r
106         return result;\r
107     }\r
108 \r
109     /**\r
110      * Method isValid.\r
111      * \r
112      * @return true if this object is valid according to the schema\r
113      */\r
114     public boolean isValid(\r
115     ) {\r
116         try {\r
117             validate();\r
118         } catch (org.exolab.castor.xml.ValidationException vex) {\r
119             return false;\r
120         }\r
121         return true;\r
122     }\r
123 \r
124     /**\r
125      * \r
126      * \r
127      * @param out\r
128      * @throws org.exolab.castor.xml.MarshalException if object is\r
129      * null or if any SAXException is thrown during marshaling\r
130      * @throws org.exolab.castor.xml.ValidationException if this\r
131      * object is an invalid instance according to the schema\r
132      */\r
133     public void marshal(\r
134             final java.io.Writer out)\r
135     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
136         Marshaller.marshal(this, out);\r
137     }\r
138 \r
139     /**\r
140      * \r
141      * \r
142      * @param handler\r
143      * @throws java.io.IOException if an IOException occurs during\r
144      * marshaling\r
145      * @throws org.exolab.castor.xml.ValidationException if this\r
146      * object is an invalid instance according to the schema\r
147      * @throws org.exolab.castor.xml.MarshalException if object is\r
148      * null or if any SAXException is thrown during marshaling\r
149      */\r
150     public void marshal(\r
151             final org.xml.sax.ContentHandler handler)\r
152     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
153         Marshaller.marshal(this, handler);\r
154     }\r
155 \r
156     /**\r
157      * Sets the value of field 'urn'.\r
158      * \r
159      * @param urn the value of field 'urn'.\r
160      */\r
161     public void setUrn(\r
162             final java.lang.String urn) {\r
163         this._urn = urn;\r
164     }\r
165 \r
166     /**\r
167      * Method unmarshal.\r
168      * \r
169      * @param reader\r
170      * @throws org.exolab.castor.xml.MarshalException if object is\r
171      * null or if any SAXException is thrown during marshaling\r
172      * @throws org.exolab.castor.xml.ValidationException if this\r
173      * object is an invalid instance according to the schema\r
174      * @return the unmarshaled uk.ac.vamsas.objects.core.AppData\r
175      */\r
176     public static uk.ac.vamsas.objects.core.AppData unmarshal(\r
177             final java.io.Reader reader)\r
178     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
179         return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Instance.class, reader);\r
180     }\r
181 \r
182     /**\r
183      * \r
184      * \r
185      * @throws org.exolab.castor.xml.ValidationException if this\r
186      * object is an invalid instance according to the schema\r
187      */\r
188     public void validate(\r
189     )\r
190     throws org.exolab.castor.xml.ValidationException {\r
191         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
192         validator.validate(this);\r
193     }\r
194 \r
195 }\r