01: /*
02: * EBMessage.java - An EditBus message
03: * :tabSize=8:indentSize=8:noTabs=false:
04: * :folding=explicit:collapseFolds=1:
05: *
06: * Copyright (C) 1999, 2002 Slava Pestov
07: *
08: * This program is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public License
10: * as published by the Free Software Foundation; either version 2
11: * of the License, or any later version.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public License
19: * along with this program; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21: */
22:
23: package org.gjt.sp.jedit;
24:
25: /**
26: * The base class of all EditBus messages.<p>
27: *
28: * Message classes extending this class typically add
29: * other data members and methods to provide subscribers with whatever is
30: * needed to handle the message appropriately.<p>
31: *
32: * Message types sent by jEdit can be found in the
33: * {@link org.gjt.sp.jedit.msg} package.
34: *
35: * @author Slava Pestov
36: * @author John Gellene (API documentation)
37: * @version $Id: EBMessage.java 5167 2005-01-09 01:47:38Z spestov $
38: *
39: * @since jEdit 2.2pre6
40: */
41: public abstract class EBMessage {
42: //{{{ EBMessage constructor
43: /**
44: * Creates a new message.
45: * @param source The message source
46: * @since jEdit 4.2pre1
47: */
48: public EBMessage(Object source) {
49: this .source = source;
50: } //}}}
51:
52: //{{{ EBMessage constructor
53: /**
54: * Creates a new message.
55: * @param source The message source
56: */
57: public EBMessage(EBComponent source) {
58: this .source = source;
59: } //}}}
60:
61: //{{{ getSource() method
62: /**
63: * Returns the sender of this message.
64: * @since jEdit 4.2pre1
65: */
66: public Object getSource() {
67: return source;
68: } //}}}
69:
70: //{{{ toString() method
71: /**
72: * Returns a string representation of this message.
73: */
74: public String toString() {
75: String className = getClass().getName();
76: int index = className.lastIndexOf('.');
77: return className.substring(index + 1) + "[" + paramString()
78: + "]";
79: } //}}}
80:
81: //{{{ paramString() method
82: /**
83: * Returns a string representation of this message's parameters.
84: */
85: public String paramString() {
86: return "source=" + source;
87: } //}}}
88:
89: //{{{ Private members
90: private Object source;
91: //}}}
92: }
|