All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pingbu.search.SearchLibraryWithData Maven / Gradle / Ivy

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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy