KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > core > DevInf


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19
20 package sync4j.framework.core;
21
22 import java.util.*;
23
24 /**
25  * Corresponds to the &l;tDevInf> element in the SyncML devinf DTD
26  *
27  * @author Stefano Fornari @ Funambol
28  *
29  * @version $Id: DevInf.java,v 1.6 2005/03/02 20:57:37 harrie Exp $
30  */

31 public final class DevInf
32 implements java.io.Serializable JavaDoc {
33
34     // ------------------------------------------------------------ Private data
35
private VerDTD verDTD;
36     private String JavaDoc man;
37     private String JavaDoc mod;
38     private String JavaDoc oem;
39     private String JavaDoc fwV;
40     private String JavaDoc swV;
41     private String JavaDoc hwV;
42     private String JavaDoc devID;
43     private String JavaDoc devTyp;
44     private ArrayList datastores = new ArrayList();
45     private ArrayList ctCap = new ArrayList();
46     private ArrayList ext = new ArrayList();
47     private Boolean JavaDoc utc;
48     private Boolean JavaDoc supportLargeObjs;
49     private Boolean JavaDoc supportNumberOfChanges;
50
51     // ------------------------------------------------------------ Constructors
52
/**
53      * In order to expose the server configuration like WS this constructor
54      * must be public
55      */

56     public DevInf() {}
57
58     /**
59      * Creates a new DevInf object with the given parameter
60      *
61      * @param verDTD the DTD version - NOT NULL
62      * @param man the device manufacturer
63      * @param mod the device model name
64      * @param oem the device OEM
65      * @param fwV the device firmware version
66      * @param swV the device software version
67      * @param hwV the device hardware version
68      * @param devID the device ID - NOT NULL
69      * @param devTyp the device type - NOT NULL
70      * @param dataStores the array of datastore - NOT NULL
71      * @param ctCap the array of content type capability - NOT NULL
72      * @param ext the array of extension element name - NOT NULL
73      * @param utc is true if the device supports UTC based time
74      * @param supportLargeObjs is true if the device supports handling of large objects
75      * @param supportNumberOfChanges is true if the device supports number of changes
76      *
77      */

78     public DevInf(final VerDTD verDTD,
79                   final String JavaDoc man,
80                   final String JavaDoc mod,
81                   final String JavaDoc oem,
82                   final String JavaDoc fwV,
83                   final String JavaDoc swV,
84                   final String JavaDoc hwV,
85                   final String JavaDoc devID,
86                   final String JavaDoc devTyp,
87                   final DataStore[] dataStores,
88                   final CTCap[] ctCap,
89                   final Ext[] ext,
90                   final boolean utc,
91                   final boolean supportLargeObjs,
92                   final boolean supportNumberOfChanges) {
93
94         setVerDTD(verDTD);
95         setDevID(devID);
96         setDevTyp(devTyp);
97         setDataStore(dataStores);
98         setCTCap(ctCap);
99         setExt(ext);
100
101         this.man = man;
102         this.mod = mod;
103         this.oem = oem;
104         this.fwV = fwV;
105         this.swV = swV;
106         this.hwV = hwV;
107
108
109         this.utc = (utc) ? new Boolean JavaDoc(utc) : null;
110         this.supportLargeObjs =
111                       (supportLargeObjs) ? new Boolean JavaDoc(supportLargeObjs) : null;
112         this.supportNumberOfChanges =
113           (supportNumberOfChanges) ? new Boolean JavaDoc(supportNumberOfChanges) : null;
114     }
115
116     // ---------------------------------------------------------- Public methods
117
/**
118      * Gets the DTD version property
119      *
120      * @return the DTD version property
121      */

122     public VerDTD getVerDTD() {
123         return verDTD;
124     }
125
126     /**
127      * Sets the DTD version property
128      *
129      * @param verDTD the DTD version
130      */

131     public void setVerDTD(VerDTD verDTD) {
132         if (verDTD == null) {
133             throw new IllegalArgumentException JavaDoc("verDTD cannot be null");
134         }
135         this.verDTD = verDTD;
136     }
137
138     /**
139      * Gets the device manufacturer property
140      *
141      * @return the device manufacturer property
142      */

143     public String JavaDoc getMan() {
144         return man;
145     }
146
147     /**
148      * Sets the device manufacturer property
149      *
150      * @param man the device manufacturer property
151      *
152      */

153     public void setMan(String JavaDoc man) {
154         this.man = man;
155     }
156
157     /**
158      * Gets the model name of device
159      *
160      * @return the model name of device
161      */

162     public String JavaDoc getMod() {
163         return mod;
164     }
165
166     /**
167      * Sets the device model property
168      *
169      * @param mod the device model property
170      *
171      */

172     public void setMod(String JavaDoc mod) {
173         this.mod = mod;
174     }
175
176     /**
177      * Gets the Original Equipment Manufacturer of the device
178      *
179      * @return the OEM property
180      */

181     public String JavaDoc getOEM() {
182         return oem;
183     }
184
185     /**
186      * Sets the Original Equipment Manufacturer of the device
187      *
188      * @param oem the Original Equipment Manufacturer of the device
189      *
190      */

191     public void setOEM(String JavaDoc oem) {
192         this.oem = oem;
193     }
194
195     /**
196      * Gets the firmware version property
197      *
198      * @return the firmware version property
199      */

200     public String JavaDoc getFwV() {
201         return fwV;
202     }
203
204     /**
205      * Sets the firmware version property
206      *
207      * @param fwV the firmware version property
208      *
209      */

210     public void setFwV(String JavaDoc fwV) {
211         this.fwV =fwV;
212     }
213
214     /**
215      * Gets the software version property
216      *
217      * @return the software version property
218      */

219     public String JavaDoc getSwV() {
220         return swV;
221     }
222
223     /**
224      * Sets the software version property
225      *
226      * @param swV the software version property
227      *
228      */

229     public void setSwV(String JavaDoc swV) {
230         this.swV =swV;
231     }
232
233     /**
234      * Gets the hardware version property
235      *
236      * @return the hardware version property
237      */

238     public String JavaDoc getHwV() {
239         return hwV;
240     }
241
242     /**
243      * Sets the hardware version property
244      *
245      * @param hwV the hardware version property
246      *
247      */

248     public void setHwV(String JavaDoc hwV) {
249         this.hwV =hwV;
250     }
251
252     /**
253      * Gets the device identifier
254      *
255      * @return the device identifier
256      */

257     public String JavaDoc getDevID() {
258         return devID;
259     }
260
261     /**
262      * Sets the device identifier
263      *
264      * @param devID the device identifier
265      *
266      */

267     public void setDevID(String JavaDoc devID) {
268         if (devID == null) {
269             throw new IllegalArgumentException JavaDoc("devID cannot be null");
270         }
271         this.devID = devID;
272     }
273
274     /**
275      * Gets the device type
276      *
277      * @return the device type
278      */

279     public String JavaDoc getDevTyp() {
280         return devTyp;
281     }
282
283     /**
284      * Sets the device type
285      *
286      * @param devTyp the device type
287      *
288      */

289     public void setDevTyp(String JavaDoc devTyp) {
290         if (devTyp == null) {
291             throw new IllegalArgumentException JavaDoc("devTyp cannot be null");
292         }
293         this.devTyp = devTyp;
294     }
295
296     /**
297      * Gets the array of datastore
298      *
299      * @return the array of datastore
300      */

301     public ArrayList getDataStore() {
302         return this.datastores;
303     }
304
305     /**
306      * Sets an array of datastore
307      *
308      * @param dataStores an array of datastore
309      *
310      */

311     public void setDataStore(DataStore[] dataStores) {
312         if (dataStores == null ) {
313             throw new IllegalArgumentException JavaDoc("datastores cannot be null");
314         }
315         this.datastores.clear();
316         this.datastores.addAll(Arrays.asList(dataStores));
317     }
318
319     /**
320      * Gets the array of content type capability
321      *
322      * @return the array of content type capability
323      */

324     public ArrayList getCTCap() {
325         return this.ctCap;
326     }
327
328     /**
329      * Sets an array of content type capability
330      *
331      * @param ctCap an array of content type capability
332      *
333      */

334     public void setCTCap(CTCap[] ctCap) {
335         if (ctCap != null) {
336             this.ctCap.clear();
337             this.ctCap.addAll(Arrays.asList(ctCap));
338         } else {
339             this.ctCap = null;
340         }
341     }
342
343     /**
344      * Gets the array of extension
345      *
346      * @return the array of extension
347      */

348     public ArrayList getExt() {
349         return this.ext;
350     }
351
352     /**
353      * Sets an array of extensions
354      *
355      * @param ext an array of extensions
356      *
357      */

358     public void setExt(Ext[] ext) {
359         if (ext != null) {
360             this.ext.clear();
361             this.ext.addAll(Arrays.asList(ext));
362         } else {
363             this.ext = null;
364         }
365     }
366
367     /**
368      * Gets true if the device supports UTC based time
369      *
370      * @return true if the device supports UTC based time
371      */

372     public boolean isUTC() {
373         return (utc != null);
374     }
375
376     /**
377      * Sets the UTC property
378      *
379      * @param utc is true if the device supports UTC based time
380      */

381     public void setUTC(Boolean JavaDoc utc) {
382         this.utc = (utc.booleanValue()) ? utc : null;
383     }
384
385     /**
386      * Sets the UTC property
387      *
388      * @param utc is true if the device supports UTC based time
389      */

390     public void setUTC(boolean utc) {
391        setUTC(new Boolean JavaDoc(utc));
392     }
393
394
395     /**
396      * Gets the Boolean value of utc
397      *
398      * @return true if the device supports UTC based time
399      */

400     public Boolean JavaDoc getUTC() {
401         if (utc == null || !utc.booleanValue()) {
402             return null;
403         }
404         return utc;
405     }
406
407     /**
408      * Gets true if the device supports handling of large objects
409      *
410      * @return true if the device supports handling of large objects
411      */

412     public boolean isSupportLargeObjs() {
413         return (supportLargeObjs != null);
414     }
415
416     /**
417      * Sets the supportLargeObjs property
418      *
419      * @param supportLargeObjs is true if the device supports handling of large objects
420      *
421      */

422     public void setSupportLargeObjs(Boolean JavaDoc supportLargeObjs) {
423         this.supportLargeObjs = (supportLargeObjs.booleanValue()) ?
424                                 supportLargeObjs :
425                                 null
426                                 ;
427     }
428
429     /**
430      * Sets the supportLargeObjs property
431      *
432      * @param supportLargeObjs is true if the device supports handling of large objects
433      *
434      */

435     public void setSupportLargeObjs(boolean supportLargeObjs) {
436        setSupportLargeObjs(new Boolean JavaDoc(supportLargeObjs));
437     }
438
439     /**
440      * Gets the Boolean value of supportLargeObjs
441      *
442      * @return true if the device supports handling of large objects
443      */

444     public Boolean JavaDoc getSupportLargeObjs() {
445         if (supportLargeObjs == null || !supportLargeObjs.booleanValue()) {
446             return null;
447         }
448         return supportLargeObjs;
449     }
450
451     /**
452      * Gets true if the device supports number of changes
453      *
454      * @return true if the device supports number of changes
455      */

456     public boolean isSupportNumberOfChanges() {
457         return (supportNumberOfChanges != null);
458     }
459
460     /**
461      * Sets the supportNumberOfChanges property
462      *
463      * @param supportNumberOfChanges is true if the device supports number of changes
464      *
465      */

466     public void setSupportNumberOfChanges(Boolean JavaDoc supportNumberOfChanges) {
467         this.supportNumberOfChanges = (supportNumberOfChanges.booleanValue()) ?
468                                       supportNumberOfChanges :
469                                       null
470                                       ;
471     }
472
473     /**
474      * Sets the supportNumberOfChanges property
475      *
476      * @param supportNumberOfChanges is true if the device supports number of changes
477      *
478      */

479     public void setSupportNumberOfChanges(boolean supportNumberOfChanges) {
480        setSupportNumberOfChanges(new Boolean JavaDoc(supportNumberOfChanges));
481     }
482
483     /**
484      * Gets the Boolean value of supportNumberOfChanges
485      *
486      * @return true if the device supports number of changes
487      */

488     public Boolean JavaDoc getSupportNumberOfChanges() {
489         if (supportNumberOfChanges == null || !supportNumberOfChanges.booleanValue()) {
490             return null;
491         }
492         return supportNumberOfChanges;
493     }
494 }
495
Popular Tags