org.lyra.Host
Class Playlist

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

public class Playlist
extends java.lang.Object

This class deals with the interaction between the application and play lists. Actions such as: Creating; Removing; and Maintaining of play lists are here.

Since the currently queued songs are a play list as well the ability to add and remove elements from that list will be enabled through here. This class will function much as does org.lyra.Database.Comptroller does.

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

Field Summary
private static java.lang.String CLASS
           
private  Terminus Host
           
private  java.util.Map<java.lang.String,java.lang.String> Lang
           
private  Ledger Logger
           
private  Comptroller Manager
           
 
Constructor Summary
Playlist(Ledger logger, Comptroller manager, Terminus host, java.util.Map<java.lang.String,java.lang.String> lang)
          Core constructor for the class.
 
Method Summary
 void addCurrent(int pos, java.util.List<java.lang.String> songs)
          Internal method that will pass on the commands necessary to write out the structure to the host in order to add songs to the Current playlist.
 void addCurrent(int pos, java.lang.String... songs)
          Will take an array of File elements and append them directly to the Current play list.
 void addCurrent(java.util.List<java.lang.String> songs)
          Internal method that will pass on the commands necessary to write out the structure to the host in order to add songs to the Current playlist.
 void addCurrent(java.lang.String... songs)
          Will take an array of File elements and append them directly to the Current play list.
 void addCurrentAlbum(int pos, java.lang.String... albums)
          Adds an album and all associated songs into the currently playing queue.
 void addCurrentAlbum(java.util.Map<java.lang.String,java.lang.String> filter)
          Adds an album and all associated songs into the currently playing queue.
 void addCurrentAlbum(java.lang.String... albums)
          Adds an album and all associated songs into the currently playing queue.
 void addCurrentArtist(int pos, java.lang.String... artists)
          Adds an artist and all associated songs into the currently playing queue.
 void addCurrentArtist(java.util.Map<java.lang.String,java.lang.String> filter)
          Adds an artist and all associated songs into the currently playing queue.
 void addCurrentArtist(java.lang.String... artists)
          Adds an artist and all associated songs into the currently playing queue.
 void addCurrentGenre(int pos, java.lang.String... genres)
          Adds an genre and all associated songs into the currently playing queue.
 void addCurrentGenre(java.util.Map<java.lang.String,java.lang.String> filter)
          Adds an genre and all associated songs into the currently playing queue.
 void addCurrentGenre(java.lang.String... genres)
          Adds an genre and all associated songs into the currently playing queue.
 boolean clearCurrent()
          This specific method is designed to clear out all entries in the current playlist.
 boolean clearCurrent(int... pos)
          Clear entries as specified.
 boolean clearCurrent(java.lang.String... pos)
          Clear entries as specified.
 void loadLocal(java.util.List<java.lang.String> names)
          Loads the contents specified by a list of songs into the current playlist.
 boolean loadRemote(java.lang.String name)
          Loads the contents of the listed playlist into the current playlist.
 boolean moveCurrent(int pos, boolean up, java.lang.String... ids)
          Will take an initial insertion point, followed by an array of elements that are to be moved to that particular point.
 boolean removeRemote(java.lang.String name)
          Has the exact opposite effect of the saveCurrent and saveRemote methods as this will remove a playlist from the host entry.
 boolean saveCurrent(java.lang.String name)
          This is the only method in this section that will not be sharing the remote name.
 boolean saveRemote(java.lang.String name)
          This is the same method as saveCurrent with a different name to hopefully cause less confusion and maintain consistency.
 boolean shuffleCurrent()
          Shuffles the songs in the current playlist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Logger

private Ledger Logger

Manager

private Comptroller Manager

Host

private Terminus Host

Lang

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

CLASS

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

Playlist

public Playlist(Ledger logger,
                Comptroller manager,
                Terminus host,
                java.util.Map<java.lang.String,java.lang.String> lang)
Core constructor for the class. Will establish all necessary elements in order to be able to start playing with play lists and the currently playing list.

Parameters:
logger - Ledger instance for logging and debugging purposes.
manager - Comptroller instance for interacting with the database.
host - Terminus instance for direct interaction with the Host.
lang - Language elements.
Method Detail

addCurrent

public void addCurrent(java.util.List<java.lang.String> songs)
Internal method that will pass on the commands necessary to write out the structure to the host in order to add songs to the Current playlist.

Parameters:
songs - List of strings containing the File attribute.

addCurrent

public void addCurrent(int pos,
                       java.util.List<java.lang.String> songs)
Internal method that will pass on the commands necessary to write out the structure to the host in order to add songs to the Current playlist.

Parameters:
pos - Integer containing initial position for insertion.
songs - List of strings containing the File attribute.

addCurrent

public void addCurrent(java.lang.String... songs)
Will take an array of File elements and append them directly to the Current play list.

Parameters:
songs - List of strings containing the File attribute.

addCurrent

public void addCurrent(int pos,
                       java.lang.String... songs)
