本文整理匯總了Java中com.j256.ormlite.stmt.Where.like方法的典型用法代碼示例。如果您正苦於以下問題:Java Where.like方法的具體用法?Java Where.like怎麽用?Java Where.like使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.j256.ormlite.stmt.Where
的用法示例。
在下文中一共展示了Where.like方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadResources
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
private void loadResources() throws SQLException {
String query = txtQuery.getText();
String filter = "contains";
if (lstFilterType.getSelectedItem() != null) {
filter = lstFilterType.getSelectedItem().getValue();
}
List<StaticResource> resources = null;
// query all
if (StringUtils.isBlank(query)) {
resources = ConfigLoader.getInstance().getStaticResources().queryForAll();
} else if (StringUtils.isNoneBlank(query) && filter.equals("contains")) {
QueryBuilder<StaticResource, String> qb =
ConfigLoader.getInstance().getStaticResources().queryBuilder();
Where<StaticResource, String> w = qb.where();
w.like(Form.NAME_FIELD_NAME, "%"+query+"%");
resources = ConfigLoader.getInstance().getStaticResources().query(qb.prepare());
} else if (StringUtils.isNoneBlank(query) && filter.equals("equals")) {
resources = ConfigLoader.getInstance().getStaticResources().queryForEq(
StaticResource.NAME_FIELD, query);
}
clearSelectedItem();
lstResult.getItems().clear();
if (resources != null) {
for(StaticResource r : resources) {
Listitem item = new Listitem();
item.appendChild(new Listcell(r.getName()));
item.appendChild(new Listcell(r.getContentType()));
item.setValue(r);
lstResult.getItems().add(item);
}
}
}
示例2: txtFormName_onChanged
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@Listen("onChange = #txtFormName; onOK = #txtFormName")
public void txtFormName_onChanged() throws SQLException {
List<Form> forms = null;
lstForms.getItems().clear();
if (StringUtils.isBlank(txtFormName.getText())) {
forms = ConfigLoader.getInstance().getForms().queryForAll();
} else {
QueryBuilder<Form, String> qb = ConfigLoader.getInstance().getForms().queryBuilder();
Where<Form, String> w = qb.where();
w.like(Form.NAME_FIELD_NAME, "%"+txtFormName.getText()+"%");
forms = ConfigLoader.getInstance().getForms().query(qb.prepare());
}
if (forms != null) {
for(Form f : forms) {
Listitem item = new Listitem();
item.appendChild(new Listcell(f.getName()));
Listcell type = new Listcell();
if (f.isJoin())
type.setLabel("Join");
else
type.setLabel("Basic");
item.appendChild(type);
item.appendChild(new Listcell(f.getDBConnection().getName()));
item.setValue(f);
lstForms.getItems().add(item);
}
}
}
示例3: modWhere
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@Override
public Where<Message, Object> modWhere(Where<Message, Object> where)
throws SQLException {
where.like(Message.CONTENT_FIELD, name);
return where;
}
示例4: buildWhere
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
/**
* help to build a where to query in database;
*
* @return
*/
private PreparedQuery buildWhere(String wantDay) throws SQLException {
QueryBuilder<ClassModel,Integer> queryBuilder = classDao.queryBuilder();
queryBuilder.clear();
Where<ClassModel,Integer> where = queryBuilder.where();
where.like("day",wantDay);
return queryBuilder.prepare();
}
示例5: onCreate
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.search_results_list);
mRecyclerView.setHasFixedSize(true);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
LinearLayout noResults = (LinearLayout) findViewById(R.id.no_results);
LinearLayout results = (LinearLayout) findViewById(R.id.results);
TextView searchCount = (TextView) findViewById(R.id.search_count_text);
Intent intent = getIntent();
if (intent!=null && Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
if (query!=null) {
List<Segment> mSegments;
try {
QueryBuilder<Segment, String> queryBuilder = Global.INSTANCE.getDaoSegment().queryBuilder();
Where<Segment, String> where = queryBuilder.where();
where.like(Segment.FIELD_BODY, new SelectArg("%" + query + "%"));
mSegments = queryBuilder.query();
RecyclerView.Adapter mAdapter = new SearchAdapter(this, mSegments, query);
mRecyclerView.setAdapter(mAdapter);
noResults.setVisibility(View.GONE);
results.setVisibility(View.VISIBLE);
String searchCountText = mSegments.size()+" "+((mSegments.size()==1)?getString(R.string.search_result):getString(R.string.results))+" "+getString(R.string.found_for_this_query);
searchCount.setText(searchCountText);
} catch (SQLException e) {
Timber.e(e);
}
}
}
}
示例6: getItemsCursor
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public static Cursor getItemsCursor(CharSequence nameConstraint, Collection<ItemType> itemTypes, String itemCategory) {
try {
RuntimeExceptionDao<Item, UUID> itemDao = DsaTabApplication.getInstance().getDBHelper().getItemDao();
PreparedQuery<Item> query = null;
QueryBuilder<Item, UUID> builder = itemDao.queryBuilder();
if (TextUtils.isEmpty(nameConstraint) && (itemTypes == null || itemTypes.isEmpty())
&& TextUtils.isEmpty(itemCategory)) {
query = builder.prepare();
} else {
Where<Item, UUID> where = builder.where();
int stmtCount=0;
if (!TextUtils.isEmpty(nameConstraint)) {
String name = nameConstraint.toString();
if (name.contains("%")) {
where.like("name", nameConstraint);
} else {
where.like("name", nameConstraint + "%");
}
stmtCount++;
}
if (!TextUtils.isEmpty(itemCategory)) {
where.eq("category", itemCategory);
stmtCount++;
}
if (itemTypes != null && !itemTypes.isEmpty()) {
for (ItemType type : itemTypes) {
where.like("itemTypes", "%;" + type.name() + ";%");
}
if (itemTypes.size() > 1) {
where.or(itemTypes.size());
}
stmtCount++;
}
if (stmtCount > 1) {
where.and(stmtCount);
}
query = where.prepare();
}
Cursor cursor = getCursor(query,itemDao.getTableName());
cursor.setNotificationUri(DsaTabApplication.getInstance().getContentResolver(), ITEMS_URI);
return cursor;
} catch (SQLException e) {
Debug.e(e);
}
return null;
}