Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.gawst.asyncdb.source.typed;
  
  
  import  android.annotation.TargetApi;
  import  android.content.ContentValues;
 import  android.content.Context;
 import  android.database.Cursor;
 import  android.database.sqlite.SQLiteOpenHelper;
 import  android.os.Build;
 import  android.support.annotation.NonNull;
 import  android.support.annotation.Nullable;

A org.gawst.asyncdb.DataSource backed by a android.database.sqlite.SQLiteOpenHelper storage that uses a Key/Value based org.gawst.asyncdb.source.DatabaseElementHandler to read/write elements from the database

Parameters:
<K> Type of the key read from the CURSOR
<V> Type of the value read from the CURSOR
<CURSOR> Wrapper around the raw Cursor read
Author(s):
Created by robUx4 on 11/01/2015.
 
 public abstract class TypedSqliteMapDataSource<K, V, CURSOR extends Cursor> implements MapDataSource<K, V, Long>, TypedDatabaseSource<LongVoid, CURSOR> {
 
 	private final TypedSqliteDataSource<MapEntry<K, V>, CURSOR> source;

Constructor. (API v14 minimum)

Parameters:
context Context used to erase the database file in case it's corrupted.
db The SQL database used to read/write data.
tableName Name of the SQL table that contains the elements to read.
databaseElementHandler Handler to transform Cursor into (K,V) pairs or (K,V) pairs to selections.
 
 	@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
 	public TypedSqliteMapDataSource(@NonNull Context context, @NonNull SQLiteOpenHelper db, @NonNull final String tableName, @NonNull final TypedMapDatabaseElementHandler<K, V, CURSOR> databaseElementHandler) {
 		this(contextdbtableNamedb.getDatabaseName(), databaseElementHandler);
 	}

Constructor.

Parameters:
context Context used to erase the database file in case it's corrupted.
db The SQL database used to read/write data.
tableName Name of the SQL table that contains the elements to read.
databaseName Name of the database file on disk, in case it's corrupted and needs to be erased.
databaseElementHandler Handler to transform Cursor into (K,V) pairs or (K,V) pairs to selections.
 
 	public TypedSqliteMapDataSource(@NonNull Context context, @NonNull SQLiteOpenHelper db, @NonNull final String tableName, @NonNull String databaseName, @NonNull final TypedMapDatabaseElementHandler<K, V, CURSOR> databaseElementHandler) {
 		if (databaseElementHandler == nullthrow new NullPointerException("null TypedMapDatabaseElementHandler in " + this);
 		this. = new TypedSqliteDataSource<MapEntry<K, V>, CURSOR>(contextdbtableNamedatabaseNamenew TypedDatabaseElementHandler<MapEntry<K,V>, CURSOR>() {
 			@NonNull
 			public String getItemSelectClause(@Nullable MapEntry<K, V> itemToSelect) {
 				return databaseElementHandler.getKeySelectClause(null == itemToSelect ? null : itemToSelect.getKey());
 			}
 
 			@NonNull
 			public String[] getItemSelectArgs(@NonNull MapEntry<K, V> itemToSelect) {
 				return databaseElementHandler.getKeySelectArgs(itemToSelect.getKey());
 			}
 
 			@NonNull
 			public MapEntry<K, V> cursorToItem(@NonNull CURSOR cursorthrows InvalidDbEntry {
 				K key = databaseElementHandler.cursorToKey(cursor);
 				return new MapEntry<K, V>(keydatabaseElementHandler.cursorToValue(cursor));
 			}
 		}) {
 			public CURSOR wrapCursor(Cursor cursor) {
 				return TypedSqliteMapDataSource.this.wrapCursor(cursor);
 			}
 		};
 	}
 
 	public Void getDatabaseId() {
 		return null;
 	}
 
 	public boolean update(MapEntry<K, V> itemToUpdate, ContentValues updateValues) {
 		return .update(itemToUpdateupdateValues);
 	}
 
 	public int delete(MapEntry<K, V> itemToDelete) {
 		return .delete(itemToDelete);
 	}
 
 	public Long insert(@NonNull ContentValues valuesthrows RuntimeException {
 		return .insert(values);
 	}
	public boolean deleteInvalidEntry(InvalidEntry invalidEntry) {
		return .deleteInvalidEntry(invalidEntry);
	}
	public CURSOR query(String[] columnsString selectionString[] selectionArgsString groupByString havingString orderByString limit) {
		return .query(columnsselectionselectionArgsgroupByhavingorderBylimit);
	}
	public int update(@NonNull ContentValues updateValuesString selectionString[] selectionArgs) {
		return .update(updateValuesselectionselectionArgs);
	}
	public int delete(String selectionString[] selectionArgs) {
		return .delete(selectionselectionArgs);
	}
	public final void queryAll(BatchReadingCallback<MapEntry<K, V>> readingCallback) {
		.queryAll(readingCallback);
	}
	public int clearAllData() {
	}
	public void eraseSource() {
	}
	public String toString() {
		return "TypedSqliteMap:"+;
	}
New to GrepCode? Check out our FAQ X