KickJava   Java API By Example, From Geeks To Geeks.

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


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 <DataStore> element in SyncML devinf DTD
26  *
27  * @author Stefano Fornari @ Funambol
28  *
29  * @version $Id: DataStore.java,v 1.6 2005/03/02 20:57:37 harrie Exp $
30  */

31 public final class DataStore
32 implements java.io.Serializable JavaDoc {
33
34     // ------------------------------------------------------------ Private data
35
private SourceRef sourceRef;
36     private String JavaDoc displayName;
37     private long maxGUIDSize;
38     private ContentTypeInfo rxPref;
39     private ArrayList rx = new ArrayList();
40     private ContentTypeInfo txPref;
41     private ArrayList tx = new ArrayList();
42     private DSMem dsMem;
43     private SyncCap syncCap;
44
45     // ------------------------------------------------------------ Constructors
46

47     /**
48      * In order to expose the server configuration like WS this constructor
49      * must be public
50      */

51     public DataStore() {}
52
53     /**
54      * Creates a new DataStore object with the given input information
55      *
56      * @param sourceRef specifies the source address from the associated
57      * command - NOT NULL
58      * @param displayName the display name
59      * @param maxGUIDSize the maximum GUID size. Set to -1 if the Maximum GUID
60      * size is unknown or unspecified. Otherwise, this
61      * parameter should be a positive number.
62      * @param rxPref the relative information received to the content type
63      * preferred - NOT NULL
64      * @param rx an array of the relative info received to the content type
65      * supported - NOT NULL
66      * @param txPref the relative information trasmitted
67      * to the content type preferred - NOT NULL
68      * @param tx an array of the relative info trasmitted to the content type
69      * supported - NOT NULL
70      * @param dsMem the datastore memory info
71      * @param syncCap the synchronization capabilities - NOT NULL
72      *
73      */

74     public DataStore(final SourceRef sourceRef,
75                      final String JavaDoc displayName,
76                      final long maxGUIDSize,
77                      final ContentTypeInfo rxPref,
78                      final ContentTypeInfo[] rx,
79                      final ContentTypeInfo txPref,
80                      final ContentTypeInfo[] tx,
81                      final DSMem dsMem,
82                      final SyncCap syncCap) {
83
84         setSourceRef(sourceRef);
85         setMaxGUIDSize(maxGUIDSize);
86         setRxPref(rxPref);
87         setRx(rx);
88         setTxPref(txPref);
89         setTx(tx);
90         setSyncCap(syncCap);
91
92         this.displayName = displayName;
93         this.dsMem = dsMem;
94     }
95
96     // ---------------------------------------------------------- Public methods
97

98     /**
99      * Gets the sourceRef properties
100      *
101      * @return the sourceRef properties
102      */

103     public SourceRef getSourceRef() {
104         return sourceRef;
105     }
106
107     /**
108      * Sets the reference URI
109      *
110      * @param sourceRef the reference URI
111      *
112      */

113     public void setSourceRef(SourceRef sourceRef) {
114         if (sourceRef == null) {
115             throw new IllegalArgumentException JavaDoc("sourceRef cannot be null");
116         }
117         this.sourceRef = sourceRef;
118     }
119
120     /**
121      * Gets the displayName properties
122      *
123      * @return the displayName properties
124      */

125     public String JavaDoc getDisplayName() {
126         return displayName;
127     }
128
129     /**
130      * Sets the displayName property
131      *
132      * @param displayName the displauName property
133      *
134      */

135     public void setDisplayName(String JavaDoc displayName) {
136         this.displayName = displayName;
137     }
138
139     /**
140      * Gets the maxGUIDSize properties
141      *
142      * @return the maxGUIDSize properties
143      */

144     public long getMaxGUIDSize() {
145         return maxGUIDSize;
146     }
147
148     public void setMaxGUIDSize(long maxGUIDSize) {
149         if ((maxGUIDSize == 0) || (maxGUIDSize < -1)) {
150             throw new IllegalArgumentException JavaDoc("illegal maxGUIDSize value");
151         }
152         this.maxGUIDSize = maxGUIDSize;
153     }
154
155     /**
156      * Gets the ContentTypeInfo corresponds to &lt;Rx-Pref&gt; element
157      *
158      * @return the ContentTypeInfo corresponds to &l;tRx-Pref&gt; element
159      */

160     public ContentTypeInfo getRxPref() {
161         return rxPref;
162     }
163
164     /**
165      * Sets the preferred type and version of a content type received by the device
166      *
167      * @param rxPref the preferred type and version of a content type
168      */

169     public void setRxPref(ContentTypeInfo rxPref) {
170         if (rxPref == null) {
171             throw new IllegalArgumentException JavaDoc("rxPref cannot be null");
172         }
173         this.rxPref = rxPref;
174     }
175
176     /**
177      * Gets the ContentTypeInfo corresponds to &lt;Rx&gt; element
178      *
179      * @return the ContentTypeInfo corresponds to &lt;Rx&gt; element
180      */

181     public ArrayList getRx() {
182         return rx;
183     }
184
185     /**
186      * Sets the supported type and version of a content type received by the device
187      *
188      * @param rxCTI and array of supported type and version of a content type
189      */

190     public void setRx(ContentTypeInfo[] rxCTI) {
191         if (rxCTI == null) {
192             throw new IllegalArgumentException JavaDoc("rx cannot be null");
193         }
194         this.rx.clear();
195         this.rx.addAll(Arrays.asList(rxCTI));
196     }
197
198
199     /**
200      * Gets the ContentTypeInfo corresponds to &lt;Tx-Pref&gt; element
201      *
202      * @return the ContentTypeInfo corresponds to &lt;Tx-Pref&gt; element
203      */

204     public ContentTypeInfo getTxPref() {
205         return txPref;
206     }
207
208     /**
209      * Sets the preferred type and version of a content type trasmitted by the device
210      *
211      * @param txPref the preferred type and version of a content type
212      */

213     public void setTxPref(ContentTypeInfo txPref) {
214         if (txPref == null) {
215             throw new IllegalArgumentException JavaDoc("txPref cannot be null");
216         }
217         this.txPref = txPref;
218     }
219
220     /**
221      * Gets an array of ContentTypeInfo corresponds to &lt;Tx&gt; element
222      *
223      * @return an array of ContentTypeInfo corresponds to &lt;Tx&gt; element
224      */

225     public ArrayList getTx() {
226         return tx;
227     }
228
229     /**
230      * Sets the supported type and version of a content type trasmitted by the device
231      *
232      * @param txCTI and array of supported type and version of a content type
233      */

234     public void setTx(ContentTypeInfo[] txCTI) {
235         if (txCTI == null) {
236             throw new IllegalArgumentException JavaDoc("tx cannot be null");
237         }
238         this.tx.clear();
239         this.tx.addAll(Arrays.asList(txCTI));
240     }
241
242     /**
243      * Gets the datastore memory information.
244      *
245      * @return the datastore memory information.
246      */

247     public DSMem getDSMem() {
248         return dsMem;
249     }
250
251     /**
252      * Sets the datastore memory information
253      *
254      * @param dsMem the datastore memory information
255      */

256     public void setDSMem(DSMem dsMem) {
257         this.dsMem = dsMem;
258     }
259
260     /**
261      * Gets the synchronization capabilities of a datastore.
262      *
263      * @return the synchronization capabilities of a datastore.
264      */

265     public SyncCap getSyncCap() {
266         return syncCap;
267     }
268
269     /**
270      * Sets the synchronization capabilities of a datastore.
271      *
272      * @param syncCap the synchronization capabilities of a datastore
273      *
274      */

275     public void setSyncCap(SyncCap syncCap) {
276         if (syncCap == null) {
277             throw new IllegalArgumentException JavaDoc("syncCap cannot be null");
278         }
279         this.syncCap = syncCap;
280     }
281 }
282
Popular Tags