KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > addressbook > folder > LocalFolder


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.addressbook.folder;
17
18 import org.columba.addressbook.config.FolderItem;
19 import org.columba.addressbook.model.IContactModel;
20 import org.columba.api.exception.StoreException;
21
22 /**
23  *
24  * AbstractLocalFolder-class gives as an additional abstraction-layer: -->
25  * IDataStorage
26  *
27  * this makes it very easy to add other folder-formats
28  *
29  * the important methods from Folder are just mapped to the corresponding
30  * methods from IDataStorage
31  *
32  *
33  */

34 public abstract class LocalFolder extends AbstractFolder {
35
36     protected DataStorage dataStorage;
37
38     public LocalFolder(String JavaDoc name, String JavaDoc path) {
39         super(name, path);
40     }
41
42     public LocalFolder(FolderItem item) {
43         super(item);
44
45     }
46
47     public abstract DataStorage getDataStorageInstance();
48
49     /**
50      * @see org.columba.addressbook.folder.IContactStorage#add(IContactModel)
51      */

52     public String JavaDoc add(IContactModel contact) throws StoreException {
53         String JavaDoc uid = super.add(contact);
54
55         getDataStorageInstance().save(uid, contact);
56
57         return uid;
58     }
59
60     /**
61      * @see org.columba.addressbook.folder.IContactStorage#get(java.lang.Object)
62      */

63     public IContactModel get(String JavaDoc uid) throws StoreException {
64         return getDataStorageInstance().load(uid);
65     }
66
67     /**
68      * @see org.columba.addressbook.folder.IContactStorage#modify(java.lang.Object,
69      * IContactModel)
70      */

71     public void modify(String JavaDoc uid, IContactModel contact) throws StoreException {
72         super.modify(uid, contact);
73
74         getDataStorageInstance().modify(uid, contact);
75
76     }
77
78     /**
79      * @see org.columba.addressbook.folder.IContactStorage#remove(java.lang.Object)
80      */

81     public void remove(String JavaDoc uid) throws StoreException {
82         super.remove(uid);
83
84         getDataStorageInstance().remove(uid);
85
86     }
87 }
88
Popular Tags