|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.qtunes.db.spi.DatabaseImpl
public class DatabaseImpl
The Database manages the Tracks and Playlists. It stores
the Playlists in a simple map, which is serialized out in
the same way as the Service#saveState
method works.
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 |
protected void |
activate(org.osgi.service.component.ComponentContext context)
|
void |
commit()
Commit any pending database changes (new or modified tracks) to the database. |
Track |
create(FieldMap map)
Create a new Track entry. |
protected void |
deactivate(org.osgi.service.component.ComponentContext context)
|
void |
delete(int track)
Delete the specified track |
Object |
getField(int track,
String fieldname)
Return the named Field from this Database |
List<Map<String,Object>> |
getFields(BitSet tracks,
String[] fields)
Get a List of the specified Fields for the specified Tracks |
int |
getLastModified()
Return the timestamp of the last modification to the Database |
Playlist |
getPlaylist(String name)
Get the Playlist with the specified name. |
Collection<String> |
getPlaylists()
Get the list of Playlist names |
String |
getShortName()
|
Track |
getTrack(int tracknumber)
Get the track with the specified track index |
BitSet |
getTracks()
Return a BitSet with all the track indices in the Database |
boolean |
hasPending()
Return true if a transaction has been begun with a call to begin() ) |
int |
max()
Return the maximum track index in this Database |
void |
putPlaylist(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 |
startService(ServiceContext context)
|
void |
stopService()
|
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)
startService
in interface Service
public void stopService()
stopService
in interface Service
public String getShortName()
getShortName
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 BitSet getTracks()
Database
getTracks
in interface Database
public int getLastModified()
Database
getLastModified
in interface Database
public int max()
Database
max
in interface Database
public int size()
Database
size
in interface Database
public Track getTrack(int tracknumber)
getTrack
in interface Database
public Object getField(int track, String fieldname)
Database
getField
in interface Database
public List<Map<String,Object>> getFields(BitSet tracks, String[] fields)
Database
getFields
in interface Database
public void delete(int track)
delete
in interface Database
public void commit()
Database
commit
in interface Database
public void abort()
abort
in interface Database
public boolean hasPending()
begin()
)
hasPending
in interface Database
public Playlist getPlaylist(String name)
Database
getPlaylist
in interface Database
public Collection<String> getPlaylists()
Database
getPlaylists
in interface Database
public void putPlaylist(String name, Playlist playlist)
Database
putPlaylist
in interface Database
public void updateTrack(int tracknumber, FieldMap changes) throws IOException
Database
updateTrack
in interface Database
IOException
protected void activate(org.osgi.service.component.ComponentContext context)
protected void deactivate(org.osgi.service.component.ComponentContext context)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |