KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > samples > contacts > CompanyRepository


1
2 package org.objectweb.jac.samples.contacts;
3
4 import java.util.HashSet JavaDoc;
5 import java.util.Iterator JavaDoc;
6 import java.util.Set JavaDoc;
7 import java.util.Vector JavaDoc;
8 import java.util.List JavaDoc;
9
10 public class CompanyRepository {
11
12     ContactRepository contactRepository = null;
13    
14     public CompanyRepository(ContactRepository cr) {
15         contactRepository = cr;
16     }
17
18     HashSet JavaDoc companies = new HashSet JavaDoc();
19
20     /**
21      * Get the value of companies.
22      * @return value of companies.
23      */

24     public Set JavaDoc getCompanies() {
25         return companies;
26     }
27    
28     /**
29      * Add a company to companies.
30      * @param company the company added.
31      */

32     public void addCompany( Company company ) {
33         companies.add( company );
34     }
35
36     public void showAll() {
37         List JavaDoc contacts = contactRepository.getContacts();
38         Iterator JavaDoc it = contacts.iterator();
39         while(it.hasNext()) {
40             Person cur = (Person)it.next();
41             Company company = cur.getCompany();
42             if (company == null)
43                 continue;
44             companies.add(company);
45         }
46     }
47 }
48
Popular Tags