9ffd5960c1c92bd47d2ba8e3e72132bd6e92aaec
[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             boolean thcycle;\r
68             boolean tmcycle;\r
69             if (this._urn != null) {\r
70                 if (temp._urn == null) return false;\r
71                 if (this._urn != temp._urn) {\r
72                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._urn);\r
73                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._urn);\r
74                     if (thcycle!=tmcycle) {\r
75                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._urn); };\r
76                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn); };\r
77                         return false;\r
78                     }\r
79                     if (!thcycle) {\r
80                         if (!this._urn.equals(temp._urn)) {\r
81                             org.castor.util.CycleBreaker.releaseCycleHandle(this._urn);\r
82                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn);\r
83                             return false;\r
84                         }\r
85                         org.castor.util.CycleBreaker.releaseCycleHandle(this._urn);\r
86                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn);\r
87                     }\r
88                 }\r
89             } else if (temp._urn != null)\r
90                 return false;\r
91             return true;\r
92         }\r
93         return false;\r
94     }\r
95 \r
96     /**\r
97      * Returns the value of field 'urn'.\r
98      * \r
99      * @return the value of field 'Urn'.\r
100      */\r
101     public java.lang.String getUrn(\r
102     ) {\r
103         return this._urn;\r
104     }\r
105 \r
106     /**\r
107      * Overrides the java.lang.Object.hashCode method.\r
108      * <p>\r
109      * The following steps came from <b>Effective Java Programming\r
110      * Language Guide</b> by Joshua Bloch, Chapter 3\r
111      * \r
112      * @return a hash code value for the object.\r
113      */\r
114     public int hashCode(\r
115     ) {\r
116         int result = super.hashCode();\r
117         \r
118         long tmp;\r
119         if (_urn != null\r
120             && !org.castor.util.CycleBreaker.startingToCycle(_urn)) {\r
121            result = 37 * result + _urn.hashCode();\r
122            org.castor.util.CycleBreaker.releaseCycleHandle(_urn);\r
123         }\r
124         \r
125         return result;\r
126     }\r
127 \r
128     /**\r
129      * Method isValid.\r
130      * \r
131      * @return true if this object is valid according to the schema\r
132      */\r
133     public boolean isValid(\r
134     ) {\r
135         try {\r
136             validate();\r
137         } catch (org.exolab.castor.xml.ValidationException vex) {\r
138             return false;\r
139         }\r
140         return true;\r
141     }\r
142 \r
143     /**\r
144      * \r
145      * \r
146      * @param out\r
147      * @throws org.exolab.castor.xml.MarshalException if object is\r
148      * null or if any SAXException is thrown during marshaling\r
149      * @throws org.exolab.castor.xml.ValidationException if this\r
150      * object is an invalid instance according to the schema\r
151      */\r
152     public void marshal(\r
153             final java.io.Writer out)\r
154     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
155         Marshaller.marshal(this, out);\r
156     }\r
157 \r
158     /**\r
159      * \r
160      * \r
161      * @param handler\r
162      * @throws java.io.IOException if an IOException occurs during\r
163      * marshaling\r
164      * @throws org.exolab.castor.xml.ValidationException if this\r
165      * object is an invalid instance according to the schema\r
166      * @throws org.exolab.castor.xml.MarshalException if object is\r
167      * null or if any SAXException is thrown during marshaling\r
168      */\r
169     public void marshal(\r
170             final org.xml.sax.ContentHandler handler)\r
171     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
172         Marshaller.marshal(this, handler);\r
173     }\r
174 \r
175     /**\r
176      * Sets the value of field 'urn'.\r
177      * \r
178      * @param urn the value of field 'urn'.\r
179      */\r
180     public void setUrn(\r
181             final java.lang.String urn) {\r
182         this._urn = urn;\r
183     }\r
184 \r
185     /**\r
186      * Method unmarshal.\r
187      * \r
188      * @param reader\r
189      * @throws org.exolab.castor.xml.MarshalException if object is\r
190      * null or if any SAXException is thrown during marshaling\r
191      * @throws org.exolab.castor.xml.ValidationException if this\r
192      * object is an invalid instance according to the schema\r
193      * @return the unmarshaled uk.ac.vamsas.objects.core.AppData\r
194      */\r
195     public static uk.ac.vamsas.objects.core.AppData unmarshal(\r
196             final java.io.Reader reader)\r
197     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
198         return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Instance.class, reader);\r
199     }\r
200 \r
201     /**\r
202      * \r
203      * \r
204      * @throws org.exolab.castor.xml.ValidationException if this\r
205      * object is an invalid instance according to the schema\r
206      */\r
207     public void validate(\r
208     )\r
209     throws org.exolab.castor.xml.ValidationException {\r
210         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
211         validator.validate(this);\r
212     }\r
213 \r
214 }\r