org.bff.javampd
Class MPDDatabase

java.lang.Object
  extended by org.bff.javampd.MPDDatabase

public class MPDDatabase
extends java.lang.Object

MPDDatabase represents a database controller to a MPD server. To obtain an instance of the class you must use the getMPDDatabase method from the MPD connection class. This class does not have a public constructor (singleton model) so the object must be obtained from the connection object.


Method Summary
 java.util.Collection<MPDSong> findAlbum(java.lang.String album)
          Returns a Collection of MPDSongs for an artist.
 java.util.Collection<MPDSong> findAlbumByArtist(java.lang.String artist, java.lang.String album)
          Returns a Collection of MPDSongs for an album by a particulat artist.
 java.util.Collection<MPDSong> findArtist(java.lang.String artist)
          Returns a Collection of MPDSongs for an artist.
 java.util.Collection<MPDSong> findTitle(java.lang.String title)
          Returns a Collection of MPDSongs for a title.
 int getAlbumCount()
          Returns the total number of albums in the database.
 int getArtistCount()
          Returns the total number of artists in the database.
 long getDbPlayTime()
          Returns the sum of all song times in database.
 long getLastUpdateTime()
          Returns the last database update in UNIX time.
 MPD getMpd()
          Returns the mpd this database class is using.
 int getSongCount()
          Returns the total number of songs in the database.
 java.util.Collection<java.lang.String> listAlbumsByArtist(java.lang.String artist)
          Returns a Collection of Strings of all albums by a particular artist.
 java.util.Collection<java.lang.String> listAllAlbums()
          Returns a Collection of Strings of all albums in the database.
 java.util.Collection<java.lang.String> listAllArtists()
          Returns a Collection of Strings of all artists in the database.
 java.util.Collection<java.lang.String> listAllFiles()
          Returns a Collection of Strings of all songs and directories from the mpd root.
 java.util.Collection<java.lang.String> listAllFiles(java.lang.String path)
          Returns a Collection of Strings of all songs and directories from the given path.
 java.util.Collection<java.lang.String> listAllGenres()
          Returns a Collection of Strings of all genres in the database.
 java.util.Collection<java.lang.String> listAllSongFiles()
          Returns a Collection of Strings of all songs from the mpd root.
 java.util.Collection<java.lang.String> listAllSongFiles(java.lang.String path)
          Returns a Collection of Strings of all songs from the given path.
 java.util.Collection<MPDSong> listAllSongs()
          Returns a Collection of MPDSongs of all songs from the mpd root.
 java.util.Collection<MPDSong> listAllSongs(java.lang.String path)
          Returns a Collection of MPDSongs of all songs from the given path.
 java.util.Collection<java.lang.String> listPlaylists()
          Returns a list of all available playlist names on the server.
 java.util.Collection<MPDSong> listPlaylistSongs(java.lang.String playlistName)
           
 java.util.Collection<MPDSong> searchAlbum(java.lang.String album)
          Returns a Collection of MPDSongs for an any album containing the parameter album.
 java.util.Collection<MPDSong> searchArtist(java.lang.String artist)
          Returns a Collection of MPDSongs for an any artist containing the parameter artist.
 java.util.Collection<MPDSong> searchFileName(java.lang.String fileName)
          Returns a Collection of MPDSongs for an any file name containing the parameter filename.
 java.util.Collection<MPDSong> searchTitle(java.lang.String title)
          Returns a Collection of MPDSongs for an any title containing the parameter title.
 void setMpd(MPD mpd)
          Set the mpd connection this class is using.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findArtist

public java.util.Collection<MPDSong> findArtist(java.lang.String artist)
                                         throws MPDConnectionException,
                                                MPDDatabaseException
Returns a Collection of MPDSongs for an artist. Please note this only returns an exact match of artist. To find a partial match use searchArtist(String artist).

Parameters:
artist - the artist to find
Returns:
a Collection of MPDSongs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

findAlbum