Will take an array of File elements and append them directly to the Current play list.

Parameters:
pos - Integer containing insertion point.
songs - List of strings containing the File attribute.

addCurrentAlbum

public void addCurrentAlbum(java.lang.String... albums)
Adds an album and all associated songs into the currently playing queue. By default this task will be done by sorting the song numbers in order to maintain original structure.

Parameters:
albums - String containing album name.

addCurrentAlbum

public void addCurrentAlbum(int pos,
                            java.lang.String... albums)
Adds an album and all associated songs into the currently playing queue. By default this task will be done by sorting the song numbers in order maintain original structure.

Parameters:
pos - Position where the songs will be added.
albums - String containing album name.

addCurrentAlbum

public void addCurrentAlbum(java.util.Map<java.lang.String,java.lang.String> filter)
Adds an album and all associated songs into the currently playing queue. By default this task will be done by sorting the song numbers in order maintain original structure.

Parameters:
filter - Map containing filtering elements.

addCurrentArtist

public void addCurrentArtist(java.lang.String... artists)
Adds an artist and all associated songs into the currently playing queue. By default this task will be done by sorting the album names and then song numbers in order maintain original structure.

Parameters:
artists - String containing artist name.

addCurrentArtist

public void addCurrentArtist(int pos,
                             java.lang.String... artists)
Adds an artist and all associated songs into the currently playing queue. By default this task will be done by sorting the album names and then song numbers in order maintain original structure.

Parameters:
pos - integer containing insertion point.
artists - String containing artist name.

addCurrentArtist

public void addCurrentArtist(java.util.Map<java.lang.String,java.lang.String> filter)
Adds an artist and all associated songs into the currently playing queue. By default this task will be done by sorting the album names and then song numbers in order maintain original structure.

Parameters:
filter - Map containing filtering elements.

addCurrentGenre

public void addCurrentGenre(java.lang.String... genres)
Adds an genre and all associated songs into the currently playing queue. By default this task will be done by sorting the album names and then song numbers in order maintain original structure.

Parameters:
genres - String containing genre name.

addCurrentGenre

public void addCurrentGenre(int pos,
                            java.lang.String... genres)
Adds an genre and all associated songs into the currently playing queue. By default this task will be done by sorting the album names and then song numbers in order maintain original structure.

Parameters:
pos - Integer containing insertion point.
genres - String containing genre name.

addCurrentGenre

public void addCurrentGenre(java.util.Map<java.lang.String,java.lang.String> filter)
Adds an genre and all associated songs into the currently playing queue. By default this task will be done by sorting the album names and then song numbers in order maintain original structure.

Parameters:
filter - Map containing filtering elements.

clearCurrent

public boolean clearCurrent()
This specific method is designed to clear out all entries in the current playlist. This corresponds to a built-in command which requires no knowledge of what is in the list.

Returns:
boolean Results of command.

clearCurrent

public boolean clearCurrent(int... pos)
Clear entries as specified. These are related to their positions in the list itself.

Parameters:
pos - Array of integers indicating which elements.
Returns:
boolean Results of command.

clearCurrent

public boolean clearCurrent(java.lang.String... pos)
Clear entries as specified. These are related to their positions in the list itself.

Parameters:
pos - Array of string indicating which elements.
Returns:
boolean Results of command.

moveCurrent

public boolean moveCurrent(int pos,
                           boolean up,
                           java.lang.String... ids)
Will take an initial insertion point, followed by an array of elements that are to be moved to that particular point.

Parameters:
pos - Integer indicating insertion point.
up - Boolean telling us if we are moving up the tree (incrementing in positions).
ids - String array indicating songs to move.
Returns:
boolean Results of command.

shuffleCurrent

public boolean shuffleCurrent()
Shuffles the songs in the current playlist. This is tied directly to a protocol command.

Returns:
boolean Results of command.

saveCurrent

public boolean saveCurrent(java.lang.String name)
This is the only method in this section that will not be sharing the remote name. Essentially it is used to save the current playlist as a remote list, hence the name.

Parameters:
name - String containing playlist name.
Returns:
boolean indicating success.

saveRemote

public boolean saveRemote(java.lang.String name)
This is the same method as saveCurrent with a different name to hopefully cause less confusion and maintain consistency.

Parameters:
name - String containing playlist name.
Returns:
boolean indicating success.

removeRemote

public boolean removeRemote(java.lang.String name)
Has the exact opposite effect of the saveCurrent and saveRemote methods as this will remove a playlist from the host entry.

Parameters:
name - String containing playlist name.
Returns:
boolean indicating success.

loadRemote

public boolean loadRemote(java.lang.String name)
Loads the contents of the listed playlist into the current playlist.

Parameters:
name - String containing playlist name.
Returns:
boolean indicating success.

loadLocal

public void loadLocal(java.util.List<java.lang.String> names)
Loads the contents specified by a list of songs into the current playlist. This method is part of this class due to the fact that this list would normally originate from a locally stored list.

Parameters:
names - List of file names to be added.