AbstractObservable

public abstract class AbstractObservable implements Observable

Provides functionality common to all Observables.

Author:Kyle M. Douglass

Fields

LOGGER

protected static final Logger LOGGER

changed

protected boolean changed

A flag indicating whether the state of this object has changed. This flag is used only when notifying listeners of a state change.

listeners

protected ArrayList<Listener> listeners

The list of listeners that are tracking this object.

Methods

addListener

public void addListener(Listener listener)

Adds a new listener to the list of subscribed listeners.

deleteListener

public void deleteListener(Listener listener)

Deletes a listener from the list of subscribed listeners.

notifyListeners

public void notifyListeners()

Notifies all subscribed listeners to a change in the Observable’s state. This method should only be called if setChanged() has been called.

notifyListeners

public void notifyListeners(Object data)

Notifies all subscribed listeners of a state change and pushes the data.

Parameters:
  • data – The data object to push to the listeners.

setChanged

public void setChanged()

Indicates that the state of this Observable has been changed.