ShortcutRepository.java revision 6d5cbd67f7a5f824babb5c892b0f30bfd9f4ff23
1/* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.quicksearchbox; 18 19import java.util.List; 20import java.util.Map; 21 22/** 23 * Holds information about shortcuts (results the user has clicked on before), and returns 24 * appropriate shortcuts for a given query. 25 */ 26public interface ShortcutRepository { 27 28 /** 29 * Checks whether there is any stored history. 30 */ 31 boolean hasHistory(); 32 33 /** 34 * Clears all shortcut history. 35 */ 36 void clearHistory(); 37 38 /** 39 * Closes any database connections etc held by this object. 40 */ 41 void close(); 42 43 /** 44 * Reports a click on a suggestion. 45 */ 46 void reportClick(SuggestionCursor suggestions, int position); 47 48 /** 49 * Gets shortcuts for a query. 50 * 51 * @param query The query. May be empty. 52 * @param allowedCorpora The corpora to get shortcuts for. 53 * @param maxShortcuts The maximum number of shortcuts to return. 54 * @return A cursor containing shortcutted results for the query. 55 */ 56 SuggestionCursor getShortcutsForQuery(String query, List<Corpus> allowedCorpora, 57 int maxShortcuts); 58 59 /** 60 * @return A map for corpus name to score. A higher score means that the corpus 61 * is more important. 62 */ 63 Map<String,Integer> getCorpusScores(); 64} 65