本文整理汇总了Java中com.activeandroid.query.From.and方法的典型用法代码示例。如果您正苦于以下问题:Java From.and方法的具体用法?Java From.and怎么用?Java From.and使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.activeandroid.query.From
的用法示例。
在下文中一共展示了From.and方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFilter
import com.activeandroid.query.From; //导入方法依赖的package包/类
/**
* Important, make sure that all previous complex SQL expressions are in braces!
*/
public static void addFilter(From sql, String[] columns, String filter) {
filter = prepareLikeFilter(filter);
if (org.apache.commons.lang3.StringUtils.isEmpty(filter)) {
return;
}
String whereExpression = new String();
String[] args = new String[columns.length * 2];
for (int i = 0; i < columns.length; i++) {
String column = columns[i];
if (whereExpression.length() > 0) {
whereExpression += " or ";
}
whereExpression += String.format(" %s like ? or %s like ? ", column, column);
args[i * 2] = filter + "%";
args[i * 2 + 1] = "% " + filter + "%";
}
sql.and("(" + whereExpression + ")", args);
}
示例2: checkAuditExistenceByNameAndVersion
import com.activeandroid.query.From; //导入方法依赖的package包/类
@Override
public boolean checkAuditExistenceByNameAndVersion(String name, Site site, int version) {
Timber.v("audit check existence : name %s version %d ", name, version);
From from = new Select().from(Audit.class)
.where(Audit.COLUMN_NAME + " = ?", name);
if (version != 0) {
from = from.and(Audit.COLUMN_VERSION + " = ?", version);
}
from = from.and(Audit.COLUMN_SITE + " = ?", site.getId());
boolean result = from.exists();
Timber.v("audit check existence retrieved : %b", result);
return result;
}
示例3: getAnnotationsSelectBydFilter
import com.activeandroid.query.From; //导入方法依赖的package包/类
public From getAnnotationsSelectBydFilter(String text, String collectionId) {
From res = new Select()
.from(Annotation.class);
SqlFilterUtils.addFilter(res, new String[] {"annotation"}, text);
if (!StringUtils.isEmpty(collectionId)) {
res.and("collection_id=?", collectionId);
}
res.orderBy("updated desc");
return res;
}