KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > freecs > content > MessageState


1 /**
2  * Copyright (C) 2003 Manfred Andres
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */

18 package freecs.content;
19 import freecs.Server;
20 import freecs.core.*;
21
22 /**
23  * Used to store values needed for a message and to
24  * make it accessible to other methods (makes it possible
25  * to move message-commands into seperate-classes)
26  */

27 public class MessageState {
28     public volatile boolean useRenderCache, moderated;
29     public volatile Group sourceGroup, targetGroup;
30     public volatile User sender, usercontext;
31     public volatile String JavaDoc message, param, msg, reason;
32     public volatile String JavaDoc msgTemplate;
33     public volatile ConnectionBuffer cb;
34     public MessageParser mp;
35     public volatile Object JavaDoc[] usrList;
36
37     public MessageState (MessageParser mp) {
38         this.mp=mp;
39         clear();
40         if (Server.TRACE_CREATE_AND_FINALIZE)
41             Server.log (this, "++++++++++++++++++++++++++++++++++++++++CREATE", Server.MSG_STATE, Server.LVL_VERY_VERBOSE);
42     }
43     
44     public void clear() {
45         sender=null;
46         usercontext=null;
47         message=null;
48         reason=null;
49         msg=null;
50         msgTemplate=null;
51         useRenderCache=true;
52         moderated = false;
53         usrList = null;
54     }
55     
56     public void inhale (MessageState mst) {
57         this.cb = mst.cb;
58         this.message = mst.message;
59         this.moderated = mst.moderated;
60         this.msg = mst.msg;
61         this.msgTemplate = mst.msgTemplate;
62         this.reason = mst.reason;
63         this.sender = mst.sender;
64         this.sourceGroup = mst.sourceGroup;
65         this.targetGroup = mst.targetGroup;
66         this.usercontext = mst.usercontext;
67         this.useRenderCache = mst.useRenderCache;
68         this.usrList = mst.usrList;
69     }
70     
71     public Object JavaDoc clone () {
72         MessageState mst = new MessageState(this.mp);
73         mst.cb = this.cb;
74         mst.message = this.message;
75         mst.moderated = this.moderated;
76         mst.msg = this.msg;
77         mst.msgTemplate = this.msgTemplate;
78         mst.reason = this.reason;
79         mst.sender = this.sender;
80         mst.sourceGroup = this.sourceGroup;
81         mst.targetGroup = this.targetGroup;
82         mst.usercontext = this.usercontext;
83         mst.useRenderCache = this.useRenderCache;
84         mst.usrList = this.usrList;
85         return mst;
86     }
87
88     public void finalize() {
89         if (Server.TRACE_CREATE_AND_FINALIZE)
90             Server.log(this, "----------------------------------------FINALIZED", Server.MSG_STATE, Server.LVL_VERY_VERBOSE);
91     }
92 }
93
Popular Tags