Corpora.java revision 21bff9bbf4286907b01d3153bff2fbd6b5ec5df8
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.database.DataSetObserver; 20 21import java.util.Collection; 22 23/** 24 * Maintains the set of available and enabled corpora. 25 */ 26public interface Corpora { 27 28 boolean isCorpusEnabled(Corpus corpus); 29 30 /** 31 * Checks if a corpus should be enabled by default. 32 */ 33 boolean isCorpusDefaultEnabled(Corpus corpus); 34 35 /** 36 * Gets all corpora, including the web corpus. 37 * 38 * @return Callers must not modify the returned collection. 39 */ 40 Collection<Corpus> getAllCorpora(); 41 42 /** 43 * Gets all enabled corpora. 44 * 45 * @return Callers must not modify the returned collection. 46 */ 47 Collection<Corpus> getEnabledCorpora(); 48 49 /** 50 * Gets a corpus by name. 51 * 52 * @return A corpus, or null. 53 */ 54 Corpus getCorpus(String name); 55 56 /** 57 * Gets the web search corpus. 58 * 59 * @return The web search corpus, or {@code null} if there is no web search corpus. 60 */ 61 Corpus getWebCorpus(); 62 63 /** 64 * Gets a source by name. 65 * 66 * @param name Source name. 67 * @return A source, or {@code null} if no source with the given name exists. 68 */ 69 Source getSource(String name); 70 71 /** 72 * Gets the corpus that contains the given source. 73 */ 74 Corpus getCorpusForSource(Source source); 75 76 /** 77 * Updates the corpora. 78 */ 79 void update(); 80 81 /** 82 * Registers an observer that is called when corpus set changes. 83 * 84 * @param observer gets notified when the data set changes. 85 */ 86 void registerDataSetObserver(DataSetObserver observer); 87 88 /** 89 * Unregisters an observer that has previously been registered with 90 * {@link #registerDataSetObserver(DataSetObserver)} 91 * 92 * @param observer the observer to unregister. 93 */ 94 void unregisterDataSetObserver(DataSetObserver observer); 95} 96