public class SelectionBuilder extends QueryBuilder<SelectionBuilder,android.database.Cursor>
ContentResolver
and
Uri
.
Cursor crs = QueryBuilder.selectFrom( rslv, uri ) .allColumns() .where( "entity_id=?", sID ) .execute() ;
Cursor crs = QueryBuilder.selectFrom( rslv, uri ) .columns( "entity_id", "name", "start_ts", "stop_ts" ) .where( "start_ts>?", TimeUtils.now() ) .orderBy( "name", ContentUtils.QUERY_ORDER_ASCENDING ) .execute() ;
ContentUtils.QUERY_ORDER_ASCENDING
,
ContentUtils.QUERY_ORDER_DESCENDING
QueryBuilder.ExecutionException, QueryBuilder.UnboundException
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
LOG_TAG |
protected java.util.LinkedHashMap<java.lang.String,java.lang.String> |
m_mapSortSpec
The mapping of sortable columns to sorting directions, if any.
|
protected java.util.Vector<java.lang.String> |
m_vColumns
The columns to be included in the result set.
|
m_asExplicitWhereParams, m_rslv, m_sExplicitWhereFormat, m_uri, m_valsToWrite
Constructor and Description |
---|
SelectionBuilder() |
SelectionBuilder(android.content.ContentResolver rslv,
android.net.Uri uri) |
SelectionBuilder(android.content.Context ctx,
android.net.Uri uri) |
Modifier and Type | Method and Description |
---|---|
SelectionBuilder |
allColumns()
Specifies that all columns should be included in the result set.
|
SelectionBuilder |
columns(java.util.Collection<java.lang.String> asColumns)
Sets the columns that should be included in the result set.
|
SelectionBuilder |
columns(java.lang.String... asColumns)
Sets the columns that should be included in the result set.
|
android.database.Cursor |
executeOrCancel(android.os.CancellationSignal sig)
(API 16+) Selects results from the data context, while
allowing the query to be cancelled in response to the specified signal.
|
android.database.Cursor |
executeOrCancel(android.content.ContentResolver rslv,
android.net.Uri uri,
android.os.CancellationSignal sig)
(API 16+) Selects results from the data context, while
allowing the query to be cancelled in response to the specified signal.
|
android.database.Cursor |
executeQuery(android.content.ContentResolver rslv,
android.net.Uri uri)
Selects results from the data context.
|
protected java.lang.String[] |
getColumns()
Generates the list of columns to be included in the result set, as an
array of strings to be passed to
ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String) . |
protected java.lang.String |
getSortSpecString()
Generates the selection's sort criteria as a string, to be supplied to
ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String) . |
protected SelectionBuilder |
initColumns()
Initializes the vector of columns to be included in the result set.
|
protected SelectionBuilder |
initSortSpec()
Initializes the map of sortable columns to sorting directions.
|
SelectionBuilder |
orderBy(java.lang.String sColumn)
Adds a sorting specification to the query.
|
SelectionBuilder |
orderBy(java.lang.String sColumn,
java.lang.String sDirection)
Adds a sorting specification to the query.
|
android.os.Bundle |
toBundle()
Creates a bundle that describes the query itself, not the result
set that it would select.
|
delete, deleteFrom, deleteFrom, execute, executeOn, executeOn, getContentResolver, getWhereFormat, getWhereParams, insert, insertInto, insertInto, onDataSource, onDataSource, select, selectFrom, selectFrom, setValues, update, update, update, validateDataContextBinding, where, where, where
protected static final java.lang.String LOG_TAG
protected java.util.Vector<java.lang.String> m_vColumns
protected java.util.LinkedHashMap<java.lang.String,java.lang.String> m_mapSortSpec
LinkedHashMap
because we want to preserve the order in
which sort keys were added to the order spec. (#52)public SelectionBuilder(android.content.ContentResolver rslv, android.net.Uri uri)
public SelectionBuilder(android.content.Context ctx, android.net.Uri uri)
public SelectionBuilder()
protected SelectionBuilder initColumns()
protected SelectionBuilder initSortSpec()
public SelectionBuilder allColumns()
public SelectionBuilder columns(java.lang.String... asColumns)
null
to this method;
use allColumns()
instead.asColumns
- the names of the columns to be includedpublic SelectionBuilder columns(java.util.Collection<java.lang.String> asColumns)
null
to this method;
use allColumns()
instead.asColumns
- the names of the columns to be includedprotected java.lang.String[] getColumns()
ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String)
.null
if all columns are to be
includedpublic SelectionBuilder orderBy(java.lang.String sColumn, java.lang.String sDirection)
sColumn
- the column to be added to the sort specificationsDirection
- the directionContentUtils.QUERY_ORDER_ASCENDING
,
ContentUtils.QUERY_ORDER_DESCENDING
public SelectionBuilder orderBy(java.lang.String sColumn)
sColumn
- the column to be added to the sort specificationprotected java.lang.String getSortSpecString()
ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String)
.public android.database.Cursor executeQuery(android.content.ContentResolver rslv, android.net.Uri uri)
executeQuery
in class QueryBuilder<SelectionBuilder,android.database.Cursor>
rslv
- the resolver through which the query should be executeduri
- the URI at which the query should be executedpublic android.database.Cursor executeOrCancel(android.os.CancellationSignal sig) throws QueryBuilder.UnboundException, QueryBuilder.ExecutionException
sig
- the signal which would cancel the queryQueryBuilder.UnboundException
QueryBuilder.ExecutionException
public android.database.Cursor executeOrCancel(android.content.ContentResolver rslv, android.net.Uri uri, android.os.CancellationSignal sig) throws QueryBuilder.UnboundException, QueryBuilder.ExecutionException
executeOrCancel(CancellationSignal)
.rslv
- the resolver through which the query should be executeduri
- the URI at which the query should be executedsig
- the signal which would cancel the queryUnboundException
- if the data context binding is inadequateExecutionException
- if the underlying query failsQueryBuilder.UnboundException
QueryBuilder.ExecutionException
public android.os.Bundle toBundle()
String
uri
String
[] columns
String
where_format
WHERE
clause.String
[] where_params
WHERE
clause format string.
String
[] order_by_cols
(optional)String
[] order_by_dirs
(optional)order_by_cols
.