1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.capabilities.impl;
19
20 import org.apache.commons.collections.CollectionUtils;
21 import org.apache.jetspeed.capabilities.Client;
22
23 import java.util.ArrayList;
24 import java.util.Collection;
25
26 /***
27 * Simple implementation of the ClientRegistry interface.
28 *
29 * @author <a href="shesmer@raleigh.ibm.com">Stephan Hesmer</a>
30 * @author <a href="mailto:raphael@apache.org">Rapha\u00ebl Luta</a>
31 * @author <a href="mailto:roger.ruttimann@earthlink.net">Roger Ruttimann</a>
32 * @version $Id: ClientImpl.java 516448 2007-03-09 16:25:47Z ate $
33 */
34 public class ClientImpl implements Client, java.io.Serializable
35 {
36 private String userAgentPattern = "";
37 private String manufacturer = "";
38 private String model = "";
39 private String version = "";
40 private String name;
41 private Collection mimetypes;
42 private Collection capabilities;
43 private int preferredMimeTypeId;
44
45 private int clientId;
46 private int evalOrder = 0;
47
48 public ClientImpl()
49 {
50 }
51
52 /***
53 * Implements the equals operation so that 2 elements are equal if
54 * all their member values are equal.
55 */
56 public boolean equals(Object object)
57 {
58 if (object == this)
59 return true;
60
61 if (object == null)
62 {
63 return false;
64 }
65
66 ClientImpl obj = (ClientImpl) object;
67
68 if (name != null)
69 {
70 if (!name.equals(obj.name))
71 {
72 return false;
73 }
74 } else
75 {
76 if (obj.name != null)
77 {
78 return false;
79 }
80 }
81
82 if (userAgentPattern != null)
83 {
84 if (!userAgentPattern.equals(obj.userAgentPattern))
85 {
86 return false;
87 }
88 } else
89 {
90 if (obj.userAgentPattern != null)
91 {
92 return false;
93 }
94 }
95
96 if (manufacturer != null)
97 {
98 if (!manufacturer.equals(obj.manufacturer))
99 {
100 return false;
101 }
102 } else
103 {
104 if (obj.manufacturer != null)
105 {
106 return false;
107 }
108 }
109
110 if (model != null)
111 {
112 if (!model.equals(obj.model))
113 {
114 return false;
115 }
116 } else
117 {
118 if (obj.model != null)
119 {
120 return false;
121 }
122 }
123
124 if (version != null)
125 {
126 if (!version.equals(obj.version))
127 {
128 return false;
129 }
130 } else
131 {
132 if (obj.version != null)
133 {
134 return false;
135 }
136 }
137 if (mimetypes != null)
138 {
139 if (!CollectionUtils.isEqualCollection(mimetypes, obj.mimetypes))
140 {
141 return false;
142 }
143 }
144 else
145 {
146 if (obj.mimetypes != null)
147 {
148 return false;
149 }
150 }
151
152 if (capabilities != null)
153 {
154 if (!(CollectionUtils.isEqualCollection(capabilities,obj.capabilities )))
155 return false;
156 }
157 else
158 {
159 if (obj.capabilities != null)
160 {
161 return false;
162 }
163 }
164 return true;
165 }
166
167 public String getUserAgentPattern()
168 {
169 return userAgentPattern;
170 }
171
172 public void setUserAgentPattern(String userAgentPattern)
173 {
174 this.userAgentPattern = userAgentPattern;
175 }
176
177 public String getManufacturer()
178 {
179 return manufacturer;
180 }
181
182 public void setManufacturer(String name)
183 {
184 manufacturer = name;
185 }
186
187 public String getModel()
188 {
189 return model;
190 }
191
192 public void setModel(String name)
193 {
194 model = name;
195 }
196
197 public String getVersion()
198 {
199 return version;
200 }
201
202 public void setVersion(String name)
203 {
204 version = name;
205 }
206
207 public Collection getMimetypes()
208 {
209 if(this.mimetypes == null)
210 {
211 this.mimetypes = new ArrayList();
212 }
213 return mimetypes;
214 }
215
216 public void setMimetypes(Collection mimetypes)
217 {
218 this.mimetypes = mimetypes;
219 }
220
221 public Collection getCapabilities()
222 {
223 if(capabilities == null)
224 {
225 capabilities = new ArrayList();
226 }
227 return capabilities;
228 }
229
230 public void setCapabilities(Collection capabilities)
231 {
232 this.capabilities = capabilities;
233 }
234
235 /***
236 * Set Client ID -- Assigns the Client ID
237 * @param id
238 */
239 public void setClientId(int id)
240 {
241 this.clientId = id;
242 }
243
244 /***
245 * Get Client ID
246 * @return Client ID
247 */
248 public int getClientId()
249 {
250 return this.clientId;
251 }
252 /***
253 * @return
254 */
255 public String getName()
256 {
257 return name;
258 }
259
260 /***
261 * @param string
262 */
263 public void setName(String string)
264 {
265 name = string;
266 }
267
268 /***
269 * @return Preferred MimeType ID for Client
270 */
271 public int getPreferredMimeTypeId()
272 {
273 return this.preferredMimeTypeId;
274 }
275
276 /***
277 * Set preferred Mimetype ID for Client
278 * @param mimeTypeId MimeTypeId
279 */
280 public void setPreferredMimeTypeId(int mimeTypeId)
281 {
282 this.preferredMimeTypeId = mimeTypeId;
283 }
284
285 /***
286 * @return Returns the evalOrder.
287 */
288 public int getEvalOrder()
289 {
290 return evalOrder;
291 }
292 /***
293 * @param evalOrder The evalOrder to set.
294 */
295 public void setEvalOrder(int evalOrder)
296 {
297 this.evalOrder = evalOrder;
298 }
299 }