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