Corpus.java revision 5691f9062b2a558ba39c700d65bc522d397ebc75
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 android.content.Intent; 20import android.graphics.drawable.Drawable; 21import android.net.Uri; 22import android.os.Bundle; 23 24import java.util.Collection; 25 26/** 27 * A corpus is a user-visible set of suggestions. A corpus gets suggestions from one 28 * or more sources. 29 * 30 * Objects that implement this interface should override {@link Object#equals(Object)} 31 * and {@link Object#hashCode()} so that they can be used as keys in hash maps. 32 */ 33public interface Corpus { 34 35 /** 36 * Gets the localized, human-readable label for this corpus. 37 */ 38 CharSequence getLabel(); 39 40 /** 41 * Gets the icon for this corpus. 42 */ 43 Drawable getCorpusIcon(); 44 45 /** 46 * Gets the icon URI for this corpus. 47 */ 48 Uri getCorpusIconUri(); 49 50 /** 51 * Gets the description to use for this corpus in system search settings. 52 */ 53 CharSequence getSettingsDescription(); 54 55 /** 56 * Gets the search hint text for this corpus. 57 */ 58 CharSequence getHint(); 59 60 /** 61 * Gets suggestions from this corpus. 62 * 63 * @param query The user query. 64 * @param queryLimit An advisory maximum number of results that the source should return. 65 * @return The suggestion results. 66 */ 67 CorpusResult getSuggestions(String query, int queryLimit); 68 69 /** 70 * Gets the unique name for this corpus. 71 */ 72 String getName(); 73 74 int getQueryThreshold(); 75 76 boolean queryAfterZeroResults(); 77 78 boolean voiceSearchEnabled(); 79 80 Intent createSearchIntent(String query, Bundle appData); 81 82 Intent createVoiceSearchIntent(Bundle appData); 83 84 SuggestionData createSearchShortcut(String query); 85 86 boolean isWebCorpus(); 87 88 /** 89 * Gets the sources that this corpus uses. 90 */ 91 Collection<Source> getSources(); 92} 93