View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.chat;
21  
22  import java.util.EventObject;
23  
24  import org.xnap.peer.Peer;
25  
26  /***
27   * An event that characterizes a change in a {@link Channel} object.
28   */
29  public class ChannelEvent extends EventObject { 
30  
31      //--- Constant(s) ---
32  
33      public static final int MESSAGE_RECEIVED = 1;
34      public static final int PEER_ADDED = 2;
35      public static final int PEER_REMOVED = 3;
36      public static final int TOPIC_CHANGED = 4;
37      public static final int PEER_CHANGED = 5;
38      public static final int CHANNEL_JOINED = 6;
39      public static final int CHANNEL_PARTED = 7;
40  
41      public static final int MESSAGE_TYPE_MESSAGE = 1;
42      public static final int MESSAGE_TYPE_INFO = 2;
43      public static final int MESSAGE_TYPE_ERROR = 3;
44      public static final int MESSAGE_TYPE_ACTION_MESSAGE = 4;
45  
46      //--- Data Field(s) ---
47      
48      private int id;
49      private String message;
50      private int messageType;
51      private Peer peer;
52      private String topic;
53  
54      //--- Constructor(s) ---
55  
56      public ChannelEvent(Object source, Peer peer, String message, 
57  						int messageType)
58      {	
59  		super(source);
60      
61  		this.id = MESSAGE_RECEIVED;
62  		this.peer = peer;
63  		this.message = message;
64  		this.messageType = messageType;
65      }
66  
67      public ChannelEvent(Object source, int id, Peer peer)
68      {
69  		super(source);
70  
71  		this.id = id;
72  		this.peer = peer;
73      }
74  
75      public ChannelEvent(Object source, String topic)
76      {
77  		super(source);
78  
79  		this.id = TOPIC_CHANGED;
80  		this.topic = topic;
81      }
82  
83      public ChannelEvent(Object source, int id)
84      {
85  		super(source);
86  	
87  		this.id = id;
88      }
89  
90      //--- Method(s) ---
91  
92      public int getID()
93      {
94  		return id;
95      }
96  
97      public String getMessage()
98      {
99  		return message;
100     }
101 
102     public int getMessageType()
103     {
104 		return messageType;
105     }
106 
107     public Peer getPeer()
108     {
109 		return peer;
110     }
111 
112     public String getTopic()
113     {
114 		return topic;
115     }
116 
117 }