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 org.exoplatform.services.communication.sms.model.*; 11 12 17 public class MessagesImpl extends ArrayList implements Serializable , Messages { 18 19 private LogonStatus _logonStatus; 20 private String _encoding; 21 private String _reason; 22 private boolean _gotError; 23 24 public MessagesImpl() { 25 clear(); 26 } 27 28 public void clear() { 29 super.clear(); 30 _logonStatus = LogonStatus.NONE; 31 _encoding = "UTF-8"; 32 _reason = ""; 33 _gotError = false; 34 } 35 36 public LogonStatus getLogonStatus() { 37 return _logonStatus; 38 } 39 40 public void setLogonStatus(LogonStatus logonStatus) { 41 _logonStatus = logonStatus; 42 } 43 44 public String getEncoding() { 45 return _encoding; 46 } 47 48 public void setEncoding(String encoding) { 49 _encoding = encoding; 50 } 51 52 public String getReason() { 53 return _reason; 54 } 55 56 public void setReason(String reason) { 57 _reason = reason; 58 } 59 60 public boolean hasErrorOccured() { 61 return _gotError; 62 } 63 64 public void errorOccured() { 65 _gotError = true; 66 } 67 68 public Iterator iterator() { 69 return super.iterator(); 70 } 71 72 public Message getMessage(int index) { 73 return (Message) get(index); 74 } 75 76 public Message addMessage() { 77 Message message = new MessageImpl(); 78 add( message ); 79 return message; 80 } 81 82 public Message addMessage(Message message) { 83 add(message); 84 return message; 85 } 86 87 public void removeMessage(Message message) { 88 remove(message); 89 } 90 91 public Message findMessageById(Integer id) { 92 for(Iterator i = iterator(); i.hasNext(); ) { 93 Message m = (Message) i.next(); 94 for(Iterator j = m.getRecipients().iterator(); j.hasNext(); ) { 95 Recipient r = (Recipient) j.next(); 96 if (id.equals(r.getId())) { 97 return m; 98 } 99 } 100 } 101 return null; 102 } 103 104 public int count() { 105 return size(); 106 } 107 108 } 109 | Popular Tags |