/jEdit/tags/jedit-4-2-pre3/org/gjt/sp/jedit/EBMessage.java

# · Java · 137 lines · 46 code · 11 blank · 80 comment · 0 complexity · 07a7a9a18b49effd3f9060fe587cbb3b MD5 · raw file

  1. /*
  2. * EBMessage.java - An EditBus message
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 1999, 2002 Slava Pestov
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * 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. package org.gjt.sp.jedit;
  23. /**
  24. * The base class of all EditBus messages.<p>
  25. *
  26. * Message classes extending this class typically add
  27. * other data members and methods to provide subscribers with whatever is
  28. * needed to handle the message appropriately.<p>
  29. *
  30. * Message types sent by jEdit can be found in the
  31. * {@link org.gjt.sp.jedit.msg} package.
  32. *
  33. * @author Slava Pestov
  34. * @author John Gellene (API documentation)
  35. * @version $Id: EBMessage.java 4678 2003-05-02 21:12:44Z spestov $
  36. *
  37. * @since jEdit 2.2pre6
  38. */
  39. public abstract class EBMessage
  40. {
  41. //{{{ EBMessage constructor
  42. /**
  43. * Creates a new message.
  44. * @param source The message source
  45. * @since jEdit 4.2pre1
  46. */
  47. public EBMessage(Object source)
  48. {
  49. this.source = source;
  50. } //}}}
  51. //{{{ EBMessage constructor
  52. /**
  53. * Creates a new message.
  54. * @param source The message source
  55. */
  56. public EBMessage(EBComponent source)
  57. {
  58. this.source = source;
  59. } //}}}
  60. //{{{ getSource() method
  61. /**
  62. * Returns the sender of this message.
  63. * @since jEdit 4.2pre1
  64. */
  65. public Object getSource()
  66. {
  67. return source;
  68. } //}}}
  69. //{{{ toString() method
  70. /**
  71. * Returns a string representation of this message.
  72. */
  73. public String toString()
  74. {
  75. String className = getClass().getName();
  76. int index = className.lastIndexOf('.');
  77. return className.substring(index + 1)
  78. + "[" + paramString() + "]";
  79. } //}}}
  80. //{{{ paramString() method
  81. /**
  82. * Returns a string representation of this message's parameters.
  83. */
  84. public String paramString()
  85. {
  86. return "source=" + source;
  87. } //}}}
  88. //{{{ Private members
  89. private Object source;
  90. //}}}
  91. //{{{ Deprecated methods
  92. /**
  93. * @deprecated Does nothing.
  94. */
  95. public void veto()
  96. {
  97. }
  98. /**
  99. * @deprecated Returns false.
  100. */
  101. public boolean isVetoed()
  102. {
  103. return false;
  104. }
  105. /**
  106. * @deprecated Subclass <code>EBMessage</code> instead.
  107. */
  108. public static abstract class NonVetoable extends EBMessage
  109. {
  110. /**
  111. * Creates a new non-vetoable message.
  112. * @param source The message source
  113. */
  114. public NonVetoable(EBComponent source)
  115. {
  116. super(source);
  117. }
  118. /**
  119. * Disallows this message from being vetoed.
  120. */
  121. public void veto()
  122. {
  123. throw new InternalError("Can't veto this message");
  124. }
  125. } //}}}
  126. }