|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.ambient.library.DBStrategy
public final class DBStrategy
The database backend for the library. Handles database operations.
| Field Summary | |
|---|---|
static int |
DATABASE_VERSION
The database version. |
| Constructor Summary | |
|---|---|
DBStrategy(android.content.Context ctx)
Creates the backend instance and opens/creates the database. |
|
| Method Summary | |
|---|---|
(package private) void |
clean(TrackOriginEnum storage)
Removes all data from all tables. |
(package private) void |
close()
Closes the database and releases all resources. |
static java.util.EnumMap<CategoryEnum,java.util.List<java.lang.String>> |
convertCriteria(java.util.Map<? extends CategoryEnum,? extends java.lang.String> map)
Converts a simple criteria to a complex criteria type. |
android.database.Cursor |
findAll()
Finds all tracks. |
android.database.Cursor |
findByCriteria(java.util.EnumMap<CategoryEnum,java.util.List<java.lang.String>> criteria,
boolean like,
boolean and,
java.lang.String orderBy)
Searches tracks. |
android.database.Cursor |
findByCriteria(java.util.Map<CategoryEnum,java.lang.String> criteria,
boolean like,
java.lang.String orderBy)
Searches tracks. |
java.util.Map<java.lang.String,java.lang.Long> |
getAllGenres()
Loads all genres as a map. |
android.database.Cursor |
getCriteriaList(CategoryEnum[] crit,
java.util.EnumMap<CategoryEnum,java.lang.String> criteria)
Returns matchable strings from existing tracks for given criteria values. |
(package private) android.database.sqlite.SQLiteDatabase |
getDb()
Returns the initialized database instance. |
int |
getGenreId(java.lang.String genre)
Searches for given genre and returns its id. |
android.database.Cursor |
rawQuery(java.lang.String select,
java.lang.String[] selectionArgs)
Invokes the SQLiteDatabase.rawQuery(String, String[]) method. |
android.database.Cursor |
rawTrackQuery(java.lang.String where,
java.lang.String[] selectionArgs)
Performs a raw query on the track table. |
(package private) long |
registerNewGenre(java.lang.String name)
Registers new genre and returns its id. |
(package private) long |
registerNewTrack(TrackMetadataBean track,
java.util.Set<java.lang.Long> genreIds)
Registers a new track with given genres. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DATABASE_VERSION
| Constructor Detail |
|---|
DBStrategy(android.content.Context ctx)
throws java.io.FileNotFoundException
ctx - the context.
java.io.FileNotFoundException - if the database fails to both open and create.| Method Detail |
|---|
void close()
android.database.sqlite.SQLiteDatabase getDb()
null.
java.lang.IllegalStateException - if the database was closed.void clean(TrackOriginEnum storage)
storage - the storage to clean. If null then all tracks and
genres are removed.public int getGenreId(java.lang.String genre)
genre - the genre to search for, must not be null.
-1 if given genre does not yet
exist.long registerNewGenre(java.lang.String name)
name - the genre name, must not be null.
long registerNewTrack(TrackMetadataBean track,
java.util.Set<java.lang.Long> genreIds)
track - the track to register.genreIds - list of genres for this track.
public android.database.Cursor getCriteriaList(CategoryEnum[] crit,
java.util.EnumMap<CategoryEnum,java.lang.String> criteria)
CategoryEnum.Genre returns all genres. Returns
ordered list.
crit - the criteria to search for. The result is ordered by these
criteria.criteria - the criteria map. All criteria combines using the AND
operator. Must not contain the crit parameter.
May be null - this is equal to an empty map.
Cursor.getString(0).
public android.database.Cursor findByCriteria(java.util.Map<CategoryEnum,java.lang.String> criteria,
boolean like,
java.lang.String orderBy)
criteria - the criteria map. All criteria combines using the AND
operator. May be null - this is equal to an empty
map. When using the CategoryEnum.Origin criteria, use
TrackOriginEnum.toDBString() as value.orderBy - the order by clause, if null then ordering is
undefined.like - if true then given strings will be compared using
the LIKE operator. Note that the values are automatically
enclosed in %%.
TrackMetadataBean using
LibraryUtils.cursorToTrackBean(Cursor). Use
LibraryUtils.pollTracks(Cursor) to get all results.
public android.database.Cursor findByCriteria(java.util.EnumMap<CategoryEnum,java.util.List<java.lang.String>> criteria,
boolean like,
boolean and,
java.lang.String orderBy)
criteria - the criteria map. All criteria are combined using the required
operator (depending on the value of the and
argument). May be null - this is equal to an
empty map. Several values for a single criteria are combined
depending on the value of the and parameter. When
using the CategoryEnum.Origin criteria, use
TrackOriginEnum.toDBString() as value.like - if true then given strings will be compared using
the LIKE operator. Note that the values are automatically
enclosed in %%.and - If true then the criteria is combined using the
AND operator. If false then the criteria is
combined using the OR operator.orderBy - the order by clause, if null then ordering is
undefined.
TrackMetadataBean using
LibraryUtils.cursorToTrackBean(Cursor). Use
LibraryUtils.pollTracks(Cursor) to get all results.public static java.util.EnumMap<CategoryEnum,java.util.List<java.lang.String>> convertCriteria(java.util.Map<? extends CategoryEnum,? extends java.lang.String> map)
map - the simple criteria.
public android.database.Cursor findAll()
TrackMetadataBean using
LibraryUtils.cursorToTrackBean(Cursor). Use
LibraryUtils.pollTracks(Cursor) to get all results.
public android.database.Cursor rawTrackQuery(java.lang.String where,
java.lang.String[] selectionArgs)
where - the where clausuleselectionArgs - optional selection argument values, may be null.
TrackMetadataBean using
LibraryUtils.cursorToTrackBean(Cursor). Use
LibraryUtils.pollTracks(Cursor) to get all results.
public android.database.Cursor rawQuery(java.lang.String select,
java.lang.String[] selectionArgs)
SQLiteDatabase.rawQuery(String, String[]) method.
select - the SQL SELECT statement.selectionArgs - optional arguments, may be null.
public java.util.Map<java.lang.String,java.lang.Long> getAllGenres()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||