KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > communication > message > AccountConfiguration


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.services.communication.message;
6
7 import java.util.ArrayList JavaDoc ;
8 import java.util.List JavaDoc ;
9 /**
10  * Created by The eXo Platform SARL .
11  * Author : Tuan Nguyen
12  * tuan08@users.sourceforge.net
13  * Date: Jun 14, 2003
14  * Time: 1:12:22 PM
15  */

16 public class AccountConfiguration {
17   private ArrayList JavaDoc accounts_ ;
18   private String JavaDoc userName_ ;
19   private String JavaDoc replyTo_ ;
20
21   public AccountConfiguration(String JavaDoc userName) {
22     userName_ = userName ;
23     accounts_ = new ArrayList JavaDoc() ;
24   }
25   
26   public String JavaDoc getReplyTo() { return replyTo_ ; }
27   public void setReplyTo(String JavaDoc replyTo) {replyTo_ = replyTo ; }
28   
29   public List JavaDoc getAccounts() { return accounts_ ; }
30   
31   public Account getAccount(String JavaDoc name) {
32     for (int i = 0; i < accounts_.size() ; i++) {
33       Account account =(Account) accounts_.get(i) ;
34       if (name.equals(account.getAccountName())) return account ;
35     }
36     return null ;
37   }
38
39   public Account removeAccount(String JavaDoc name) {
40     for (int i = 0; i < accounts_.size() ; i++) {
41       Account account =(Account) accounts_.get(i) ;
42       if (name.equals(account.getAccountName())) {
43         accounts_.remove(i) ;
44         return account ;
45       }
46     }
47     return null ;
48   }
49
50   public void addAccount(Account account) {
51    accounts_.add(account) ;
52   }
53
54   public Account getDefaultAccount() {
55     if(accounts_.size() > 0)
56       return (Account) accounts_.get(0) ;
57     return null;
58   }
59 }
Popular Tags