Android Open Source - InMemoryDb Data Source






From Project

Back to project page InMemoryDb.

License

The source code is released under:

Apache License

If you think the Android project InMemoryDb listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.gawst.asyncdb;
//  www . j ava 2s . c o m
import android.content.ContentValues;

/**
 * Interface to define a data source with {@link E} elements.
 *
 * @param <E> Elements read/written by the data source.
 * @param <INSERT_ID> Type of the object returned by {@link #insert(android.content.ContentValues)}
 * @author Created by robUx4 on 12/31/2014.
 */
public interface DataSource<E, INSERT_ID> {

  /**
   * Internal interface to handle elements when the whole database is read.
   *
   * @param <E>
   */
  public interface BatchReadingCallback<E> {
    /**
     * Add the element in the memory storage
     *
     * @param item The object to add
     */
    void addItemInMemory(E item);

    /**
     * Called when we have the cursor to read the data from.
     * <p/>
     * Useful to prepare the amount of data needed or get the index of the column we need.
     *
     * @param elementCount The amount of elements that are about to be read from the database.
     */
    void startLoadingAllItems(int elementCount);

    void removeInvalidEntry(InvalidEntry invalidEntry);
  }

  /**
   * Internal call to read the whole database.
   *
   * @param readingCallback
   * @return All the elements in the source with all the fields
   */
  void queryAll(BatchReadingCallback<E> readingCallback);

  /**
   * Clear all the data in the source
   *
   * @return the number of items removed
   */
  int clearAllData();

  /**
   * Add a new element in the source
   *
   * @param element The element to add
   * @return An object representing the added item or {@code null} if it wasn't added
   */
  INSERT_ID insert(ContentValues element) throws RuntimeException;

  /**
   * Delete the item from the source of data
   *
   * @param itemToDelete
   * @return {@code true} if the element was removed
   */
  boolean delete(E itemToDelete);

  /**
   * Delete the data specified by the {@code invalidEntry} from the source.
   *
   * @param invalidEntry
   * @return
   */
  boolean deleteInvalidEntry(InvalidEntry invalidEntry);

  /**
   * Update an element already in the database
   *
   * @param itemToUpdate
   * @param updateValues
   * @return {@code true} if the element was updated
   */
  boolean update(E itemToUpdate, ContentValues updateValues);

  /**
   * Completely delete the data source, likely because it's corrupted beyond repair
   */
  void eraseSource();
}




Java Source Code List

org.gawst.asyncdb.AsyncDatabaseHandler.java
org.gawst.asyncdb.AsyncDbHelperHandler.java
org.gawst.asyncdb.AsyncQueryHandler.java
org.gawst.asyncdb.AsynchronousDatabase.java
org.gawst.asyncdb.AsynchronousDbErrorHandler.java
org.gawst.asyncdb.AsynchronousDbHelper.java
org.gawst.asyncdb.AsynchronousDbOperation.java
org.gawst.asyncdb.DataSource.java
org.gawst.asyncdb.InMemoryDbArrayList.java
org.gawst.asyncdb.InMemoryDbCopyOnWriteArrayList.java
org.gawst.asyncdb.InMemoryDbList.java
org.gawst.asyncdb.InMemoryDbListener.java
org.gawst.asyncdb.InMemoryDbMap.java
org.gawst.asyncdb.InMemoryDbSet.java
org.gawst.asyncdb.InMemoryDbTreeSet.java
org.gawst.asyncdb.InMemoryHashmapDb.java
org.gawst.asyncdb.InMemoryLruCache.java
org.gawst.asyncdb.InvalidDbEntry.java
org.gawst.asyncdb.InvalidEntry.java
org.gawst.asyncdb.LogManager.java
org.gawst.asyncdb.Logger.java
org.gawst.asyncdb.LruCache.java
org.gawst.asyncdb.MapDataSource.java
org.gawst.asyncdb.MapDatabaseElementHandler.java
org.gawst.asyncdb.MapEntry.java
org.gawst.asyncdb.adapter.InMemoryArrayListAdapter.java
org.gawst.asyncdb.adapter.InMemoryFilteredAdapter.java
org.gawst.asyncdb.adapter.InMemoryFilteredListAdapter.java
org.gawst.asyncdb.adapter.InMemoryFilteredTreeAdapter.java
org.gawst.asyncdb.adapter.InMemoryTreeSetAdapter.java
org.gawst.asyncdb.adapter.UIHandler.java
org.gawst.asyncdb.purge.DatabasePurgerMaxDate.java
org.gawst.asyncdb.purge.DatabaseSourcePurgerMax.java
org.gawst.asyncdb.purge.DatabaseSourcePurger.java
org.gawst.asyncdb.purge.PurgeHandler.java
org.gawst.asyncdb.source.ContentProviderDataSource.java
org.gawst.asyncdb.source.CursorDataSource.java
org.gawst.asyncdb.source.DatabaseElementHandler.java
org.gawst.asyncdb.source.DatabaseSource.java
org.gawst.asyncdb.source.SqliteDataSource.java
org.gawst.asyncdb.source.SqliteMapDataSource.java
org.gawst.asyncdb.source.typed.TypedContentProviderDataSource.java
org.gawst.asyncdb.source.typed.TypedCursorDataSource.java
org.gawst.asyncdb.source.typed.TypedDatabaseElementHandler.java
org.gawst.asyncdb.source.typed.TypedDatabaseSource.java
org.gawst.asyncdb.source.typed.TypedSqliteDataSource.java
org.gawst.asyncdb.source.typed.TypedSqliteMapDataSource.java