1/*
2 * Copyright (C) 2010 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 */
16package com.android.quicksearchbox;
17
18import android.content.ComponentName;
19import android.database.Cursor;
20
21import com.android.quicksearchbox.google.GoogleSource;
22
23import java.util.Collection;
24
25public class CursorBackedSourceResult extends CursorBackedSuggestionCursor
26        implements SourceResult {
27
28    private final GoogleSource mSource;
29
30    public CursorBackedSourceResult(GoogleSource source, String userQuery) {
31        this(source, userQuery, null);
32    }
33
34    public CursorBackedSourceResult(GoogleSource source, String userQuery, Cursor cursor) {
35        super(userQuery, cursor);
36        mSource = source;
37    }
38
39    public GoogleSource getSource() {
40        return mSource;
41    }
42
43    @Override
44    public GoogleSource getSuggestionSource() {
45        return mSource;
46    }
47
48    @Override
49    public ComponentName getSuggestionIntentComponent() {
50        return mSource.getIntentComponent();
51    }
52
53    public boolean isSuggestionShortcut() {
54        return false;
55    }
56
57    public boolean isHistorySuggestion() {
58        return false;
59    }
60
61    @Override
62    public String toString() {
63        return mSource + "[" + getUserQuery() + "]";
64    }
65
66    @Override
67    public SuggestionExtras getExtras() {
68        if (mCursor == null) return null;
69        return CursorBackedSuggestionExtras.createExtrasIfNecessary(mCursor, getPosition());
70    }
71
72    public Collection<String> getExtraColumns() {
73        if (mCursor == null) return null;
74        return CursorBackedSuggestionExtras.getExtraColumns(mCursor);
75    }
76
77}