1 5 package org.exoplatform.services.communication.sms.model; 6 7 import java.io.Serializable ; 8 import java.util.ArrayList ; 9 import java.util.Iterator ; 10 import java.util.List ; 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 20 public class MessageImpl implements Serializable , Message { 21 22 private String _from = ""; 23 private List _recipients = new ArrayList (); 24 private Object _content = ""; 25 private MessageFormat _format; 26 27 public MessageImpl() { 28 } 29 30 public String getFrom() { 31 return _from; 32 } 33 34 public Message setFrom(String from) { 35 _from = from; 36 return this; 37 } 38 39 public List 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 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 id) { 63 for (Iterator 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 getContent() { 81 return _content; 82 } 83 84 public Message setContent(Object 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 |