01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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 name, String 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 add(IContactModel contact) throws StoreException {
53: String 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 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 uid, IContactModel contact)
72: throws StoreException {
73: super .modify(uid, contact);
74:
75: getDataStorageInstance().modify(uid, contact);
76:
77: }
78:
79: /**
80: * @see org.columba.addressbook.folder.IContactStorage#remove(java.lang.Object)
81: */
82: public void remove(String uid) throws StoreException {
83: super.remove(uid);
84:
85: getDataStorageInstance().remove(uid);
86:
87: }
88: }
|