Package com.brightcove.player.store
Class BaseStore
java.lang.Object
com.brightcove.player.store.BaseStore
- Direct Known Subclasses:
OfflineStoreManager
A base wrapper for
EntityStore
.-
Field Summary
Modifier and TypeFieldDescriptionprotected final android.content.Context
The context of the host application.protected final io.requery.reactivex.ReactiveEntityStore<io.requery.Persistable>
Reference to the data store.static final int
The maximum of expressions allowed in the queries generation by this store.static final int
The maximum of variables allowed in the queries generation by this store.protected final com.brightcove.player.store.BaseStore.Source
Reference to the backing store configuration. -
Constructor Summary
ModifierConstructorDescriptionprotected
BaseStore
(android.content.Context context, io.requery.meta.EntityModel model, int version) Constructs a new instance ofBaseStore
protected
BaseStore
(android.content.Context context, io.requery.meta.EntityModel model, String name, int version) Constructs a new instance ofBaseStore
-
Method Summary
Modifier and TypeMethodDescriptionboolean
compact()
Compacts the physical database file size by running the SQLite VACUUM statement.boolean
deleteEntity
(IdentifiableEntity entity) Deletes an identifiable entity from the store.protected static String
getDefaultDatabaseName
(android.content.Context context, io.requery.meta.EntityModel model) Provides the default database name for the given application context/entity model.protected static String
getDefaultDatabasePassword
(android.content.Context context, io.requery.meta.EntityModel model) Provides the default database password for the given application context/entity model.long
Gets the size of the backing database file.protected void
onCreated
(int version) Called when newEntityDataStore
has been created.protected void
onUpgraded
(int oldVersion, int newVersion) Called when theEntityDataStore
has been upgraded from an previous version to a new version.<E extends IdentifiableEntity>
ErefreshEntity
(E entity) Refresh the given entity.<T extends IdentifiableEntity>
TsaveEntity
(T entity) Inserts or updates the given entity.
-
Field Details
-
MAX_SQL_VARIABLES
public static final int MAX_SQL_VARIABLESThe maximum of variables allowed in the queries generation by this store. Please note the actual limit imposed by Sqlite database is typically 999. However we set the limit to a lower value to give enough headroom for the requery library to manipulate the final query.- See Also:
-
MAX_SQL_EXPRESSIONS
public static final int MAX_SQL_EXPRESSIONSThe maximum of expressions allowed in the queries generation by this store. Please note the actual limit imposed by Sqlite database is typically 1000. However we set the limit to a lower value to give enough headroom for the requery library to manipulate the final query.- See Also:
-
context
protected final android.content.Context contextThe context of the host application. -
source
protected final com.brightcove.player.store.BaseStore.Source sourceReference to the backing store configuration. -
dataStore
protected final io.requery.reactivex.ReactiveEntityStore<io.requery.Persistable> dataStoreReference to the data store.
-
-
Constructor Details
-
BaseStore
protected BaseStore(@NonNull android.content.Context context, @NonNull io.requery.meta.EntityModel model, int version) Constructs a new instance ofBaseStore
- Parameters:
context
- reference to the host application context.model
- the entity modelversion
- the schema version
-
BaseStore
protected BaseStore(@NonNull android.content.Context context, @NonNull io.requery.meta.EntityModel model, @NonNull String name, int version) Constructs a new instance ofBaseStore
- Parameters:
context
- reference to the host application context.model
- the entity modelname
- the name of the databaseversion
- the schema version
-
-
Method Details
-
getFileSize
public long getFileSize()Gets the size of the backing database file.- Returns:
- -1 if an error occured while trying to read the size, 0 if the database file does not exist, otherwise of the size of the database file expressed as total number of bytes.
-
compact
public boolean compact()Compacts the physical database file size by running the SQLite VACUUM statement.- Returns:
- true if the operation was successful, otherwise false.
-
refreshEntity
Refresh the given entity. This refreshes the already loaded properties in the entity. If no properties are loaded then the default properties will be loaded.- Type Parameters:
E
- the expected type of the entity;- Parameters:
entity
- reference to the entity to be refreshed.- Returns:
- null if the entity is null or if it does not exist in the store, otherwise reference to the updated entity
-
onCreated
protected void onCreated(int version) Called when newEntityDataStore
has been created. Override this method to setup the default state of the entity store.- Parameters:
version
- schema version of the store.
-
onUpgraded
protected void onUpgraded(int oldVersion, int newVersion) Called when theEntityDataStore
has been upgraded from an previous version to a new version.- Parameters:
oldVersion
- the old schema versionnewVersion
- the new schema version
-
saveEntity
Inserts or updates the given entity.- Parameters:
entity
- the entity to be save.- Returns:
- the updated the entity.;
-
deleteEntity
Deletes an identifiable entity from the store.- Parameters:
entity
- the entity to be deleted.- Returns:
- true if the entity was found and removed from the store, otherwise false.
-
getDefaultDatabaseName
protected static String getDefaultDatabaseName(android.content.Context context, io.requery.meta.EntityModel model) Provides the default database name for the given application context/entity model.- Parameters:
context
- the context of the host application.model
- reference to the entity model.- Returns:
- the default database name for this application and entity mode.
-
getDefaultDatabasePassword
@Nullable protected static String getDefaultDatabasePassword(android.content.Context context, io.requery.meta.EntityModel model) Provides the default database password for the given application context/entity model.- Parameters:
context
- the context of the host application.model
- reference to the entity model.- Returns:
- the default database name for this application and entity mode.
-