Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.togethersoft.openapi.util
Class EventMulticaster

public class EventMulticaster

Suited to work with an array of event listeners.

Author:
  TogetherSoft
See Also: EventDispatch, VetoableDispatch

Method Summary
`final void` | `add(EventListener listener)` Adds listener to listers array.
`final static EventMulticaster` | `add(EventMulticaster caster, EventListener listener)` Adds a listener to specified `EventMulticaster`.
`final void` | `dispatch(EventDispatch e)` For every listener in array calls method `dispatch` of specified event.
`final static void` | `dispatch(EventMulticaster caster, EventDispatch e)` Calls `dispatch` method of dispatchable event for every event listener from event multicaster.
`int` | `find(EventListener listener)` Searches for specified listener.
`final boolean` | `hasListeners()` Checks is there more listeners
`final void` | `remove(EventListener listener)` Removes listener from listers array.
`final static EventMulticaster` | `remove(EventMulticaster caster, EventListener listener)` Removes a listener from specified `EventMulticaster`.
`final boolean` | `vetoableDispatch(VetoableDispatch e)` For every listener in array calls method `vetoableDispatch` of specified event.
`final static boolean` | `vetoableDispatch(EventMulticaster caster, VetoableDispatch e)` Calls `vetoableDispatch` method of dispatchable event for every event listener from event multicaster.

Method Detail

### add

    public final void add(EventListener listener)

  Adds listener to listers array. This method is thread safe.

### add

    public final static EventMulticaster add(EventMulticaster caster, EventListener listener)

  Adds a listener to specified `EventMulticaster`.
  Parameters:
    caster - EventMulticaster where listener will be added.
    listener - Event listener will be added.

### dispatch

    public final void dispatch(EventDispatch e)

  For every listener in array calls method `dispatch` of specified event. This method executes corresponding methods of listeners.
  Parameters:
    e - Dispatchable event which method `dispatch` are executed.

### dispatch

    public final static void dispatch(EventMulticaster caster, EventDispatch e)

  Calls `dispatch` method of dispatchable event for every event listener from event multicaster. If there is no listeners in multicaster : does nothing.
  Parameters:
    caster - EventMulticaster that containes listeners.
    e - Dispatchable event which method `dispatch` is executed.

### find

    public int find(EventListener listener)

  Searches for specified listener.
  Parameters:
    listener - Listener to be found.
  Returns: `int` index of listener, or `-1` if not found.

### hasListeners

    public final boolean hasListeners()

  Checks is there more listeners
  Returns: `true` if there is, `false` otherwise.

### remove

    public final void remove(EventListener listener)

  Removes listener from listers array. This method is thread safe.

### remove

    public final static EventMulticaster remove(EventMulticaster caster, EventListener listener)

  Removes a listener from specified `EventMulticaster`.
  Parameters:
    caster - EventMulticaster where listener will be removed from.
    listener - Event listener will be removed.

### vetoableDispatch

    public final boolean vetoableDispatch(VetoableDispatch e)

  For every listener in array calls method `vetoableDispatch` of specified event. This method executes corresponding methods of listeners.
  Parameters:
    e - Vetoable event which method `vetoableDispatch` are executed.
  Returns: `true` if all methods are executed or there is no listeners; `false` if `VetoException` cought.
  See Also:
    VetoException, VetoableDispatch

### vetoableDispatch

    public final static boolean vetoableDispatch(EventMulticaster caster, VetoableDispatch e)

  Calls `vetoableDispatch` method of dispatchable event for every event listener from event multicaster. If there is no listeners in multicaster returns `true`.
  Parameters:
    caster - EventMulticaster that containes listeners.
    e Vetoable - and dispatchable event which method `vetoableDispatch` is executed.
  Returns: `true` if `vetoableDispatch` is executed or there is no listeners in multicaster; `false` if `VetoException` is cought.

Association Links

to Class java.util.EventListener

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD