public class

EventSource

extends Object
implements IEventSource
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.events.EventSource
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Standard implementation for an event source.

Summary

Fields
public static final AtomicInteger onEventCallCount
Public Constructors
EventSource()
Create an event source not attached to a parent source.
EventSource(EventSource parentSource)
Create an event source attached to an optional parent source.
Public Methods
void addListener(IEventListener listener)
Register a listener.
int countListeners()
Get the numbers of objects listening to this event source.
List<IEventListener> getListeners()
Get a copy of the list of listeners.
IEventSource getParentSource()
Get the parent source.
void insertListener(int index, IEventListener listener)
Register a listener.
void notifyListeners(Event e)
void notifyListeners(IEvent e)
Notify listeners that an event has occurred.
void notifyListeners(Event e, boolean notifyParent)
static IEventListener relay(IEventSource origin, IEventSource proxy)
Relay events issued from an origin to the listeners of a proxy.
void removeListener(IEventListener listener)
Unregister a listener.
void setParentSource(IEventSource parentSource)
Set a parent source.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.util.events.IEventSource

Fields

public static final AtomicInteger onEventCallCount

Public Constructors

public EventSource ()

Create an event source not attached to a parent source.

public EventSource (EventSource parentSource)

Create an event source attached to an optional parent source. If present, events generated by this source will be propagated to its listeners as well as the parent source's listeners.

Parameters
parentSource optional parent source

Public Methods

public void addListener (IEventListener listener)

Register a listener. The listener is appended to the existing list of listeners. The implementor may allow duplicates.

Parameters
listener a listener of events generated by this source

public int countListeners ()

Get the numbers of objects listening to this event source.

Returns
  • the number of listeners

public List<IEventListener> getListeners ()

Get a copy of the list of listeners.

public IEventSource getParentSource ()

Get the parent source.

Returns
  • the parent source, or null if none

public void insertListener (int index, IEventListener listener)

Register a listener. The implementor may allow duplicates.

Parameters
index insertion point
listener a listener of events generated by this source

public void notifyListeners (Event e)

public void notifyListeners (IEvent e)

Notify listeners that an event has occurred.

Parameters
e the event to be propagated

public void notifyListeners (Event e, boolean notifyParent)

public static IEventListener relay (IEventSource origin, IEventSource proxy)

Relay events issued from an origin to the listeners of a proxy.

Parameters
origin events are emitted by this origin event source
proxy events will be relayed by this proxy event source
Returns
  • the event listener/relayer object, which should be disposed by the caller after the origin is destroyed

public void removeListener (IEventListener listener)

Unregister a listener. If the implementor allows duplicates in addListener(), it should deal with those consistently.

Parameters
listener the listener to be removed

public void setParentSource (IEventSource parentSource)

Set a parent source.

Parameters
parentSource the optional parent source