org.lyra.Host
Class Status

java.lang.Object
  extended by org.lyra.Host.Status

public class Status
extends java.lang.Object

Deals with the basic status handling of the Music Player Daemon protocol and its interaction with the rest of the system.

Version:
1.0.5, %Revision, 174%, %LastChangedDate, 27/10/12 3:33PM%
Author:
Martin Foster

Field Summary
private static java.lang.String CLASS
           
private  java.util.List<java.util.Map<java.lang.String,java.lang.String>> Current
           
private  java.util.List<java.lang.String> Disabled
           
private  java.util.List<java.lang.String> Enabled
           
private  Terminus Host
           
private  Ledger Logger
           
private  java.util.List<java.lang.String> Playlist
           
private  java.util.Map<java.lang.String,java.lang.String> State
           
private  java.util.Map<java.lang.String,java.lang.String> Stats
           
 
Constructor Summary
Status(Ledger logger, Terminus host)
          Primary constructor for this class.
 
Method Summary
static boolean fetchState(int state)
          Returns the state of an element by first taking the numeric value and providing the user with a proper boolean.
static boolean fetchState(java.lang.String state)
          Returns the state of an element by first taking the string value and providing the user with a proper boolean.
 java.util.List<java.util.Map<java.lang.String,java.lang.String>> getCurrent()
          Returns the generated playlist from the Music Player Daemon host typically used for synchronisation of database elements.
 java.util.List<java.lang.String> getDisabled()
          Get a listing of all disabled commands.
 java.util.Set<java.lang.String> getDisabledAsSet()
          Get a listing of all disabled commands.
 java.util.List<java.lang.String> getEnabled()
          List containing all commands available for use.
 java.util.Set<java.lang.String> getEnabledAsSet()
          List containing all commands available for use.
 java.util.List<java.lang.String> getPlaylist()
          Returns a list of all stored playlists in the host.
 java.util.Map<java.lang.String,java.lang.String> getState()
          Returns the state element that has been generated by this class.
 java.util.Map<java.lang.String,java.lang.String> getStatistics()
          Returns the statistics element that has been generated by this class.
protected  void updateByEvent(UpdateEvent update)
          An update variant that will extract information as necessary based on an event that has been generated.
protected  void updateCurrent()
          Playlist contain a lot of information that can be retained.
protected  void updateDisabled()
          Accesses the Music Player Daemon and gets a list of all commands which are not enabled for use on the host.
protected  void updateEnabled()
          Accesses the Music Player Daemon and gets a list of all commands which are enabled for use on the host.
 void updateHost(Terminus host)
          This provides the ability to change the Terminus connection which has been initially setup.
protected  void updatePlaylist()
          Provides an update mechanism for stored playlists on the hosts enabling a user to get select them for playback and so forth.
protected  void updateState()
          Sends the appropriate command and parses the return value in order to extract status information from the Music Player Daemon.
protected  void updateStatistics()
          Statistics can provide a great deal of information about the Music Player Daemon and provide a stating point to discover if the database needs updating or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

State

private java.util.Map<java.lang.String,java.lang.String> State

Stats

private java.util.Map<java.lang.String,java.lang.String> Stats

Current

private java.util.List<java.util.Map<java.lang.String,java.lang.String>> Current

Playlist

private java.util.List<java.lang.String> Playlist

Enabled

private java.util.List<java.lang.String> Enabled

Disabled

private java.util.List<java.lang.String> Disabled

Logger

private Ledger Logger

Host

private Terminus Host

CLASS

private static final java.lang.String CLASS
See Also:
Constant Field Values
Constructor Detail

Status

public Status(Ledger logger,
              Terminus host)
Primary constructor for this class. Primarily responsible for passing up the base Classes for management and generating the initial maps.

Parameters:
logger - Ledger instance for logging and debugging purposes.
host - Terminus instance for direct interaction with the Host.
Method Detail

updateHost

public void updateHost(Terminus host)
This provides the ability to change the Terminus connection which has been initially setup. This permits other elements to maintain their connection to the Status class without a change.

Parameters:
host - Terminus instance for direct interaction with the Host.

updateByEvent

protected void updateByEvent(UpdateEvent update)
An update variant that will extract information as necessary based on an event that has been generated. This permits a greater locking capability forcing all newly update information to have the same state.

Parameters:
update - UpdateEvent instance carrying all information on what to update.

updateState

protected void updateState()
Sends the appropriate command and parses the return value in order to extract status information from the Music Player Daemon.


getState

public java.util.Map<java.lang.String,java.lang.String> getState()
Returns the state element that has been generated by this class. Used to generate the UI components and establish state. The information that may be returned is as follows:

This information changes with player state and version. So it becomes necessary to check for the existence of tags prior to using them.

Returns:
Map containing state information.

updateStatistics

protected void updateStatistics()
Statistics can provide a great deal of information about the Music Player Daemon and provide a stating point to discover if the database needs updating or not.


getStatistics

public java.util.Map<java.lang.String,java.lang.String> getStatistics()
Returns the statistics element that has been generated by this class. Used primarily to maintain sync with the database element.

Returns:
Map containing statistical information of the host.

updateEnabled

protected void updateEnabled()
Accesses the Music Player Daemon and gets a list of all commands which are enabled for use on the host. This can be used to determine if certain functionality can be offered.


getEnabled

public java.util.List<java.lang.String> getEnabled()
List containing all commands available for use. Where an absence would indicate invalid command or one that is not supported by a certain version of the Music Player Daemon.

Returns:
List containing enabled commands.

getEnabledAsSet

public java.util.Set<java.lang.String> getEnabledAsSet()
List containing all commands available for use. Where an absence would indicate invalid command or one that is not supported by a certain version of the Music Player Daemon.

Returns:
List containing enabled commands.

updateDisabled

protected void updateDisabled()
Accesses the Music Player Daemon and gets a list of all commands which are not enabled for use on the host. This can be used to determine if certain functionality can be offered.


getDisabled

public java.util.List<java.lang.String> getDisabled()
Get a listing of all disabled commands. This method is not the preferred way of working with restrictions, better overall to make use of getEnabled in order to determine commands that may not be supported in specific versions.

Returns:
List containing disabled commands.

getDisabledAsSet

public java.util.Set<java.lang.String> getDisabledAsSet()
Get a listing of all disabled commands. This method is not the preferred way of working with restrictions, better overall to make use of getEnabled in order to determine commands that may not be supported in specific versions.

Returns:
List containing disabled commands.

updateCurrent

protected void updateCurrent()
Playlist contain a lot of information that can be retained. However while it is not always necessary to carry all of it we do so for code simplicity.


getCurrent

public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getCurrent()
Returns the generated playlist from the Music Player Daemon host typically used for synchronisation of database elements.

Returns:
List of Map elements.

updatePlaylist

protected void updatePlaylist()
Provides an update mechanism for stored playlists on the hosts enabling a user to get select them for playback and so forth.


getPlaylist

public java.util.List<java.lang.String> getPlaylist()
Returns a list of all stored playlists in the host.

Returns:
List containing named items.

fetchState

public static boolean fetchState(java.lang.String state)
Returns the state of an element by first taking the string value and providing the user with a proper boolean. Due to the protocol of the Music Player Daemon these strings represent a 1 or 0.

Parameters:
state - String indicating state of an element.
Returns:
Boolean indicating state of an element.

fetchState

public static boolean fetchState(int state)
Returns the state of an element by first taking the numeric value and providing the user with a proper boolean.

Parameters:
state - Integer indicating state of an element.
Returns:
Boolean indicating state of an element.