org.qtunes.db
Interface Database

All Superinterfaces:
Service
All Known Implementing Classes:
DatabaseImpl

public interface Database
extends Service

The Database manages the Tracks and Playlists. How it works is down to the implementation but in general the rules are it must handle locking, as it will be read/ written to by multiple threads.


Method Summary
 void commit()
          Commit any pending database changes (new or modified tracks) to the database.
 Track create(FieldMap map)
          Create a new Track entry.
 ManualPlaylist createManualPlaylist()
          Create a new ManualPlaylist
 SmartPlaylist createSmartPlaylist(java.lang.String filter)
          Create a new ManualPlaylist
 Playlist getPlaylist(java.lang.String name)
          Get the Playlist with the specified name.
 java.util.Collection<java.lang.String> getPlaylists()
          Get the list of Playlist names
 int getRevision()
          Return the revision number of the Database
 Track getTrack(int tracknumber)
          Get the track with the specified track index
 java.util.Collection<Track> getTracks()
          Return a read-only Collection with all the Tracks in the Database in arbirary order.
 java.util.List<Track> getTracks(java.lang.String sort, java.lang.String filter)
          Return a List of the tracks in the database with the specified sort order and filter.
 void lock(boolean hold)
          Lock or unlock the database for edits.
 void putPlaylist(java.lang.String name, Playlist playlist)
          Store (possibly overwriting) the playlist with the specified name.\ If the value is null the playlist will be removed.
 int size()
          Return the number of tracks in this Database
 void updateTrack(int tracknumber, FieldMap changes)
          Update the fields on the specified Track.
 
Methods inherited from interface org.qtunes.core.Service
getContext, reportState, startService, stopService
 

Method Detail

create

Track create(FieldMap map)
Create a new Track entry. The track will initially be created in the temporary store - whether this method runs an "update" or an "insert" depends on the Matcher, which will try to match the fields in the FieldMap against the existing tracks. This may be done by Filename, by Inode or by checksum of the audio data (for example). The fields are then stored and the Track returned.


getTracks

java.util.Collection<Track> getTracks()
Return a read-only Collection with all the Tracks in the Database in arbirary order.


getTracks

java.util.List<Track> getTracks(java.lang.String sort,
                                java.lang.String filter)
Return a List of the tracks in the database with the specified sort order and filter. This list will be regenerated on each call so should be called sparingly. The returned list may be modified


getRevision

int getRevision()
Return the revision number of the Database


size

int size()
Return the number of tracks in this Database


getTrack

Track getTrack(int tracknumber)
Get the track with the specified track index


commit

void commit()
Commit any pending database changes (new or modified tracks) to the database.


getPlaylist

Playlist getPlaylist(java.lang.String name)
Get the Playlist with the specified name. The special name "*" means the Playlist that matches all tracks in the database


getPlaylists

java.util.Collection<java.lang.String> getPlaylists()
Get the list of Playlist names


putPlaylist

void putPlaylist(java.lang.String name,
                 Playlist playlist)
Store (possibly overwriting) the playlist with the specified name.\ If the value is null the playlist will be removed.


updateTrack

void updateTrack(int tracknumber,
                 FieldMap changes)
                 throws java.io.IOException
Update the fields on the specified Track. The track file will be updated immediately, the database only on the next commit

Throws:
java.io.IOException

createManualPlaylist

ManualPlaylist createManualPlaylist()
Create a new ManualPlaylist


createSmartPlaylist

SmartPlaylist createSmartPlaylist(java.lang.String filter)
Create a new ManualPlaylist


lock

void lock(boolean hold)
Lock or unlock the database for edits. Use sparingly!