public java.util.Collection<MPDSong> findAlbum(java.lang.String album)
                                        throws MPDConnectionException,
                                               MPDDatabaseException
Returns a Collection of MPDSongs for an artist. Please note this only returns an exact match of album. To find a partial match use searchAlbum(String artist).

Parameters:
album - the album to find
Returns:
a Collection of MPDSongs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

findAlbumByArtist

public java.util.Collection<MPDSong> findAlbumByArtist(java.lang.String artist,
                                                       java.lang.String album)
                                                throws MPDConnectionException,
                                                       MPDDatabaseException
Returns a Collection of MPDSongs for an album by a particulat artist. Please note this only returns an exact match of album and artist.

Parameters:
artist - the artist alcum belongs to
album - the album to find
Returns:
a Collection of MPDSongs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

findTitle

public java.util.Collection<MPDSong> findTitle(java.lang.String title)
                                        throws MPDConnectionException,
                                               MPDDatabaseException
Returns a Collection of MPDSongs for a title. Please note this only returns an exact match of title. To find a partial match use searchTitle(String title).

Parameters:
title - the title to find
Returns:
a Collection of MPDSongs
Throws:
MPDConnectionException - if there is a problem sending the command
MPDDatabaseException - if the MPD responded with an error

listAllFiles

public java.util.Collection<java.lang.String> listAllFiles()
                                                    throws MPDConnectionException,
                                                           MPDDatabaseException
Returns a Collection of Strings of all songs and directories from the mpd root.

Returns:
a collection of Strings containing all files and dirs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listAllFiles

public java.util.Collection<java.lang.String> listAllFiles(java.lang.String path)
                                                    throws MPDConnectionException,
                                                           MPDDatabaseException
Returns a Collection of Strings of all songs and directories from the given path.

Parameters:
path - the root of the list
Returns:
a collection of Strings containing all files and dirs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listAllSongFiles

public java.util.Collection<java.lang.String> listAllSongFiles()
                                                        throws MPDConnectionException,
                                                               MPDDatabaseException
Returns a Collection of Strings of all songs from the mpd root.

Returns:
a collection of Strings containing all files and dirs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listAllSongFiles

public java.util.Collection<java.lang.String> listAllSongFiles(java.lang.String path)
                                                        throws MPDConnectionException,
                                                               MPDDatabaseException
Returns a Collection of Strings of all songs from the given path.

Parameters:
path - the root of the list
Returns:
a collection of Strings containing all files and dirs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listAllSongs

public java.util.Collection<MPDSong> listAllSongs()
                                           throws MPDConnectionException,
                                                  MPDDatabaseException
Returns a Collection of MPDSongs of all songs from the mpd root.

Returns:
a collection of Strings containing all files and dirs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listAllSongs

public java.util.Collection<MPDSong> listAllSongs(java.lang.String path)
                                           throws MPDConnectionException,
                                                  MPDDatabaseException
Returns a Collection of MPDSongs of all songs from the given path.

Parameters:
path - the root of the list
Returns:
a collection of Strings containing all files and dirs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

searchArtist

public java.util.Collection<MPDSong> searchArtist(java.lang.String artist)
                                           throws MPDConnectionException,
                                                  MPDDatabaseException
Returns a Collection of MPDSongs for an any artist containing the parameter artist. Please note this returns a partial match of an artist. To find an exact match use searchArtist(String artist).

Parameters:
artist - the artist to match
Returns:
a Collection of MPDSongs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

searchAlbum

public java.util.Collection<MPDSong> searchAlbum(java.lang.String album)
                                          throws MPDConnectionException,
                                                 MPDDatabaseException
Returns a Collection of MPDSongs for an any album containing the parameter album. Please note this returns a partial match of an album. To find an exact match use searchAlbum(String album).

Parameters:
album - the album to match
Returns:
a Collection of MPDSongs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

searchTitle

public java.util.Collection<MPDSong> searchTitle(java.lang.String title)
                                          throws MPDConnectionException,
                                                 MPDDatabaseException
