本文整理汇总了Java中com.google.samples.apps.iosched.util.SelectionBuilder类的典型用法代码示例。如果您正苦于以下问题:Java SelectionBuilder类的具体用法?Java SelectionBuilder怎么用?Java SelectionBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectionBuilder类属于com.google.samples.apps.iosched.util包,在下文中一共展示了SelectionBuilder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTagsFilter
import com.google.samples.apps.iosched.util.SelectionBuilder; //导入依赖的package包/类
/** Adds the tags filter query parameter to the given builder. */
private void addTagsFilter(SelectionBuilder builder, String tagsFilter) {
// Note: for context, remember that session queries are done on a join of sessions
// and the sessions_tags relationship table, and are GROUP'ed BY the session ID.
String[] requiredTags = tagsFilter.split(",");
if (requiredTags.length == 0) {
// filtering by 0 tags -- no-op
return;
} else if (requiredTags.length == 1) {
// filtering by only one tag, so a simple WHERE clause suffices
builder.where(Tags.TAG_ID + "=?", requiredTags[0]);
} else {
// Filtering by multiple tags, so we must add a WHERE clause with an IN operator,
// and add a HAVING statement to exclude groups that fall short of the number
// of required tags. For example, if requiredTags is { "X", "Y", "Z" }, and a certain
// session only has tags "X" and "Y", it will be excluded by the HAVING statement.
String questionMarkTuple = makeQuestionMarkTuple(requiredTags.length);
builder.where(Tags.TAG_ID + " IN " + questionMarkTuple, requiredTags);
builder.having("COUNT(" + Qualified.SESSIONS_SESSION_ID + ") >= " + requiredTags.length);
}
}
示例2: update
import com.google.samples.apps.iosched.util.SelectionBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
String accountName = getCurrentAccountName(uri, false);
LOGV(TAG, "update(uri=" + uri + ", values=" + values.toString()
+ ", account=" + accountName + ")");
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
final int match = sUriMatcher.match(uri);
if (match == SEARCH_INDEX) {
// update the search index
ScheduleDatabase.updateSessionSearchIndex(db);
return 1;
}
final SelectionBuilder builder = buildSimpleSelection(uri);
if (match == MY_SCHEDULE) {
values.remove(MySchedule.MY_SCHEDULE_ACCOUNT_NAME);
builder.where(MySchedule.MY_SCHEDULE_ACCOUNT_NAME + "=?", accountName);
}
int retVal = builder.where(selection, selectionArgs).update(db, values);
notifyChange(uri);
return retVal;
}
示例3: delete
import com.google.samples.apps.iosched.util.SelectionBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
String accountName = getCurrentAccountName(uri, false);
LOGV(TAG, "delete(uri=" + uri + ", account=" + accountName + ")");
if (uri.equals(ScheduleContract.BASE_CONTENT_URI)) {
// Handle whole database deletes (e.g. when signing out)
deleteDatabase();
notifyChange(uri);
return 1;
}
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
final SelectionBuilder builder = buildSimpleSelection(uri);
final int match = sUriMatcher.match(uri);
if (match == MY_SCHEDULE) {
builder.where(MySchedule.MY_SCHEDULE_ACCOUNT_NAME + "=?", accountName);
}
int retVal = builder.where(selection, selectionArgs).delete(db);
notifyChange(uri);
return retVal;
}
示例4: addTagsFilter
import com.google.samples.apps.iosched.util.SelectionBuilder; //导入依赖的package包/类
/**
* Adds the {@code tagsFilter} query parameter to the given {@code builder}. This query
* parameter is used by the {@link com.google.samples.apps.iosched.explore.ExploreSessionsActivity}
* when the user makes a selection containing multiple filters.
*/
private void addTagsFilter(SelectionBuilder builder, String tagsFilter, String numCategories) {
// Note: for context, remember that session queries are done on a join of sessions
// and the sessions_tags relationship table, and are GROUP'ed BY the session ID.
String[] requiredTags = tagsFilter.split(",");
if (requiredTags.length == 0) {
// filtering by 0 tags -- no-op
return;
} else if (requiredTags.length == 1) {
// filtering by only one tag, so a simple WHERE clause suffices
builder.where(Tags.TAG_ID + "=?", requiredTags[0]);
} else {
// Filtering by multiple tags, so we must add a WHERE clause with an IN operator,
// and add a HAVING statement to exclude groups that fall short of the number
// of required tags. For example, if requiredTags is { "X", "Y", "Z" }, and a certain
// session only has tags "X" and "Y", it will be excluded by the HAVING statement.
int categories = 1;
if (numCategories != null && TextUtils.isDigitsOnly(numCategories)) {
try {
categories = Integer.parseInt(numCategories);
LOGD(TAG, "Categories being used " + categories);
} catch (Exception ex) {
LOGE(TAG, "exception parsing categories ", ex);
}
}
String questionMarkTuple = makeQuestionMarkTuple(requiredTags.length);
builder.where(Tags.TAG_ID + " IN " + questionMarkTuple, requiredTags);
builder.having(
"COUNT(" + Qualified.SESSIONS_SESSION_ID + ") >= " + categories);
}
}
示例5: update
import com.google.samples.apps.iosched.util.SelectionBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
String accountName = getCurrentAccountName(uri, false);
LOGV(TAG, "update(uri=" + uri + ", values=" + values.toString()
+ ", account=" + accountName + ")");
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
ScheduleUriEnum matchingUriEnum = mUriMatcher.matchUri(uri);
if (matchingUriEnum == ScheduleUriEnum.SEARCH_INDEX) {
// update the search index
ScheduleDatabase.updateSessionSearchIndex(db);
return 1;
}
final SelectionBuilder builder = buildSimpleSelection(uri);
if (matchingUriEnum == ScheduleUriEnum.MY_SCHEDULE) {
values.remove(MySchedule.MY_SCHEDULE_ACCOUNT_NAME);
builder.where(MySchedule.MY_SCHEDULE_ACCOUNT_NAME + "=?", accountName);
}
if (matchingUriEnum == ScheduleUriEnum.MY_VIEWED_VIDEOS) {
values.remove(MyViewedVideos.MY_VIEWED_VIDEOS_ACCOUNT_NAME);
builder.where(MyViewedVideos.MY_VIEWED_VIDEOS_ACCOUNT_NAME + "=?", accountName);
}
if (matchingUriEnum == ScheduleUriEnum.MY_FEEDBACK_SUBMITTED) {
values.remove(MyFeedbackSubmitted.MY_FEEDBACK_SUBMITTED_ACCOUNT_NAME);
builder.where(MyFeedbackSubmitted.MY_FEEDBACK_SUBMITTED_ACCOUNT_NAME + "=?",
accountName);
}
int retVal = builder.where(selection, selectionArgs).update(db, values);
notifyChange(uri);
return retVal;
}
示例6: delete
import com.google.samples.apps.iosched.util.SelectionBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
String accountName = getCurrentAccountName(uri, false);
LOGV(TAG, "delete(uri=" + uri + ", account=" + accountName + ")");
if (uri == ScheduleContract.BASE_CONTENT_URI) {
// Handle whole database deletes (e.g. when signing out)
deleteDatabase();
notifyChange(uri);
return 1;
}
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
final SelectionBuilder builder = buildSimpleSelection(uri);
ScheduleUriEnum matchingUriEnum = mUriMatcher.matchUri(uri);
if (matchingUriEnum == ScheduleUriEnum.MY_SCHEDULE) {
builder.where(MySchedule.MY_SCHEDULE_ACCOUNT_NAME + "=?", accountName);
}
if (matchingUriEnum == ScheduleUriEnum.MY_VIEWED_VIDEOS) {
builder.where(MyViewedVideos.MY_VIEWED_VIDEOS_ACCOUNT_NAME + "=?", accountName);
}
if (matchingUriEnum == ScheduleUriEnum.MY_FEEDBACK_SUBMITTED) {
builder.where(
MyFeedbackSubmitted.MY_FEEDBACK_SUBMITTED_ACCOUNT_NAME + "=?", accountName);
}
int retVal = builder.where(selection, selectionArgs).delete(db);
notifyChange(uri);
return retVal;
}
示例7: addTagsFilter
import com.google.samples.apps.iosched.util.SelectionBuilder; //导入依赖的package包/类
/**
* Adds the {@code tagsFilter} query parameter to the given {@code builder}. This query
* parameter is used when the user makes a selection containing multiple filters.
*/
private void addTagsFilter(SelectionBuilder builder, String tagsFilter, String numCategories) {
// Note: for context, remember that session queries are done on a join of sessions
// and the sessions_tags relationship table, and are GROUP'ed BY the session ID.
String[] requiredTags = tagsFilter.split(",");
if (requiredTags.length == 0) {
// filtering by 0 tags -- no-op
return;
} else if (requiredTags.length == 1) {
// filtering by only one tag, so a simple WHERE clause suffices
builder.where(Tags.TAG_ID + "=?", requiredTags[0]);
} else {
// Filtering by multiple tags, so we must add a WHERE clause with an IN operator,
// and add a HAVING statement to exclude groups that fall short of the number
// of required tags. For example, if requiredTags is { "X", "Y", "Z" }, and a certain
// session only has tags "X" and "Y", it will be excluded by the HAVING statement.
int categories = 1;
if (numCategories != null && TextUtils.isDigitsOnly(numCategories)) {
try {
categories = Integer.parseInt(numCategories);
LOGD(TAG, "Categories being used " + categories);
} catch (Exception ex) {
LOGE(TAG, "exception parsing categories ", ex);
}
}
String questionMarkTuple = makeQuestionMarkTuple(requiredTags.length);
builder.where(Tags.TAG_ID + " IN " + questionMarkTuple, requiredTags);
builder.having(
"COUNT(" + Qualified.SESSIONS_SESSION_ID + ") >= " + categories);
}
}
示例8: delete
import com.google.samples.apps.iosched.util.SelectionBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
String accountName = getCurrentAccountName(uri, false);
LOGV(TAG, "delete(uri=" + uri + ", account=" + accountName + ")");
if (uri == ScheduleContract.BASE_CONTENT_URI) {
// Handle whole database deletes (e.g. when signing out)
deleteDatabase();
notifyChange(uri);
return 1;
}
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
final SelectionBuilder builder = buildSimpleSelection(uri);
ScheduleUriEnum matchingUriEnum = mUriMatcher.matchUri(uri);
if (matchingUriEnum == ScheduleUriEnum.MY_SCHEDULE) {
builder.where(MySchedule.MY_SCHEDULE_ACCOUNT_NAME + "=?", accountName);
}
if (matchingUriEnum == ScheduleUriEnum.MY_RESERVATIONS) {
builder.where(MyReservations.MY_RESERVATION_ACCOUNT_NAME + "=?", accountName);
}
if (matchingUriEnum == ScheduleUriEnum.MY_VIEWED_VIDEOS) {
builder.where(MyViewedVideos.MY_VIEWED_VIDEOS_ACCOUNT_NAME + "=?", accountName);
}
if (matchingUriEnum == ScheduleUriEnum.MY_FEEDBACK_SUBMITTED) {
builder.where(
MyFeedbackSubmitted.MY_FEEDBACK_SUBMITTED_ACCOUNT_NAME + "=?", accountName);
}
int retVal = builder.where(selection, selectionArgs).delete(db);
if (retVal > 0) {
notifyChange(uri);
}
return retVal;
}
示例9: update
import com.google.samples.apps.iosched.util.SelectionBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
String accountName = getCurrentAccountName(uri, false);
Uri notifyUri = null;
LOGV(TAG, "update(uri=" + uri + ", values=" + values.toString()
+ ", account=" + accountName + ")");
boolean isAccountUpdateAllowed = ScheduleContractHelper.isAccountUpdateAllowed(uri);
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
ScheduleUriEnum matchingUriEnum = mUriMatcher.matchUri(uri);
if (matchingUriEnum == ScheduleUriEnum.SEARCH_INDEX) {
// update the search index
ScheduleDatabase.updateSessionSearchIndex(db);
return 1;
}
final SelectionBuilder builder = buildSimpleSelection(uri);
if (matchingUriEnum == ScheduleUriEnum.SESSIONS_ID_RELATED) {
// update not supported
return 0;
}
if (matchingUriEnum == ScheduleUriEnum.MY_SCHEDULE) {
if (!isAccountUpdateAllowed) {
values.remove(MySchedule.MY_SCHEDULE_ACCOUNT_NAME);
}
builder.where(MySchedule.MY_SCHEDULE_ACCOUNT_NAME + "=?", accountName);
// Also notify session listeners.
notifyUri = Sessions.CONTENT_MY_SCHEDULE_URI;
}
if (matchingUriEnum == ScheduleUriEnum.MY_RESERVATIONS) {
values.remove(MyReservations.MY_RESERVATION_ACCOUNT_NAME);
builder.where(MyReservations.MY_RESERVATION_ACCOUNT_NAME + "=?", accountName);
}
if (matchingUriEnum == ScheduleUriEnum.MY_VIEWED_VIDEOS) {
values.remove(MyViewedVideos.MY_VIEWED_VIDEOS_ACCOUNT_NAME);
builder.where(MyViewedVideos.MY_VIEWED_VIDEOS_ACCOUNT_NAME + "=?", accountName);
}
if (matchingUriEnum == ScheduleUriEnum.MY_FEEDBACK_SUBMITTED) {
if (!isAccountUpdateAllowed) {
values.remove(MyFeedbackSubmitted.MY_FEEDBACK_SUBMITTED_ACCOUNT_NAME);
}
builder.where(MyFeedbackSubmitted.MY_FEEDBACK_SUBMITTED_ACCOUNT_NAME + "=?",
accountName);
}
int retVal = builder.where(selection, selectionArgs).update(db, values);
if (retVal > 0) {
notifyChange(uri);
if (null != notifyUri) notifyChange(notifyUri);
}
return retVal;
}