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