net.shredzone.ifish.db
Class PlaylistDb

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by net.shredzone.ifish.db.PlaylistDb
All Implemented Interfaces:
Serializable, ListModel

public class PlaylistDb
extends AbstractListModel

This class contains the playlist database.

Version:
$Id: PlaylistDb.java 291 2009-04-28 21:29:27Z shred $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
PlaylistDb(String basedir)
          Create an empty database.
 
Method Summary
 void addEntryByComment(FileEntry entry)
          Add a FileEntry to all the target playlists.
 void addPlaylist(Playlist playlist)
          Add a playlist to the database.
 void cleanup()
          Removes all empty playlists.
 boolean containsPlaylist(String name)
          Checks if a playlist with a certain name is known.
 Object getElementAt(int index)
          Get a playlist at a certain index.
 Playlist getPlaylist(String name)
          Get a playlist with a certain name.
 int getSize()
          Get the size of all Playlists stored in this PlaylistDB.
 Iterator<Playlist> iterator()
          Get an interator for all Playlist in this PlaylistDb.
 void markAll()
          Mark all playlists for sorting.
 void readPlaylists(File base, NaviDb navi, String charset, StatusCallback cb)
          Read all playlists from the ifish directory of the base directory, in the given charset.
 void removeEntry(Entry entry)
          Remove an Entry from all playlists.
 void removePlaylist(Playlist playlist)
          Remove a playlist from the database.
 void renamePlaylist(Playlist playlist, String name)
          Rename a playlist.
 void sortMarkAll()
          Sort all marked parts in all playlists.
 void writePlaylists(File base, String charset, StatusCallback cb)
          Write all playlists to the ifish directory of the base directory, in the given charset.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlaylistDb

public PlaylistDb(String basedir)
Create an empty database.

Method Detail

addPlaylist

public void addPlaylist(Playlist playlist)
Add a playlist to the database.

Parameters:
playlist - Playlist to be added

removePlaylist

public void removePlaylist(Playlist playlist)
Remove a playlist from the database. If the entry does not exist, nothing will happen.

Parameters:
playlist - Playlist to be removed

renamePlaylist

public void renamePlaylist(Playlist playlist,
                           String name)
Rename a playlist. This is only possible for static playlists.

Parameters:
playlist - Playlist to be renamed
name - New name of the playlist

containsPlaylist

public final boolean containsPlaylist(String name)
Checks if a playlist with a certain name is known.

Parameters:
name - Name of the playlist (not the internal name)
Returns:
true: there already is a playlist known with that name.

getPlaylist

public Playlist getPlaylist(String name)
Get a playlist with a certain name. If there is no playlist with that name known, a new empty Playlist will be created. I.e. the method will always return a Playlist unless the memory is filled or so...

Parameters:
name - Name of the playlist (not the internal name)
Returns:
Playlist with that internal name.

addEntryByComment

public void addEntryByComment(FileEntry entry)
Add a FileEntry to all the target playlists. The file tag's comment will be evaluated for the playlist names the file will belong to, and the FileEntry will then be added to the appropriate playlists.

Note that only FileEntry objects can be added to playlists, since the comment is not stored in an DbEntry.

Parameters:
entry - FileEntry to be added to the playlists

removeEntry

public void removeEntry(Entry entry)
Remove an Entry from all playlists.

Parameters:
entry - Entry to be removed from all playlists

cleanup

public void cleanup()
Removes all empty playlists.


getSize

public int getSize()
Get the size of all Playlists stored in this PlaylistDB.

Returns:
Number of playlists

getElementAt

public Object getElementAt(int index)
Get a playlist at a certain index.

Parameters:
index - Index to get the Playlist from
Returns:
Playlist object or null if there was none at the index

iterator

public Iterator<Playlist> iterator()
Get an interator for all Playlist in this PlaylistDb.

Returns:
Iterator

markAll

public void markAll()
Mark all playlists for sorting.


sortMarkAll

public void sortMarkAll()
Sort all marked parts in all playlists.


readPlaylists

public void readPlaylists(File base,
                          NaviDb navi,
                          String charset,
                          StatusCallback cb)
                   throws IOException,
                          UnsupportedEncodingException
Read all playlists from the ifish directory of the base directory, in the given charset. If a StatusCallback is provided, it is used for showing the current write state.

The Jukebox software is only able to handle ISO-8859-1 encoded playlists. For the time being, the charset passed in will be ignored and ISO-8859-1 will always be used.

Parameters:
base - iHP base directory
navi - NaviDb where to find the Entry objects for each file
charset - Charset to be used
cb - StatusCallback to be used, or null
Throws:
IOException
UnsupportedEncodingException

writePlaylists

public void writePlaylists(File base,
                           String charset,
                           StatusCallback cb)
                    throws IOException,
                           UnsupportedEncodingException
Write all playlists to the ifish directory of the base directory, in the given charset. If a StatusCallback is provided, it is used for showing the current write state.

The Jukebox software is only able to handle ISO-8859-1 encoded playlists. For the time being, the charset passed in will be ignored and ISO-8859-1 will always be used.

Parameters:
base - iHP base directory
charset - Charset to be used
cb - StatusCallback to be used, or null
Throws:
IOException
UnsupportedEncodingException


Copyright © 2007-2011 shredzone.org. All Rights Reserved.