You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MethodEventSource.java 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.event;
  17. import java.io.Serializable;
  18. import java.lang.reflect.Method;
  19. import com.vaadin.shared.Registration;
  20. /**
  21. * <p>
  22. * Interface for classes supporting registration of methods as event receivers.
  23. * </p>
  24. *
  25. * <p>
  26. * For more information on the inheritable event mechanism see the
  27. * {@link com.vaadin.event com.vaadin.event package documentation}.
  28. * </p>
  29. *
  30. * @author Vaadin Ltd.
  31. * @since 3.0
  32. */
  33. public interface MethodEventSource extends Serializable {
  34. /**
  35. * <p>
  36. * Registers a new event listener with the specified activation method to
  37. * listen events generated by this component. If the activation method does
  38. * not have any arguments the event object will not be passed to it when
  39. * it's called.
  40. * </p>
  41. *
  42. * <p>
  43. * For more information on the inheritable event mechanism see the
  44. * {@link com.vaadin.event com.vaadin.event package documentation}.
  45. * </p>
  46. *
  47. * @param eventType
  48. * the type of the listened event. Events of this type or its
  49. * subclasses activate the listener.
  50. * @param object
  51. * the object instance who owns the activation method.
  52. * @param method
  53. * the activation method.
  54. * @return a registration object for removing the listener
  55. * @throws java.lang.IllegalArgumentException
  56. * unless <code>method</code> has exactly one match in
  57. * <code>object</code>
  58. * @throws NullPointerException
  59. * if {@code object} is {@code null}
  60. */
  61. public Registration addListener(Class<?> eventType, Object object,
  62. Method method);
  63. /**
  64. * <p>
  65. * Registers a new listener with the specified activation method to listen
  66. * events generated by this component. If the activation method does not
  67. * have any arguments the event object will not be passed to it when it's
  68. * called.
  69. * </p>
  70. *
  71. * <p>
  72. * This version of <code>addListener</code> gets the name of the activation
  73. * method as a parameter. The actual method is reflected from
  74. * <code>object</code>, and unless exactly one match is found,
  75. * <code>java.lang.IllegalArgumentException</code> is thrown.
  76. * </p>
  77. *
  78. * <p>
  79. * For more information on the inheritable event mechanism see the
  80. * {@link com.vaadin.event com.vaadin.event package documentation}.
  81. * </p>
  82. *
  83. * @param eventType
  84. * the type of the listened event. Events of this type or its
  85. * subclasses activate the listener.
  86. * @param object
  87. * the object instance who owns the activation method.
  88. * @param methodName
  89. * the name of the activation method.
  90. * @return a registration object for removing the listener
  91. * @throws java.lang.IllegalArgumentException
  92. * unless <code>method</code> has exactly one match in
  93. * <code>object</code>
  94. * @throws NullPointerException
  95. * if {@code object} is {@code null}
  96. */
  97. public Registration addListener(Class<?> eventType, Object object,
  98. String methodName);
  99. /**
  100. * Removes all registered listeners matching the given parameters. Since
  101. * this method receives the event type and the listener object as
  102. * parameters, it will unregister all <code>object</code>'s methods that are
  103. * registered to listen to events of type <code>eventType</code> generated
  104. * by this component.
  105. *
  106. * <p>
  107. * For more information on the inheritable event mechanism see the
  108. * {@link com.vaadin.event com.vaadin.event package documentation}.
  109. * </p>
  110. *
  111. * @param eventType
  112. * the exact event type the <code>object</code> listens to.
  113. * @param target
  114. * the target object that has registered to listen to events of
  115. * type <code>eventType</code> with one or more methods.
  116. */
  117. public void removeListener(Class<?> eventType, Object target);
  118. /**
  119. * Removes one registered listener method. The given method owned by the
  120. * given object will no longer be called when the specified events are
  121. * generated by this component.
  122. *
  123. * <p>
  124. * For more information on the inheritable event mechanism see the
  125. * {@link com.vaadin.event com.vaadin.event package documentation}.
  126. * </p>
  127. *
  128. * @param eventType
  129. * the exact event type the <code>object</code> listens to.
  130. * @param target
  131. * the target object that has registered to listen to events of
  132. * type eventType with one or more methods.
  133. * @param method
  134. * the method owned by the target that's registered to listen to
  135. * events of type eventType.
  136. * @deprecated use a {@link Registration} returned by
  137. * {@link #addListener(Class, Object, Method)}
  138. */
  139. @Deprecated
  140. public void removeListener(Class<?> eventType, Object target,
  141. Method method);
  142. /**
  143. * <p>
  144. * Removes one registered listener method. The given method owned by the
  145. * given object will no longer be called when the specified events are
  146. * generated by this component.
  147. * </p>
  148. *
  149. * <p>
  150. * This version of <code>removeListener</code> gets the name of the
  151. * activation method as a parameter. The actual method is reflected from the
  152. * target, and unless exactly one match is found,
  153. * <code>java.lang.IllegalArgumentException</code> is thrown.
  154. * </p>
  155. *
  156. * <p>
  157. * For more information on the inheritable event mechanism see the
  158. * {@link com.vaadin.event com.vaadin.event package documentation}.
  159. * </p>
  160. *
  161. * @param eventType
  162. * the exact event type the <code>object</code> listens to.
  163. * @param target
  164. * the target object that has registered to listen to events of
  165. * type <code>eventType</code> with one or more methods.
  166. * @param methodName
  167. * the name of the method owned by <code>target</code> that's
  168. * registered to listen to events of type <code>eventType</code>.
  169. * @deprecated use a {@link Registration} returned by
  170. * {@link #addListener(Class, Object, String)}
  171. */
  172. @Deprecated
  173. public void removeListener(Class<?> eventType, Object target,
  174. String methodName);
  175. }