org.bff.javampd.monitor
Class MPDEventMonitor

java.lang.Object
  extended by org.bff.javampd.monitor.MPDEventMonitor
Direct Known Subclasses:
MPDEventRelayer, MPDStandAloneMonitor

public abstract class MPDEventMonitor
extends java.lang.Object

MPDEventMonitor is the abstract base class for all event monitors.


Constructor Summary
MPDEventMonitor(MPD mpd)
          Only contructor for this abstract base class.
 
Method Summary
 void addConnectionChangeListener(ConnectionChangeListener ccl)
          Adds a ConnectionChangeListener to this object to receive ConnectionChangeEvents.
 void addTrackPositionChangeListener(TrackPositionChangeListener tpcl)
          Adds a TrackPositionChangeListener to this object to receive TrackPositionChangeEvents.
protected  void checkConnection()
          Checks the connection status of the MPD.
protected  void checkTrackPosition(long newPos)
          Checks the track position and fires a TrackPositionChangeEvent if there has been a change in track position.
protected  void fireConnectionChangeEvent(boolean isConnected, java.lang.String msg)
          Sends the appropriate ConnectionChangeEvent to all registered ConnectionChangeListeners.
protected  void fireTrackPositionChangeEvent(long newTime)
          Sends the appropriate TrackPositionChangeEvent to all registered TrackPositionChangeListeners.
 void removeConnectionChangeListener(ConnectionChangeListener ccl)
          Removes a ConnectionChangeListener from this object.
 void removeTrackPositionChangeListener(TrackPositionChangeListener tpcl)
          Removes a TrackPositionChangeListener from this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MPDEventMonitor

public MPDEventMonitor(MPD mpd)
Only contructor for this abstract base class.

Parameters:
mpd - a connection to a MPD
Method Detail

addTrackPositionChangeListener

public void addTrackPositionChangeListener(TrackPositionChangeListener tpcl)
Adds a TrackPositionChangeListener to this object to receive TrackPositionChangeEvents.

Parameters:
tpcl - the TrackPositionChangeListener to add

removeTrackPositionChangeListener

public void removeTrackPositionChangeListener(TrackPositionChangeListener tpcl)
Removes a TrackPositionChangeListener from this object.

Parameters:
tpcl - the TrackPositionChangeListener to remove

fireTrackPositionChangeEvent

protected void fireTrackPositionChangeEvent(long newTime)
Sends the appropriate TrackPositionChangeEvent to all registered TrackPositionChangeListeners.

Parameters:
newTime - the new elapsed time

addConnectionChangeListener

public void addConnectionChangeListener(ConnectionChangeListener ccl)
Adds a ConnectionChangeListener to this object to receive ConnectionChangeEvents.

Parameters:
ccl - the ConnectionChangeListerner to add

removeConnectionChangeListener

public void removeConnectionChangeListener(ConnectionChangeListener ccl)
Removes a ConnectionChangeListener from this object.

Parameters:
ccl - the ConnectionChangeListener to remove

fireConnectionChangeEvent

protected void fireConnectionChangeEvent(boolean isConnected,
                                         java.lang.String msg)
Sends the appropriate ConnectionChangeEvent to all registered ConnectionChangeListeners.

Parameters:
isConnected - the connection status

checkConnection

protected final void checkConnection()
Checks the connection status of the MPD. Fires a ConnectionChangeEvent if the connection status changes.


checkTrackPosition

protected final void checkTrackPosition(long newPos)
Checks the track position and fires a TrackPositionChangeEvent if there has been a change in track position.

Parameters:
newPos - the new elapsed time to check