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 ServiceType.
26 *
27 * @version $Revision: 1.11 $ $Date: 2005/01/23 12:51:51 $
28 */
29 public class ServiceType extends org.astrogrid.registry.beans.resource.ResourceType
30 implements java.io.Serializable
31 {
32
33
34
35
36
37
38 /***
39 * a specific description of the context and capabilities of a
40 * service.
41 *
42 */
43 private org.astrogrid.registry.beans.resource.CapabilityType _capability;
44
45 /***
46 * A description of a service interface.
47 *
48 */
49 private org.astrogrid.registry.beans.resource.InterfaceType _interface;
50
51
52
53
54
55
56 public ServiceType() {
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 ServiceType) {
79
80 ServiceType temp = (ServiceType)obj;
81 if (this._capability != null) {
82 if (temp._capability == null) return false;
83 else if (!(this._capability.equals(temp._capability)))
84 return false;
85 }
86 else if (temp._capability != null)
87 return false;
88 if (this._interface != null) {
89 if (temp._interface == null) return false;
90 else if (!(this._interface.equals(temp._interface)))
91 return false;
92 }
93 else if (temp._interface != null)
94 return false;
95 return true;
96 }
97 return false;
98 }
99
100 /***
101 * Returns the value of field 'capability'. The field
102 * 'capability' has the following description: a specific
103 * description of the context and capabilities of a service.
104 *
105 *
106 * @return the value of field 'capability'.
107 */
108 public org.astrogrid.registry.beans.resource.CapabilityType getCapability()
109 {
110 return this._capability;
111 }
112
113 /***
114 * Returns the value of field 'interface'. The field
115 * 'interface' has the following description: A description of
116 * a service interface.
117 *
118 *
119 * @return the value of field 'interface'.
120 */
121 public org.astrogrid.registry.beans.resource.InterfaceType getInterface()
122 {
123 return this._interface;
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 'capability'. The field 'capability'
166 * has the following description: a specific description of the
167 * context and capabilities of a service.
168 *
169 *
170 * @param capability the value of field 'capability'.
171 */
172 public void setCapability(org.astrogrid.registry.beans.resource.CapabilityType capability)
173 {
174 this._capability = capability;
175 }
176
177 /***
178 * Sets the value of field 'interface'. The field 'interface'
179 * has the following description: A description of a service
180 * interface.
181 *
182 *
183 * @param _interface
184 * @param interface the value of field 'interface'.
185 */
186 public void setInterface(org.astrogrid.registry.beans.resource.InterfaceType _interface)
187 {
188 this._interface = _interface;
189 }
190
191 /***
192 * Method unmarshalServiceType
193 *
194 * @param reader
195 */
196 public static org.astrogrid.registry.beans.resource.ServiceType unmarshalServiceType(java.io.Reader reader)
197 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
198 {
199 return (org.astrogrid.registry.beans.resource.ServiceType) Unmarshaller.unmarshal(org.astrogrid.registry.beans.resource.ServiceType.class, reader);
200 }
201
202 /***
203 * Method validate
204 */
205 public void validate()
206 throws org.exolab.castor.xml.ValidationException
207 {
208 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
209 validator.validate(this);
210 }
211
212 }