|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface represents a database of songs. It provides facilities for simple searches by keyword and title, and allows clients to check out copies of songs, and check in changes.
This interface also specifies that all operations are atomic and thread-safe. That is, every mutation operation is atomic-- simultaneous mutations are serialized so they will not conflict. In addition, any query operation will always return information about a self-consistent state that the database was or could have been in at some point in the past. In-memory representations such as StandardModel can implement this trivially by synchronizing each method, but an implementation with a SQL backend may require more work to implement these semantics.
Atomicity is not guaranteed for any of the other model interfaces.
Method Summary | |
SongID |
addCopyOfSong(Song original)
Makes a copy of the given song and adds it to the database. |
SongID |
addEmptySong(String title,
Locale locale)
Add a new empty Song to the database. |
Song |
checkOutSong(SongID id)
Get a song by SongID. |
void |
commitSong(Song song)
Commit changes to this song. |
boolean |
containsSongID(SongID id)
Tests whether the given song id exists in this database. |
SongIDResultSet |
createEmptyResultSet()
Create an empty result set. |
void |
forceCommitSong(Song song)
Commit changes to this song. |
void |
forceCommitSongAs(Song song,
SongID songID)
Force-commit a song as the given SongID. |
SongID |
getSongIDForString(String idStr)
Get the SongID for the given string, if it exists. |
boolean |
isSongFresh(Song song)
Check the commit count to see if this song is still fresh. |
boolean |
isWritable()
Returns true if the database is writable. |
SongIDResultSet |
performOperation(SongOperation operation,
SongIDResultSet param)
Perform an operation on a set of songs. |
boolean |
removeSong(SongID id)
Remove the given song from the database. |
Method Detail |
public boolean isWritable()
public Song checkOutSong(SongID id) throws SongDatabaseFailedException
id
- SongID
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will often have a cause exception, which may be exceptions
like IOException or SQLException.
NullPointerException
- id was nullpublic boolean containsSongID(SongID id) throws SongDatabaseFailedException
id
- SongID to test
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will often have a cause exception, which may be exceptions
like IOException or SQLException.
NullPointerException
- id was nullpublic SongID getSongIDForString(String idStr) throws SongDatabaseFailedException
idStr
- serialized ID
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will often have a cause exception, which may be exceptions
like IOException or SQLException.public SongIDResultSet createEmptyResultSet()
public SongIDResultSet performOperation(SongOperation operation, SongIDResultSet param) throws SongDatabaseFailedException
Note that some SongDatabase implementations may choose to optimize this method by not calling the operation directly, but by analzying the semantics of the operation as declared by which operation semantics interfaces are implemented, and performing accelerated operations such as checking caches. Thus, do not expect that the SongOperation object you pass will actually be invoked.
One common use of this method is to get a result set containing all the SongIDs in the database. This is accomplished by passing null for the parameter, and a NopSemantics implementation for the operation.
operation
- SongOperation to performparam
- input result set
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will often have a cause exception, which may be exceptions
like IOException or SQLException.public SongID addEmptySong(String title, Locale locale) throws SongDatabaseFailedException
title
- main title of song to addlocale
- Locale of song to add, or null to use the default locale
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will often have a cause exception, which may be exceptions
like IOException or SQLException.
NullPointerException
- title was nullpublic SongID addCopyOfSong(Song original) throws SongDatabaseFailedException
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will often have a cause exception, which may be exceptions
like IOException or SQLException.
NullPointerException
- original was nullpublic boolean removeSong(SongID id) throws SongDatabaseFailedException
id
- SongID of song to remove
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will often have a cause exception, which may be exceptions
like IOException or SQLException.
NullPointerException
- id was nullpublic boolean isSongFresh(Song song) throws SongDeletedException, SongDatabaseFailedException
song
- song to test
SongDeletedException
- someone deleted this song in the meantime
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will often have a cause exception, which may be exceptions
like IOException or SQLException.
IllegalArgumentException
- this database is not the owner of the Song
NullPointerException
- song was nullpublic void commitSong(Song song) throws SongNotFreshException, SongDeletedException, SongDatabaseFailedException
song
- song to commit
SongNotFreshException
- someone committed a change in the meantime
SongDeletedException
- someone deleted this song in the meantime
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will always have a cause exception, which may be exceptions
like IOException or SQLException.
IllegalArgumentException
- this database is not the owner of the Song
NullPointerException
- song was nullpublic void forceCommitSong(Song song) throws SongDeletedException, SongDatabaseFailedException
song
- song to commit
SongDeletedException
- someone deleted this song in the meantime
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will always have a cause exception, which may be exceptions
like IOException or SQLException.
IllegalArgumentException
- this database is not the owner of the Song
NullPointerException
- song was nullpublic void forceCommitSongAs(Song song, SongID songID) throws SongDeletedException, SongDatabaseFailedException
song
- song to commitsongID
- SongID to commit as
SongDeletedException
- someone deleted the SongID
SongDatabaseFailedException
- Catch-all exception for database-related
problems. This will always have a cause exception, which may be exceptions
like IOException or SQLException.
IllegalArgumentException
- this database is not the owner of the SongID
NullPointerException
- song or songID was null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |