KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > sps > DataStore


1 package sync4j.syncclient.sps;
2
3 import java.util.Enumeration JavaDoc;
4 import java.util.Vector JavaDoc;
5
6 import javax.microedition.rms.RecordStore;
7
8 import javax.microedition.pim.Event;
9 import javax.microedition.pim.EventList;
10 import javax.microedition.pim.PIM;
11 import javax.microedition.pim.PIMException;
12 import net.rim.device.api.system.PersistentObject;
13 import net.rim.device.api.system.PersistentStore;
14 import net.rim.device.api.ui.component.Dialog;
15 import net.rim.device.api.util.StringMatch;
16 import sync4j.syncclient.util.StaticDataHelper;
17
18 import sync4j.syncclient.blackberry.parser.ParserFactory;
19 import sync4j.syncclient.blackberry.parser.EventParser;
20
21 /**
22  * This class provide abstract methods
23  * to access device database
24  *
25  * @author Fabio Maggi @ Funambol
26  * $Id: DataStore.java,v 1.6 2005/02/22 16:48:13 fabius Exp $
27  */

28 public abstract class DataStore {
29       //------------------------------------------------------------- Constants
30

31     public static final char RECORD_STATE_NEW = 'N' ;
32     public static final char RECORD_STATE_DELETED = 'D' ;
33     public static final char RECORD_STATE_UPDATED = 'U' ;
34     public static final char RECORD_STATE_UNSIGNED = ' ' ;
35        
36     //------------------------------------------------------------- Private Data
37

38     public static DataStore getDataStore (String JavaDoc datastoreName) {
39     
40         StaticDataHelper stdh = new StaticDataHelper();
41         
42         if (stdh.getContactSourceUri().equals(datastoreName)) {
43             return new ContactDataStore ();
44         } else {
45             return new EventDataStore ();
46         }
47     }
48     
49     /**
50      * Set last timestamp in dedicate recordStore
51      * @param lastTimestamp
52      * @throws DataAccessException
53      **/

54     public abstract void setLastTimestamp(long lastTimestamp)
55     throws DataAccessException;
56
57
58     /**
59      * @return last timestamp from dedicate recordstore
60      * @throws DataAccessException
61      **/

62     public abstract long getLastTimestamp()
63     throws DataAccessException;
64
65     /**
66      * if record exist in database, update records
67      * if record not exist in database, add record
68      * @param record record to store
69      * @throws DataAccessException
70      **/

71     public abstract Record setRecord(Record record, boolean modify)
72     throws DataAccessException;
73
74     /**
75      * Delete a record from the event database.
76      * @param record
77      * @throws DataAccessException
78      */

79     public abstract void deleteRecord(Record record)
80     throws DataAccessException;
81     
82     /**
83      * return no deleted records from device recordstore
84      *
85      * @return find records
86      * @throws DataAccessException
87      **/

88     public abstract Vector JavaDoc getNoDeletedRecords()
89     throws DataAccessException;
90     
91     public abstract Vector JavaDoc getRecords(char state)
92     throws DataAccessException;
93     
94     public abstract void startDSOperations();
95
96     /**
97      * execute commit recordstore operations
98      * remove records signed as DELETED 'D'
99      * mark UNSIGNED ' ' records signed as NEW 'N' and UPDATED 'U'
100      *
101      * @throws DataAccessException
102      *
103      */

104     public abstract void commitDSOperations()
105     throws DataAccessException;
106
107 }
108
Popular Tags