001: /**
002: * $Id: AddressBook.java,v 1.5 2003/06/23 20:10:06 byork Exp $
003: * Copyright 2002 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and iPlanet
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.addressbook;
014:
015: import java.util.Vector;
016: import java.util.Properties;
017: import java.util.Enumeration;
018:
019: /**
020: * Address Book abstract class: encapsulates the commands to be
021: * carried out on the address book. The Adapters implement the various
022: * commands.
023: *
024: */
025: public abstract class AddressBook extends Element {
026:
027: /**
028: * Parent ABStore associated with this address book.
029: */
030: protected ABStore store;
031:
032: /**
033: * address book ID corresponding to this user's address book store.
034: */
035: protected String abID;
036:
037: /**
038: * The locale of the address book user.
039: */
040: protected String locale;
041:
042: /**
043: * Address Book constructor.
044: *
045: * @param store The ABStore this address book belongs to
046: */
047: protected AddressBook(ABStore store, String abID) {
048: this .store = store;
049: this .abID = abID;
050: this .elementType = Element.ADDRESSBOOK;
051: }
052:
053: // Accessor methods
054:
055: /**
056: * Return the address book id for this address book.
057: *
058: * @return address book id associated with this address book.
059: */
060: public String getAbID() {
061: return abID;
062: }
063:
064: /**
065: * Return the ABStore for this address book.
066: *
067: * @return address book store associated with this address book.
068: */
069: public ABStore getStore() {
070: return store;
071: }
072:
073: /**
074: * Return the locale of the address book user.
075: *
076: * @return Locale string for the user.
077: */
078: public String getLocale() {
079: return locale;
080: }
081:
082: /**
083: * Set the locale of the address book user.
084: *
085: * @param Locale string for the user.
086: */
087: public void setLocale(String locale) {
088: this .locale = locale;
089: }
090:
091: /**
092: * Run a search on the address book given the contraints and
093: * filters specified in the ABFilter argument.
094: *
095: * @param abFilter Definition of the contraints and the filters for the
096: * fetch.
097: * @return Array of Address Book Element objects.
098: * @exception ABStoreException if unable to connect to back end service.
099: * @exception OperationNotSupportedException if the adapter doesnt support the functionality
100: */
101: public abstract Element[] fetch(ABFilter abFilter)
102: throws ABStoreException, OperationNotSupportedException;
103:
104: /**
105: * Add a new Element to the address book.
106: *
107: * @param element The new Element to be added including the unique identifier.
108: * @exception ABStoreException if unable to connect to back end service.
109: * @exception OperationNotSupportedException if the adapter doesnt support the functionality
110: */
111: public abstract void add(Element element) throws ABStoreException,
112: OperationNotSupportedException;
113:
114: /**
115: * Modify an Element from the address book.
116: *
117: * @param oldElement The Element in the address book to be replaced.
118: * @param newElement The new Element to replace the exisiting element.
119: * @exception ABStoreException if unable to connect to back end service.
120: * @exception OperationNotSupportedException if the adapter doesnt support the functionality
121: */
122: public abstract void modify(Element oldElement, Element newElement)
123: throws ABStoreException, OperationNotSupportedException;
124:
125: /**
126: * Delete an Element from the address book.
127: *
128: * @param element The Element to be deleted.
129: * @exception ABStoreException if unable to connect to back end service.
130: * @exception OperationNotSupportedException if the adapter doesnt support the functionality
131: */
132: public abstract void delete(Element element)
133: throws ABStoreException, OperationNotSupportedException;
134:
135: /**
136: * Fetch the address book entries in the specified group
137: *
138: * @return String array of Elements in the address book.
139: * @exception ABStoreException if unable to connect to back end service.
140: * @exception OperationNotSupportedException if the adapter doesnt support the functionality
141: */
142: public abstract Element[] fetchGroupMembers(ABFilter filter,
143: Group group) throws ABStoreException,
144: OperationNotSupportedException;
145:
146: /**
147: * Add an element to an existing group in the address book.
148: *
149: * @param Element The Element to be added.
150: * @param Group The group to which the element is to be added.
151: * @exception ABStoreException if unable to connect to back end service.
152: * @exception OperationNotSupportedException if the adapter doesnt support the functionality
153: */
154: public abstract void addGroupMember(Element element, Group group)
155: throws ABStoreException, OperationNotSupportedException;
156:
157: /**
158: * Delete an element from a group in the address book.
159: *
160: * @param element The Element to be deleted.
161: * @param group The Group to which the entry is to be deleted.
162: * @exception ABStoreException if unable to connect to back end service.
163: * @exception OperationNotSupportedException if the adapter doesnt support the functionality
164: */
165: public abstract void deleteGroupMember(Element element, Group group)
166: throws ABStoreException, OperationNotSupportedException;
167:
168: /**
169: * Return the ABSearchTerm object corresponding to the service type.
170: *
171: * @return ABSearchTerm object corresponding to the service type.
172: */
173: public abstract ABSearchTerm newABSearchTerm(String name,
174: String value, boolean exact);
175:
176: /**
177: * Return the ABSearchTerm object corresponding to the service type.
178: *
179: * @return ABSearchTerm object corresponding to the service type.
180: */
181: public abstract ABSearchTerm newABSearchTerm(ABSearchTerm term,
182: int op) throws ABStoreException;
183:
184: /**
185: * Return the ABSearchTerm object corresponding to the service type.
186: *
187: * @return ABSearchTerm object corresponding to the service type.
188: */
189: public abstract ABSearchTerm newABSearchTerm(ABSearchTerm[] terms,
190: int op) throws ABStoreException;
191:
192: }
|