Class BaseStore

java.lang.Object
com.brightcove.player.store.BaseStore
Direct Known Subclasses:
OfflineStoreManager

public class BaseStore extends Object
A base wrapper for EntityStore.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected 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

    Constructors
    Modifier
    Constructor
    Description
    protected
    BaseStore(android.content.Context context, io.requery.meta.EntityModel model, int version)
    Constructs a new instance of BaseStore
    protected
    BaseStore(android.content.Context context, io.requery.meta.EntityModel model, String name, int version)
    Constructs a new instance of BaseStore
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compacts the physical database file size by running the SQLite VACUUM statement.
    boolean
    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 new EntityDataStore has been created.
    protected void
    onUpgraded(int oldVersion, int newVersion)
    Called when the EntityDataStore has been upgraded from an previous version to a new version.
    <E extends IdentifiableEntity>
    E
    refreshEntity(E entity)
    Refresh the given entity.
    <T extends IdentifiableEntity>
    T
    saveEntity(T entity)
    Inserts or updates the given entity.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_SQL_VARIABLES

      public static final int MAX_SQL_VARIABLES
      The 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_EXPRESSIONS
      The 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 context
      The context of the host application.
    • source

      protected final com.brightcove.player.store.BaseStore.Source source
      Reference to the backing store configuration.
    • dataStore

      protected final io.requery.reactivex.ReactiveEntityStore<io.requery.Persistable> dataStore
      Reference 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 of BaseStore
      Parameters:
      context - reference to the host application context.
      model - the entity model
      version - 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 of BaseStore
      Parameters:
      context - reference to the host application context.
      model - the entity model
      name - the name of the database
      version - 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

      @Nullable public <E extends IdentifiableEntity> E refreshEntity(@Nullable E entity)
      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 new EntityDataStore 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 the EntityDataStore has been upgraded from an previous version to a new version.
      Parameters:
      oldVersion - the old schema version
      newVersion - the new schema version
    • saveEntity

      public <T extends IdentifiableEntity> T saveEntity(@NonNull T entity)
      Inserts or updates the given entity.
      Parameters:
      entity - the entity to be save.
      Returns:
      the updated the entity.;
    • deleteEntity

      public boolean deleteEntity(@Nullable IdentifiableEntity entity)
      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.