KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.exoplatform.services.communication.sms.model.*;
11
12 /**
13  *
14  * @author: Ove Ranheim
15  * @email: oranheim@users.sourceforge.net
16  */

17 public class MessagesImpl extends ArrayList JavaDoc implements Serializable JavaDoc, Messages {
18     
19     private LogonStatus _logonStatus;
20     private String JavaDoc _encoding;
21     private String JavaDoc _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 JavaDoc getEncoding() {
45         return _encoding;
46     }
47     
48     public void setEncoding(String JavaDoc encoding) {
49         _encoding = encoding;
50     }
51     
52     public String JavaDoc getReason() {
53         return _reason;
54     }
55     
56     public void setReason(String JavaDoc 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 JavaDoc 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 JavaDoc id) {
92         for(Iterator JavaDoc i = iterator(); i.hasNext(); ) {
93             Message m = (Message) i.next();
94             for(Iterator JavaDoc 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