1
2
3
4
5
6
7
8 package org.astrogrid.registry.beans.resource;
9
10
11
12
13
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import org.exolab.castor.xml.MarshalException;
19 import org.exolab.castor.xml.Marshaller;
20 import org.exolab.castor.xml.Unmarshaller;
21 import org.exolab.castor.xml.ValidationException;
22 import org.xml.sax.ContentHandler;
23
24 /***
25 * Class RelatedResourceType.
26 *
27 * @version $Revision: 1.14 $ $Date: 2007/01/04 16:26:22 $
28 */
29 public class RelatedResourceType extends org.astrogrid.common.bean.BaseBean
30 implements java.io.Serializable
31 {
32
33
34
35
36
37
38 /***
39 * a property that relates one resource to another.
40 *
41 */
42 private java.lang.String _relationship;
43
44 /***
45 * the resource that is related to the current one being
46 * described.
47 *
48 */
49 private org.astrogrid.registry.beans.resource.ResourceReferenceType _relatedTo;
50
51
52
53
54
55
56 public RelatedResourceType() {
57 super();
58 }
59
60
61
62
63
64
65 /***
66 * Note: hashCode() has not been overriden
67 *
68 * @param obj
69 */
70 public boolean equals(java.lang.Object obj)
71 {
72 if ( this == obj )
73 return true;
74
75 if (super.equals(obj)==false)
76 return false;
77
78 if (obj instanceof RelatedResourceType) {
79
80 RelatedResourceType temp = (RelatedResourceType)obj;
81 if (this._relationship != null) {
82 if (temp._relationship == null) return false;
83 else if (!(this._relationship.equals(temp._relationship)))
84 return false;
85 }
86 else if (temp._relationship != null)
87 return false;
88 if (this._relatedTo != null) {
89 if (temp._relatedTo == null) return false;
90 else if (!(this._relatedTo.equals(temp._relatedTo)))
91 return false;
92 }
93 else if (temp._relatedTo != null)
94 return false;
95 return true;
96 }
97 return false;
98 }
99
100 /***
101 * Returns the value of field 'relatedTo'. The field
102 * 'relatedTo' has the following description: the resource that
103 * is related to the current one being described.
104 *
105 *
106 * @return the value of field 'relatedTo'.
107 */
108 public org.astrogrid.registry.beans.resource.ResourceReferenceType getRelatedTo()
109 {
110 return this._relatedTo;
111 }
112
113 /***
114 * Returns the value of field 'relationship'. The field
115 * 'relationship' has the following description: a property
116 * that relates one resource to another.
117 *
118 *
119 * @return the value of field 'relationship'.
120 */
121 public java.lang.String getRelationship()
122 {
123 return this._relationship;
124 }
125
126 /***
127 * Method isValid
128 */
129 public boolean isValid()
130 {
131 try {
132 validate();
133 }
134 catch (org.exolab.castor.xml.ValidationException vex) {
135 return false;
136 }
137 return true;
138 }
139
140 /***
141 * Method marshal
142 *
143 * @param out
144 */
145 public void marshal(java.io.Writer out)
146 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
147 {
148
149 Marshaller.marshal(this, out);
150 }
151
152 /***
153 * Method marshal
154 *
155 * @param handler
156 */
157 public void marshal(org.xml.sax.ContentHandler handler)
158 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
159 {
160
161 Marshaller.marshal(this, handler);
162 }
163
164 /***
165 * Sets the value of field 'relatedTo'. The field 'relatedTo'
166 * has the following description: the resource that is related
167 * to the current one being described.
168 *
169 *
170 * @param relatedTo the value of field 'relatedTo'.
171 */
172 public void setRelatedTo(org.astrogrid.registry.beans.resource.ResourceReferenceType relatedTo)
173 {
174 this._relatedTo = relatedTo;
175 }
176
177 /***
178 * Sets the value of field 'relationship'. The field
179 * 'relationship' has the following description: a property
180 * that relates one resource to another.
181 *
182 *
183 * @param relationship the value of field 'relationship'.
184 */
185 public void setRelationship(java.lang.String relationship)
186 {
187 this._relationship = relationship;
188 }
189
190 /***
191 * Method unmarshalRelatedResourceType
192 *
193 * @param reader
194 */
195 public static org.astrogrid.registry.beans.resource.RelatedResourceType unmarshalRelatedResourceType(java.io.Reader reader)
196 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
197 {
198 return (org.astrogrid.registry.beans.resource.RelatedResourceType) Unmarshaller.unmarshal(org.astrogrid.registry.beans.resource.RelatedResourceType.class, reader);
199 }
200
201 /***
202 * Method validate
203 */
204 public void validate()
205 throws org.exolab.castor.xml.ValidationException
206 {
207 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
208 validator.validate(this);
209 }
210
211 }