01: /*
02: * Lucane - a collaborative platform
03: * Copyright (C) 2002 Vincent Fiack <vfiack@mail15.com>
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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;
23:
24: /**
25: * A message that can go accross the network
26: */
27: public class Message implements Serializable {
28: private ConnectInfo sender;
29: private ConnectInfo receiver;
30: private String application;
31: private Object data;
32:
33: /**
34: * Constructor
35: *
36: * @param sender the sender connect info
37: * @param receiver the receiver connect info
38: * @param application the application that should get this message
39: * @param data some parameters
40: */
41: public Message(ConnectInfo sender, ConnectInfo receiver,
42: String application, Object data) {
43: this .sender = sender;
44: this .receiver = receiver;
45: this .application = application;
46: this .data = data;
47: }
48:
49: //-- getters
50:
51: /**
52: * Get the message sender
53: *
54: * @return the sender
55: */
56: public ConnectInfo getSender() {
57: return sender;
58: }
59:
60: /**
61: * Get the message receiver
62: *
63: * @return the receiver
64: */
65: public ConnectInfo getReceiver() {
66: return receiver;
67: }
68:
69: /**
70: * Get the application name
71: *
72: * @return the application name
73: */
74: public String getApplication() {
75: return application;
76: }
77:
78: /**
79: * Get message data
80: *
81: * @return the data
82: */
83: public Object getData() {
84: return data;
85: }
86:
87: /**
88: * Shows the message as a string
89: *
90: * @return a description
91: */
92: public String toString() {
93: return "[" + sender.getName() + ">" + receiver.getName() + ":"
94: + application + ":" + data + "]";
95: }
96: }
|