Package storage
Class SQLiteStorage
java.lang.Object
storage.SQLiteStorage
- All Implemented Interfaces:
MediaStorage
Implementation of MediaStorage backed by a SQLite database.
-
Constructor Summary
ConstructorsConstructorDescriptionSQLiteStorage(File file) Instantiate a new SQLiteStorage backed by the given file. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanReturn whether or not Media with the given ID is stored.voiddeleteMedia(long id) Delete the Media with the given ID.voiddeleteMediaByID(Long id) Delete the Media with the given unqiue identifier.getIDsWithin(double x, double y, double w, double h) voidinsertMedia(Media media) Store the given media.booleanisIDtaken(long id) booleanReturn whether or not this DB is stored in memory rather than in a file.loadMedia(long id) Load the Media with the given name.voidSave the given Media.voidStore the current database in the given file and switch to using that file as the current database.Return all the IDs currently storedLoad the Media with the given unique identifier.selectIDsWithin(double x, double y, double w, double h) Return the IDs of media within the given rectangular region.selectMediaByID(Long id) Load the Media with the given unique identifier.
-
Constructor Details
-
SQLiteStorage
Instantiate a new SQLiteStorage backed by the given file.If `file` is `null`, then the storage will be backed by memory instead of a file.
- Throws:
Exception
-
-
Method Details
-
saveTo
Store the current database in the given file and switch to using that file as the current database.- Throws:
Exception
-
isInMemory
public boolean isInMemory()Return whether or not this DB is stored in memory rather than in a file. -
insertMedia
Store the given media.- Throws:
Exception
-
selectMediaByID
Load the Media with the given unique identifier.- Throws:
Exception
-
selectBaseMediaByID
Load the Media with the given unique identifier.Unlike `selectMediaByID`, this method does not deserialize the object and instead instantiates the base Media class from the properties common to all media types. This is useful for inspecting the position, etc. of a stored Media object without having to deserialize the whole object (which might be costly for some potentially large Media types such as audio).
- Throws:
Exception
-
deleteMediaByID
Delete the Media with the given unqiue identifier.- Throws:
Exception
-
selectAllIDs
Return all the IDs currently stored- Throws:
Exception
-
selectIDsWithin
Return the IDs of media within the given rectangular region.- Parameters:
x- The X-coordinate of the top-left corner of the rectangular regiony- The Y-coordinate of the top-left corner of the rectangular regionw- The width of the rectangular regionh- The height of the rectangular region- Throws:
Exception
-
contains
Return whether or not Media with the given ID is stored.- Throws:
Exception
-
close
- Throws:
Exception
-
deleteMedia
Description copied from interface:MediaStorageDelete the Media with the given ID.- Specified by:
deleteMediain interfaceMediaStorage- Throws:
Exception
-
saveMedia
Description copied from interface:MediaStorageSave the given Media.The Media must be assigned an ID other than `Media.EMPTY_ID`.
- Specified by:
saveMediain interfaceMediaStorage- Throws:
Exception
-
loadMedia
Description copied from interface:MediaStorageLoad the Media with the given name.- Specified by:
loadMediain interfaceMediaStorage- Parameters:
id- The unique identifier of the Media to load- Returns:
- The Media object with the given ID, or `null` if no such Media object is stored.
- Throws:
Exception
-
getIDsWithin
- Specified by:
getIDsWithinin interfaceMediaStorage- Returns:
- The IDs of the Media objects within the rectangular region with width `w`, height `h`, and top-left corner at (`x`, `y`).
- Throws:
Exception
-
isIDtaken
- Specified by:
isIDtakenin interfaceMediaStorage- Returns:
- Whether or not Media with the given identifier is stored.
- Throws:
Exception
-