KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > communication > sms > model > MessageImpl


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.sms.model;
6
7 import java.io.Serializable JavaDoc;
8 import java.util.ArrayList JavaDoc;
9 import java.util.Iterator JavaDoc;
10 import java.util.List JavaDoc;
11 import org.exoplatform.services.communication.sms.encoder.MessageFormat;
12 import org.exoplatform.services.communication.sms.model.Message;
13 import org.exoplatform.services.communication.sms.model.Recipient;
14
15
16 /**
17  * @author: Ove Ranheim
18  * @email: oranheim@users.sourceforge.net
19  */

20 public class MessageImpl implements Serializable JavaDoc, Message {
21
22     private String JavaDoc _from = "";
23     private List JavaDoc _recipients = new ArrayList JavaDoc();
24     private Object JavaDoc _content = "";
25     private MessageFormat _format;
26
27     public MessageImpl() {
28     }
29
30     public String JavaDoc getFrom() {
31         return _from;
32     }
33
34     public Message setFrom(String JavaDoc from) {
35         _from = from;
36         return this;
37     }
38
39     public List JavaDoc getRecipients() {
40         return _recipients;
41     }
42
43     public Recipient addRecipient(Recipient recipient) {
44         _recipients.add(recipient);
45         return recipient;
46     }
47     
48     public Recipient addRecipient(String JavaDoc recipient) {
49         Recipient r = new RecipientImpl(recipient);
50         _recipients.add(r);
51         return r;
52     }
53     
54     public void removeRecipient(Recipient recipient) {
55         _recipients.remove(recipient);
56     }
57
58     public void removeRecipient(int index) {
59         _recipients.remove(index);
60     }
61     
62     public Recipient findRecipientById(Integer JavaDoc id) {
63         for (Iterator JavaDoc i = _recipients.iterator(); i.hasNext(); ) {
64             Recipient r = (Recipient) i.next();
65             if (id.equals(r.getId())) {
66                 return r;
67             }
68         }
69         return null;
70     }
71     
72     public void clearRecipients() {
73         _recipients.clear();
74     }
75     
76     public int countRecipients() {
77         return _recipients.size();
78     }
79     
80     public Object JavaDoc getContent() {
81         return _content;
82     }
83
84     public Message setContent(Object JavaDoc content) {
85         _content = content;
86         return this;
87     }
88
89     public MessageFormat getFormat() {
90         return _format;
91     }
92
93     public Message setFormat(MessageFormat format) {
94         _format = format;
95         return this;
96     }
97
98 }
99
100
Popular Tags