KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > common > Message


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2002 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; 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.lucane.common;
21
22 import java.io.Serializable JavaDoc;
23
24 /**
25  * A message that can go accross the network
26  */

27 public class Message implements Serializable JavaDoc
28 {
29     private ConnectInfo sender;
30     private ConnectInfo receiver;
31     private String JavaDoc application;
32     private Object JavaDoc data;
33     
34     /**
35      * Constructor
36      *
37      * @param sender the sender connect info
38      * @param receiver the receiver connect info
39      * @param application the application that should get this message
40      * @param data some parameters
41      */

42     public Message(ConnectInfo sender, ConnectInfo receiver, String JavaDoc application, Object JavaDoc data)
43     {
44         this.sender = sender;
45         this.receiver = receiver;
46         this.application = application;
47         this.data = data;
48     }
49     
50     //-- getters
51

52     /**
53      * Get the message sender
54      *
55      * @return the sender
56      */

57     public ConnectInfo getSender()
58     {
59         return sender;
60     }
61     
62     /**
63      * Get the message receiver
64      *
65      * @return the receiver
66      */

67     public ConnectInfo getReceiver()
68     {
69         return receiver;
70     }
71     
72     /**
73      * Get the application name
74      *
75      * @return the application name
76      */

77     public String JavaDoc getApplication()
78     {
79         return application;
80     }
81     
82     /**
83      * Get message data
84      *
85      * @return the data
86      */

87     public Object JavaDoc getData()
88     {
89         return data;
90     }
91     
92     /**
93      * Shows the message as a string
94      *
95      * @return a description
96      */

97     public String JavaDoc toString()
98     {
99         return "[" + sender.getName() + ">" + receiver.getName()+
100             ":" + application + ":" + data + "]";
101     }
102 }
103
Popular Tags