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