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