KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > addressbook > facade > GroupItem


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.addressbook.facade;
19
20 import java.util.List JavaDoc;
21 import java.util.Vector JavaDoc;
22
23 /**
24  * Convenience class implementation of IGroupItem. This implementation class can be used by clients
25  * of the addressbook facade if desired, or can be implemented differently, if necessary.
26  */

27 public class GroupItem extends HeaderItem implements IGroupItem {
28
29     private List JavaDoc<IContactItem> list = new Vector JavaDoc<IContactItem>();
30
31     public GroupItem() {
32         super(false);
33     }
34
35     /**
36      * @param id
37      */

38     public GroupItem(String JavaDoc id) {
39         super(id, false);
40     }
41     
42     /**
43      * @param id
44      * @param name
45      * @param description
46      */

47     public GroupItem(String JavaDoc id, String JavaDoc name, String JavaDoc description) {
48         super(id, name, description, false);
49     }
50
51     /* (non-Javadoc)
52      * @see org.columba.addressbook.facade.IGroupItem#getContacts()
53      */

54     public List JavaDoc<IContactItem> getContacts() {
55         return list;
56     }
57
58     /* (non-Javadoc)
59      * @see org.columba.addressbook.facade.IGroupItem#setContacts(java.util.List)
60      */

61     public void setContacts(List JavaDoc<IContactItem> contacts) {
62         list = contacts;
63     }
64
65     /* (non-Javadoc)
66      * @see org.columba.addressbook.facade.IGroupItem#addContact(org.columba.addressbook.facade.IContactItem)
67      */

68     public void addContact(IContactItem item) {
69         if (item == null)
70             throw new IllegalArgumentException JavaDoc("item == null");
71         list.add(item);
72     }
73
74     /* (non-Javadoc)
75      * @see org.columba.addressbook.facade.IGroupItem#removeContact(org.columba.addressbook.facade.IContactItem)
76      */

77     public void removeContact(IContactItem item) {
78         if (item == null)
79             throw new IllegalArgumentException JavaDoc("item == null");
80         list.remove(item);
81     }
82
83     /* (non-Javadoc)
84      * @see org.columba.addressbook.facade.IGroupItem#getContactCount()
85      */

86     public int getContactCount() {
87         return list.size();
88     }
89 }
90
Popular Tags