KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > sps > common > 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 package sync4j.syncclient.sps.common;
20
21 import java.util.Vector JavaDoc;
22 import java.util.Date JavaDoc;
23 import java.util.Hashtable JavaDoc;
24
25
26 /**
27  * This class create DataStore
28  * and provide method to call new record
29  *
30  * @author Fabio Maggi @ Funambol
31  * $Id: DataStore.java,v 1.3 2005/01/19 11:18:36 fabius Exp $
32  */

33 public abstract class DataStore {
34
35     // ------------------------------------------------------------ Private data
36

37     private String JavaDoc dataStoreName = null;
38     private RecordMetadata recordMetadata = null;
39     private Hashtable JavaDoc dataStoreProperties = null;
40
41     //------------------------------------------------------------- Constructors
42

43     public DataStore (String JavaDoc dataStoreName, RecordMetadata recordMetadata) {
44         this.dataStoreName = dataStoreName;
45         this.recordMetadata = recordMetadata;
46     }
47
48     //----------------------------------------------------------- Public methods
49

50     /** Getter for property dataStoreProperties
51      * @return Value of Data Store Properties
52      */

53     public Hashtable JavaDoc getDataStoreProperties() {
54         return this.dataStoreProperties;
55     }
56
57     /** Setter for property dataStoreProperties.
58      * @param dataStoreProperties New value of data Store Properties.
59      */

60     public void setDataStoreProperties(Hashtable JavaDoc dataStoreProperties) {
61         this.dataStoreProperties = dataStoreProperties;
62     }
63
64
65     public String JavaDoc getDataStoreName() {
66
67         return this.dataStoreName;
68
69     }
70
71     public RecordMetadata getRecordMetadata() {
72
73         return this.recordMetadata;
74
75     }
76
77     /**
78      * create record
79      *
80      * @param key
81      * @return record
82      * @throws DataAccessException
83      **/

84     public abstract Record newRecord(String JavaDoc key)
85     throws DataAccessException;
86
87     /**
88      * read record
89      *
90      * @param record
91      * @throws DataAccessException
92      **/

93     public abstract Record readRecord(Record record)
94     throws DataAccessException;
95
96     /**
97      * store record
98      *
99      * @param record
100      * @throws DataAccessException
101      **/

102     public abstract Record storeRecord(Record record)
103     throws DataAccessException;
104
105     /**
106      * delete record
107      *
108      * @param record
109      * @throws DataAccessException
110      **/

111     public abstract void deleteRecord(Record record)
112     throws DataAccessException;
113
114     /**
115      * return alla records of dataStore
116      *
117      * @return find records
118      * @throws DataAccessException
119      **/

120     public abstract Vector JavaDoc findAllRecords()
121     throws DataAccessException;
122
123     /**
124      * return a Vector of Record
125      * found by state, last timestamp
126      *
127      * @param state state of record
128      * @param since last timestamp
129      * @return find records
130      * @throws DataAccessException
131      **/

132     public abstract Vector JavaDoc findRecords(char state, Date JavaDoc since)
133     throws DataAccessException;
134
135     /**
136      * return records of dataStore find by spsRecordFilter
137      *
138      * @param recordFilter filter
139      * @return find records
140      * @throws DataAccessException
141      **/

142     public abstract Vector JavaDoc findRecords(RecordFilter recordFilter)
143     throws DataAccessException;
144
145     /**
146      * @return datastore next key
147      * @throws DataAccessException
148      **/

149     public abstract long getNextKey()
150     throws DataAccessException;
151
152     /**
153      * Method define start DB operations
154      * @throws DataAccessException
155      */

156     public abstract void startDBOperations()
157     throws DataAccessException;
158
159     /**
160      * Method define end DB operations
161      * @throws DataAccessException
162      */

163     public abstract void commitDBOperations()
164     throws DataAccessException;;
165
166 }
Popular Tags