Returns a Collection of MPDSongs for an any title containing the parameter title. Please note this returns a partial match of a title. To find an exact match use searchTitle(String title).

Parameters:
title - the title to match
Returns:
a Collection of MPDSongs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

searchFileName

public java.util.Collection<MPDSong> searchFileName(java.lang.String fileName)
                                             throws MPDConnectionException,
                                                    MPDDatabaseException
Returns a Collection of MPDSongs for an any file name containing the parameter filename.

Parameters:
fileName - the file name to match
Returns:
a Collection of MPDSongs
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listAllAlbums

public java.util.Collection<java.lang.String> listAllAlbums()
                                                     throws MPDConnectionException,
                                                            MPDDatabaseException
Returns a Collection of Strings of all albums in the database.

Returns:
a Collection of Strings containing the album names
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listAllArtists

public java.util.Collection<java.lang.String> listAllArtists()
                                                      throws MPDConnectionException,
                                                             MPDDatabaseException
Returns a Collection of Strings of all artists in the database.

Returns:
a Collection of Strings containing the album names
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listAllGenres

public java.util.Collection<java.lang.String> listAllGenres()
                                                     throws MPDConnectionException,
                                                            MPDDatabaseException
Returns a Collection of Strings of all genres in the database.

Returns:
a Collection of Strings containing the genre names
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listAlbumsByArtist

public java.util.Collection<java.lang.String> listAlbumsByArtist(java.lang.String artist)
                                                          throws MPDConnectionException,
                                                                 MPDDatabaseException
Returns a Collection of Strings of all albums by a particular artist.

Parameters:
artist - the artist to find albums
Returns:
a Collection of Strings of all albums
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is aproblem sending the command

getArtistCount

public int getArtistCount()
                   throws MPDConnectionException,
                          MPDDatabaseException
Returns the total number of artists in the database.

Returns:
the total number of artists
Throws:
MPDConnectionException - if there is a problem sending the command
MPDDatabaseException - if the MPD responded with an error

getAlbumCount

public int getAlbumCount()
                  throws MPDConnectionException,
                         MPDDatabaseException
Returns the total number of albums in the database.

Returns:
the total number of albums
Throws:
MPDConnectionException - if there is a problem sending the command
MPDDatabaseException - if the MPD responded with an error

getSongCount

public int getSongCount()
                 throws MPDConnectionException,
                        MPDDatabaseException
Returns the total number of songs in the database.

Returns:
the total number of songs
Throws:
MPDConnectionException - if there is a problem sending the command
MPDDatabaseException - if the MPD responded with an error

getDbPlayTime

public long getDbPlayTime()
                   throws MPDConnectionException,
                          MPDDatabaseException
Returns the sum of all song times in database.

Returns:
the sum of all song times
Throws:
MPDConnectionException - if there is a problem sending the command
MPDDatabaseException - if the MPD responded with an error

getLastUpdateTime

public long getLastUpdateTime()
                       throws MPDConnectionException,
                              MPDDatabaseException
Returns the last database update in UNIX time.

Returns:
the last database update in UNIX time
Throws:
MPDConnectionException - if there is a problem sending the command
MPDDatabaseException - if the MPD responded with an error

getMpd

public MPD getMpd()
Returns the mpd this database class is using.

Returns:
the mpd connection

setMpd

public void setMpd(MPD mpd)
Set the mpd connection this class is using.

Parameters:
mpd - the mpd to use

listPlaylists

public java.util.Collection<java.lang.String> listPlaylists()
                                                     throws MPDConnectionException,
                                                            MPDDatabaseException
Returns a list of all available playlist names on the server.

Returns:
a list of playlist names
Throws:
MPDDatabaseException - if the MPD responded with an error
MPDConnectionException - if there is a problem sending the command

listPlaylistSongs

public java.util.Collection<MPDSong> listPlaylistSongs(java.lang.String playlistName)
                                                throws MPDConnectionException,
                                                       MPDDatabaseException
Throws:
MPDConnectionException
MPDDatabaseException