|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.qtunes.db.spi.simple.DatabaseImpl
public class DatabaseImpl
The Database manages the Tracks and Playlists. It stores the Playlists as properties for this service.
The track database is done via a Store
, and works
in two stages. First, a MemoryStore
is updated with
the track information, then when commit()
is called
this temporary store is merged with the main Store (probably
a FileStore
at this stage. This is a flat-file which
is designed for very quick random access to track data.
This class is necessarily one of the more complex and it may change over time. It must be thread safe (with java.util.concurrent).
Constructor Summary | |
---|---|
DatabaseImpl()
|
Method Summary | |
---|---|
void |
abort()
Abort the current pending transactions |
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 query)
Create a new ManualPlaylist |
ServiceContext |
getContext()
Return the ServiceContext that was passed into Service.startService(org.qtunes.core.ServiceContext) |
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. |
boolean |
hasPending()
Return true if a transaction has been begun with a call to begin() ) |
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. |
java.util.Map<java.lang.String,java.lang.Object> |
reportState()
Return a Map describing the state of this Service, for serialization back to any client that needs to know (eg webplayer) - so values should be serializable objects, eg Lists, Maps or simple objects. |
int |
size()
Return the number of tracks in this Database |
void |
startService(ServiceContext context)
Start the Service |
void |
stopService(ServiceContext context)
Stop the Service |
void |
updateTrack(int tracknumber,
FieldMap changes)
Update the fields on the specified Track. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DatabaseImpl()
Method Detail |
---|
public void startService(ServiceContext context)
Service
startService
in interface Service
context
- the ServiceContext for this Servicepublic void stopService(ServiceContext context)
Service
stopService
in interface Service
context
- the ServiceContext for this Service (same as was passed into start)public ServiceContext getContext()
Service
Service.startService(org.qtunes.core.ServiceContext)
getContext
in interface Service
public Track create(FieldMap map)
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.
create
in interface Database
public java.util.Collection<Track> getTracks()
Database
getTracks
in interface Database
public java.util.List<Track> getTracks(java.lang.String sort, java.lang.String filter)
Database
getTracks
in interface Database
public int getRevision()
Database
getRevision
in interface Database
public int size()
Database
size
in interface Database
public Track getTrack(int tracknumber)
getTrack
in interface Database
public void lock(boolean hold)
Database
lock
in interface Database
public void commit()
Database
commit
in interface Database
public void abort()
public boolean hasPending()
begin()
)
public Playlist getPlaylist(java.lang.String name)
Database
getPlaylist
in interface Database
public java.util.Collection<java.lang.String> getPlaylists()
Database
getPlaylists
in interface Database
public void putPlaylist(java.lang.String name, Playlist playlist)
Database
putPlaylist
in interface Database
public void updateTrack(int tracknumber, FieldMap changes) throws java.io.IOException
Database
updateTrack
in interface Database
java.io.IOException
public ManualPlaylist createManualPlaylist()
Database
createManualPlaylist
in interface Database
public SmartPlaylist createSmartPlaylist(java.lang.String query)
Database
createSmartPlaylist
in interface Database
public java.util.Map<java.lang.String,java.lang.Object> reportState()
Service
reportState
in interface Service
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |