Home | History | Annotate | Download | only in quicksearchbox
      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 
     17 package com.android.quicksearchbox;
     18 
     19 import android.database.DataSetObserver;
     20 
     21 import java.util.Collection;
     22 
     23 /**
     24  * A suggestion cursor that delegates all methods to another SuggestionCursor.
     25  */
     26 public class SuggestionCursorWrapper extends AbstractSuggestionCursorWrapper {
     27 
     28     private final SuggestionCursor mCursor;
     29 
     30     public SuggestionCursorWrapper(String userQuery, SuggestionCursor cursor) {
     31         super(userQuery);
     32         mCursor = cursor;
     33     }
     34 
     35     public void close() {
     36         if (mCursor != null) {
     37             mCursor.close();
     38         }
     39     }
     40 
     41     public int getCount() {
     42         return mCursor == null ? 0 : mCursor.getCount();
     43     }
     44 
     45     public int getPosition() {
     46         return mCursor == null ? 0 : mCursor.getPosition();
     47     }
     48 
     49     public void moveTo(int pos) {
     50         if (mCursor != null) {
     51             mCursor.moveTo(pos);
     52         }
     53     }
     54 
     55     public boolean moveToNext() {
     56         if (mCursor != null) {
     57             return mCursor.moveToNext();
     58         } else {
     59             return false;
     60         }
     61     }
     62 
     63     public void registerDataSetObserver(DataSetObserver observer) {
     64         if (mCursor != null) {
     65             mCursor.registerDataSetObserver(observer);
     66         }
     67     }
     68 
     69     public void unregisterDataSetObserver(DataSetObserver observer) {
     70         if (mCursor != null) {
     71             mCursor.unregisterDataSetObserver(observer);
     72         }
     73     }
     74 
     75     @Override
     76     protected SuggestionCursor current() {
     77         return mCursor;
     78     }
     79 
     80     public Collection<String> getExtraColumns() {
     81         return mCursor.getExtraColumns();
     82     }
     83 
     84 }
     85