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