Android Open Source - InMemoryDb Typed Database 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.source.typed;
//from   ww  w  . j  a v a  2 s  .co  m
import android.content.ContentValues;
import android.database.Cursor;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

/**
 * Interface for classes that read/write data in SQL queries
 *
 * @param <INSERT_ID>   Type of element returned by {@link #insert(android.content.ContentValues) insert()}
 * @param <DATABASE_ID> Type of the ID needed to use {@link org.gawst.asyncdb.AsyncDatabaseHandler}
 * @param <CURSOR> Wrapper around the raw {@code Cursor} read
 * @author Created by robUx4 on 11/01/2015.
 */
public interface TypedDatabaseSource<INSERT_ID, DATABASE_ID, CURSOR extends Cursor> {
  /**
   * Query the {@link org.gawst.asyncdb.source.DatabaseSource} with an SQL-like syntax.
   *
   * @param columns       A list of which columns to return. Passing null will
   *                      return all columns, which is inefficient.
   * @param selection     A filter declaring which rows to return, formatted as an
   *                      SQL WHERE clause (excluding the WHERE itself). Passing null will
   *                      return all rows.
   * @param selectionArgs You may include ?s in selection, which will be
   *                      replaced by the values from selectionArgs, in the order that they
   *                      appear in the selection. The values will be bound as Strings.
   * @param groupBy       A filter declaring how to group rows, formatted as an SQL
   *                      GROUP BY clause (excluding the GROUP BY itself). Passing null
   *                      will cause the rows to not be grouped.
   * @param having        A filter declare which row groups to include in the cursor,
   *                      if row grouping is being used, formatted as an SQL HAVING
   *                      clause (excluding the HAVING itself). Passing null will cause
   *                      all row groups to be included, and is required when row
   *                      grouping is not being used.
   * @param orderBy       How to order the rows, formatted as an SQL ORDER BY
   *                      clause (excluding the ORDER BY itself). Passing null will use the
   *                      default sort order, which may be unordered.
   * @param limit         Limits the number of rows returned by the query,
   *                      formatted as LIMIT clause. Passing null denotes no LIMIT clause.
   * @return a {@link android.database.Cursor} containing the result of the selection.
   */
  CURSOR query(@Nullable String[] columns, @Nullable String selection, @Nullable String[] selectionArgs,
               @Nullable String groupBy, @Nullable String having, @Nullable String orderBy, @Nullable String limit);

  /**
   * Insert a raw in the database.
   *
   * @param values The initial values for the newly inserted row. The key is the column name for
   *               the field. Passing an empty ContentValues will create an empty row.
   * @return a {@link INSERT_ID} specific to the {@link org.gawst.asyncdb.source.DatabaseSource}
   * @throws RuntimeException
   */
  INSERT_ID insert(@NonNull ContentValues values) throws RuntimeException;

  /**
   * Update row(s) in the {@link org.gawst.asyncdb.source.DatabaseSource}.
   *
   * @param updateValues  The new field values. The key is the column name for the field.  A null value will remove an existing field value.
   * @param selection     A filter to apply to rows before updating, formatted as an SQL WHERE clause  (excluding the WHERE itself).
   * @param selectionArgs You may include ?s in the selection clause, which
   *                      will be replaced by the values from whereArgs. The values
   *                      will be bound as Strings.
   * @return the number of rows updated.
   */
  int update(@NonNull ContentValues updateValues, @Nullable String selection, @Nullable String[] selectionArgs);

  /**
   * Delete row(s) from the {@link org.gawst.asyncdb.source.DatabaseSource}.
   *
   * @param selection     A filter to apply to rows before deleting, formatted as an SQL WHERE clause  (excluding the WHERE itself).
   * @param selectionArgs You may include ?s in the selection clause, which
   *                      will be replaced by the values from whereArgs. The values
   *                      will be bound as Strings.
   * @return
   */
  int delete(@Nullable String selection, @Nullable String[] selectionArgs);

  /**
   * @return The database ID needed to use {@link org.gawst.asyncdb.AsyncDatabaseHandler}
   */
  DATABASE_ID getDatabaseId();

  /**
   * @return the raw {@link android.database.Cursor} read from the database turned into a more friendly {@link CURSOR}.
   */
  CURSOR wrapCursor(Cursor cursor);
}




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