01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //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;
21: import java.util.Vector;
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<IContactItem> list = new Vector<IContactItem>();
30:
31: public GroupItem() {
32: super (false);
33: }
34:
35: /**
36: * @param id
37: */
38: public GroupItem(String id) {
39: super (id, false);
40: }
41:
42: /**
43: * @param id
44: * @param name
45: * @param description
46: */
47: public GroupItem(String id, String name, String description) {
48: super (id, name, description, false);
49: }
50:
51: /* (non-Javadoc)
52: * @see org.columba.addressbook.facade.IGroupItem#getContacts()
53: */
54: public List<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<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("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("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: }
|