KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > server > store > PersistentStore


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.framework.server.store;
20
21 import java.util.Map JavaDoc;
22
23 import sync4j.framework.server.store.Clause;
24 import sync4j.framework.server.store.ConfigPersistentStoreException;
25 import sync4j.framework.server.store.PersistentStoreException;
26
27 /**
28  * A <i>PersistentStore</i> is a class that stores objects in a persistent media
29  * such as a database. The work of saving and reading data to and from the store
30  * is delegated to the store() and read() methods that can take the appropriate
31  * actions based on the type of the object that has to be written or read.
32  * <p>
33  * To store an object just call <i>store(obj)</i>.<br>
34  * To read an object call read(obj).
35  * <p>
36  * Note that those two methods return true if they know how to deal with the
37  * given object; that return value is not intended to be a success indicator. It
38  * just tells the caller that the <i>PersistentStore</i> knew how to process the
39  * given object.
40  * <p>
41  * A <i>PersistentStore</i> can be configured calling <i>configure()</i> with a
42  * <i>java.util.Map</i> parameter containing configuration information. The
43  * content of the map is implementation specific.
44  *
45  * @author Stefano Fornari @ Funambol
46  *
47  * @version $Id: PersistentStore.java,v 1.11 2005/03/02 20:57:38 harrie Exp $
48  */

49 public interface PersistentStore {
50     
51     // ---------------------------------------------------------- Public methods
52

53     /**
54      * Configure the persistent store
55      *
56      * @param config an <i>Map</i> containing configuration parameters.
57      *
58      * @throws ConfigPersistentStoreException
59      */

60     public void configure(Map JavaDoc config) throws ConfigPersistentStoreException;
61     
62     /**
63      * Store the given object to the persistent media.
64      *
65      * @param o object to be stored
66      *
67      * @return true if this <i>PersistentStore</i> processed the given object,
68      * false otherwise
69      *
70      * @throws PersistentStoreException
71      */

72     public boolean store(Object JavaDoc o) throws PersistentStoreException;
73     
74     /**
75      * Read from the persistent media the given object.
76      *
77      * @param o object to be read
78      *
79      * @return true if this <i>PersistentStore</i> processed the given object,
80      * false otherwise
81      *
82      * @throws PersistentStoreException
83      */

84     public boolean read(Object JavaDoc o) throws PersistentStoreException;
85     
86     /**
87      * Read all objects stored the persistent media.
88      *
89      * @param objClass the object class handled by the persistent store
90      *
91      * @return an array containing the objects read. If no objects are found an
92      * empty array is returned. If the persistent store has not
93      * processed the quest, null is returned.
94      *
95      * @throws PersistentStoreException
96      */

97     public Object JavaDoc[] read(Class JavaDoc objClass) throws PersistentStoreException;
98     
99     /**
100      * Delete the given object to the persistent media
101      *
102      * @param o object to be deleted
103      *
104      * @return true if this <i>PersistentStore</i> processed the given object,
105      * false otherwise
106      *
107      * @throws PersistentStoreException
108      */

109     public boolean delete(Object JavaDoc o) throws PersistentStoreException;
110     
111     /**
112      * Read all objects stored the persistent media.
113      *
114      * @param o the object class handled by the persistent store
115      * @param clause the array of select conditions
116      *
117      * @return an array containing the objects read. If no objects are found an
118      * empty array is returned. If the persistent store has not
119      * processed the quest, null is returned.
120      *
121      * @throws PersistentStoreException
122      */

123     public Object JavaDoc[] read(Object JavaDoc o, Clause clause) throws PersistentStoreException;
124
125     /**
126      * Counts all objects stored the persistent media.
127      *
128      * @param o the object class handled by the persistent store
129      * @param clause the array of select conditions
130      *
131      * @return An integer containing the number in the persistent
132      * store for the Object-type.
133      *
134      * @throws PersistentStoreException
135      */

136     public int count(Object JavaDoc o, Clause clause) throws PersistentStoreException;
137
138     
139 }
140
Popular Tags