1 /* 2 * Copyright (C) 2006 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 android.database; 18 19 import android.content.ContentResolver; 20 import android.net.Uri; 21 import android.os.Bundle; 22 23 /** 24 * Wrapper class for Cursor that delegates all calls to the actual cursor object. The primary 25 * use for this class is to extend a cursor while overriding only a subset of its methods. 26 */ 27 public class CursorWrapper implements Cursor { 28 /** @hide */ 29 protected final Cursor mCursor; 30 31 /** 32 * Creates a cursor wrapper. 33 * @param cursor The underlying cursor to wrap. 34 */ CursorWrapper(Cursor cursor)35 public CursorWrapper(Cursor cursor) { 36 mCursor = cursor; 37 } 38 39 /** 40 * Gets the underlying cursor that is wrapped by this instance. 41 * 42 * @return The wrapped cursor. 43 */ getWrappedCursor()44 public Cursor getWrappedCursor() { 45 return mCursor; 46 } 47 48 @Override close()49 public void close() { 50 mCursor.close(); 51 } 52 53 @Override isClosed()54 public boolean isClosed() { 55 return mCursor.isClosed(); 56 } 57 58 @Override getCount()59 public int getCount() { 60 return mCursor.getCount(); 61 } 62 63 @Override 64 @Deprecated deactivate()65 public void deactivate() { 66 mCursor.deactivate(); 67 } 68 69 @Override moveToFirst()70 public boolean moveToFirst() { 71 return mCursor.moveToFirst(); 72 } 73 74 @Override getColumnCount()75 public int getColumnCount() { 76 return mCursor.getColumnCount(); 77 } 78 79 @Override getColumnIndex(String columnName)80 public int getColumnIndex(String columnName) { 81 return mCursor.getColumnIndex(columnName); 82 } 83 84 @Override getColumnIndexOrThrow(String columnName)85 public int getColumnIndexOrThrow(String columnName) 86 throws IllegalArgumentException { 87 return mCursor.getColumnIndexOrThrow(columnName); 88 } 89 90 @Override getColumnName(int columnIndex)91 public String getColumnName(int columnIndex) { 92 return mCursor.getColumnName(columnIndex); 93 } 94 95 @Override getColumnNames()96 public String[] getColumnNames() { 97 return mCursor.getColumnNames(); 98 } 99 100 @Override getDouble(int columnIndex)101 public double getDouble(int columnIndex) { 102 return mCursor.getDouble(columnIndex); 103 } 104 105 @Override setExtras(Bundle extras)106 public void setExtras(Bundle extras) { 107 mCursor.setExtras(extras); 108 } 109 110 @Override getExtras()111 public Bundle getExtras() { 112 return mCursor.getExtras(); 113 } 114 115 @Override getFloat(int columnIndex)116 public float getFloat(int columnIndex) { 117 return mCursor.getFloat(columnIndex); 118 } 119 120 @Override getInt(int columnIndex)121 public int getInt(int columnIndex) { 122 return mCursor.getInt(columnIndex); 123 } 124 125 @Override getLong(int columnIndex)126 public long getLong(int columnIndex) { 127 return mCursor.getLong(columnIndex); 128 } 129 130 @Override getShort(int columnIndex)131 public short getShort(int columnIndex) { 132 return mCursor.getShort(columnIndex); 133 } 134 135 @Override getString(int columnIndex)136 public String getString(int columnIndex) { 137 return mCursor.getString(columnIndex); 138 } 139 140 @Override copyStringToBuffer(int columnIndex, CharArrayBuffer buffer)141 public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { 142 mCursor.copyStringToBuffer(columnIndex, buffer); 143 } 144 145 @Override getBlob(int columnIndex)146 public byte[] getBlob(int columnIndex) { 147 return mCursor.getBlob(columnIndex); 148 } 149 150 @Override getWantsAllOnMoveCalls()151 public boolean getWantsAllOnMoveCalls() { 152 return mCursor.getWantsAllOnMoveCalls(); 153 } 154 155 @Override isAfterLast()156 public boolean isAfterLast() { 157 return mCursor.isAfterLast(); 158 } 159 160 @Override isBeforeFirst()161 public boolean isBeforeFirst() { 162 return mCursor.isBeforeFirst(); 163 } 164 165 @Override isFirst()166 public boolean isFirst() { 167 return mCursor.isFirst(); 168 } 169 170 @Override isLast()171 public boolean isLast() { 172 return mCursor.isLast(); 173 } 174 175 @Override getType(int columnIndex)176 public int getType(int columnIndex) { 177 return mCursor.getType(columnIndex); 178 } 179 180 @Override isNull(int columnIndex)181 public boolean isNull(int columnIndex) { 182 return mCursor.isNull(columnIndex); 183 } 184 185 @Override moveToLast()186 public boolean moveToLast() { 187 return mCursor.moveToLast(); 188 } 189 190 @Override move(int offset)191 public boolean move(int offset) { 192 return mCursor.move(offset); 193 } 194 195 @Override moveToPosition(int position)196 public boolean moveToPosition(int position) { 197 return mCursor.moveToPosition(position); 198 } 199 200 @Override moveToNext()201 public boolean moveToNext() { 202 return mCursor.moveToNext(); 203 } 204 205 @Override getPosition()206 public int getPosition() { 207 return mCursor.getPosition(); 208 } 209 210 @Override moveToPrevious()211 public boolean moveToPrevious() { 212 return mCursor.moveToPrevious(); 213 } 214 215 @Override registerContentObserver(ContentObserver observer)216 public void registerContentObserver(ContentObserver observer) { 217 mCursor.registerContentObserver(observer); 218 } 219 220 @Override registerDataSetObserver(DataSetObserver observer)221 public void registerDataSetObserver(DataSetObserver observer) { 222 mCursor.registerDataSetObserver(observer); 223 } 224 225 @Override 226 @Deprecated requery()227 public boolean requery() { 228 return mCursor.requery(); 229 } 230 231 @Override respond(Bundle extras)232 public Bundle respond(Bundle extras) { 233 return mCursor.respond(extras); 234 } 235 236 @Override setNotificationUri(ContentResolver cr, Uri uri)237 public void setNotificationUri(ContentResolver cr, Uri uri) { 238 mCursor.setNotificationUri(cr, uri); 239 } 240 241 @Override getNotificationUri()242 public Uri getNotificationUri() { 243 return mCursor.getNotificationUri(); 244 } 245 246 @Override unregisterContentObserver(ContentObserver observer)247 public void unregisterContentObserver(ContentObserver observer) { 248 mCursor.unregisterContentObserver(observer); 249 } 250 251 @Override unregisterDataSetObserver(DataSetObserver observer)252 public void unregisterDataSetObserver(DataSetObserver observer) { 253 mCursor.unregisterDataSetObserver(observer); 254 } 255 } 256 257