1 2 package org.objectweb.jac.samples.contacts; 3 4 import java.util.HashSet ; 5 import java.util.Iterator ; 6 import java.util.Set ; 7 import java.util.Vector ; 8 import java.util.List ; 9 10 public class CompanyRepository { 11 12 ContactRepository contactRepository = null; 13 14 public CompanyRepository(ContactRepository cr) { 15 contactRepository = cr; 16 } 17 18 HashSet companies = new HashSet (); 19 20 24 public Set getCompanies() { 25 return companies; 26 } 27 28 32 public void addCompany( Company company ) { 33 companies.add( company ); 34 } 35 36 public void showAll() { 37 List contacts = contactRepository.getContacts(); 38 Iterator 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 |