pingbu.search.SearchLibraryWithData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pingbu-search Show documentation
Show all versions of pingbu-search Show documentation
A multiple condition search library
The newest version!
package pingbu.search;
import java.util.*;
/**
* 包含条目数据的搜索库
*
* @author pingbu
*/
public class SearchLibraryWithData extends SearchLibrary {
private final Map> mItems = new HashMap<>();
/**
* 添加一个索引条目
*
* @param id 条目id
* @param item 索引条目,为一组字段名与字段值的映射
*/
public void addItem(final int id, final Map item) {
mItems.put(id, item);
for (final Map.Entry field : item.entrySet()) {
final SearchIndex index = getField(field.getKey());
if (index != null)
index.addItem(id, field.getValue());
}
}
/**
* 添加一个索引条目
*
* @param id 条目id
* @return 索引条目,为一组字段名与字段值的映射
*/
public Map getItem(final int id) {
return mItems.get(id);
}
}