The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.net.Uri; |
| 21 | import android.os.Bundle; |
| 22 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | /** |
Andrew Stadler | 46baf53 | 2010-06-21 10:23:46 -0700 | [diff] [blame] | 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. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | public class CursorWrapper implements Cursor { |
Jeff Brown | 825c513 | 2011-10-12 16:11:30 -0700 | [diff] [blame] | 28 | /** @hide */ |
| 29 | protected final Cursor mCursor; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
Jeff Brown | 825c513 | 2011-10-12 16:11:30 -0700 | [diff] [blame] | 31 | /** |
| 32 | * Creates a cursor wrapper. |
| 33 | * @param cursor The underlying cursor to wrap. |
| 34 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | public CursorWrapper(Cursor cursor) { |
| 36 | mCursor = cursor; |
| 37 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
Andrew Stadler | 46baf53 | 2010-06-21 10:23:46 -0700 | [diff] [blame] | 39 | /** |
Jeff Brown | 7ce7452 | 2011-10-07 13:29:37 -0700 | [diff] [blame] | 40 | * Gets the underlying cursor that is wrapped by this instance. |
| 41 | * |
| 42 | * @return The wrapped cursor. |
Andrew Stadler | 46baf53 | 2010-06-21 10:23:46 -0700 | [diff] [blame] | 43 | */ |
| 44 | public Cursor getWrappedCursor() { |
| 45 | return mCursor; |
| 46 | } |
| 47 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | public void close() { |
| 49 | mCursor.close(); |
| 50 | } |
| 51 | |
| 52 | public boolean isClosed() { |
| 53 | return mCursor.isClosed(); |
| 54 | } |
| 55 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | public int getCount() { |
| 57 | return mCursor.getCount(); |
| 58 | } |
| 59 | |
| 60 | public void deactivate() { |
| 61 | mCursor.deactivate(); |
| 62 | } |
| 63 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | public boolean moveToFirst() { |
| 65 | return mCursor.moveToFirst(); |
| 66 | } |
| 67 | |
| 68 | public int getColumnCount() { |
| 69 | return mCursor.getColumnCount(); |
| 70 | } |
| 71 | |
| 72 | public int getColumnIndex(String columnName) { |
| 73 | return mCursor.getColumnIndex(columnName); |
| 74 | } |
| 75 | |
| 76 | public int getColumnIndexOrThrow(String columnName) |
| 77 | throws IllegalArgumentException { |
| 78 | return mCursor.getColumnIndexOrThrow(columnName); |
| 79 | } |
| 80 | |
| 81 | public String getColumnName(int columnIndex) { |
| 82 | return mCursor.getColumnName(columnIndex); |
| 83 | } |
| 84 | |
| 85 | public String[] getColumnNames() { |
| 86 | return mCursor.getColumnNames(); |
| 87 | } |
| 88 | |
| 89 | public double getDouble(int columnIndex) { |
| 90 | return mCursor.getDouble(columnIndex); |
| 91 | } |
| 92 | |
| 93 | public Bundle getExtras() { |
| 94 | return mCursor.getExtras(); |
| 95 | } |
| 96 | |
| 97 | public float getFloat(int columnIndex) { |
| 98 | return mCursor.getFloat(columnIndex); |
| 99 | } |
| 100 | |
| 101 | public int getInt(int columnIndex) { |
| 102 | return mCursor.getInt(columnIndex); |
| 103 | } |
| 104 | |
| 105 | public long getLong(int columnIndex) { |
| 106 | return mCursor.getLong(columnIndex); |
| 107 | } |
| 108 | |
| 109 | public short getShort(int columnIndex) { |
| 110 | return mCursor.getShort(columnIndex); |
| 111 | } |
| 112 | |
| 113 | public String getString(int columnIndex) { |
| 114 | return mCursor.getString(columnIndex); |
| 115 | } |
| 116 | |
| 117 | public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { |
| 118 | mCursor.copyStringToBuffer(columnIndex, buffer); |
| 119 | } |
| 120 | |
| 121 | public byte[] getBlob(int columnIndex) { |
| 122 | return mCursor.getBlob(columnIndex); |
| 123 | } |
| 124 | |
| 125 | public boolean getWantsAllOnMoveCalls() { |
| 126 | return mCursor.getWantsAllOnMoveCalls(); |
| 127 | } |
| 128 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | public boolean isAfterLast() { |
| 130 | return mCursor.isAfterLast(); |
| 131 | } |
| 132 | |
| 133 | public boolean isBeforeFirst() { |
| 134 | return mCursor.isBeforeFirst(); |
| 135 | } |
| 136 | |
| 137 | public boolean isFirst() { |
| 138 | return mCursor.isFirst(); |
| 139 | } |
| 140 | |
| 141 | public boolean isLast() { |
| 142 | return mCursor.isLast(); |
| 143 | } |
| 144 | |
Vasu Nori | 8b0dd7d | 2010-05-18 11:54:31 -0700 | [diff] [blame] | 145 | public int getType(int columnIndex) { |
| 146 | return mCursor.getType(columnIndex); |
| 147 | } |
| 148 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 149 | public boolean isNull(int columnIndex) { |
| 150 | return mCursor.isNull(columnIndex); |
| 151 | } |
| 152 | |
| 153 | public boolean moveToLast() { |
| 154 | return mCursor.moveToLast(); |
| 155 | } |
| 156 | |
| 157 | public boolean move(int offset) { |
| 158 | return mCursor.move(offset); |
| 159 | } |
| 160 | |
| 161 | public boolean moveToPosition(int position) { |
| 162 | return mCursor.moveToPosition(position); |
| 163 | } |
| 164 | |
| 165 | public boolean moveToNext() { |
| 166 | return mCursor.moveToNext(); |
| 167 | } |
| 168 | |
| 169 | public int getPosition() { |
| 170 | return mCursor.getPosition(); |
| 171 | } |
| 172 | |
| 173 | public boolean moveToPrevious() { |
| 174 | return mCursor.moveToPrevious(); |
| 175 | } |
| 176 | |
| 177 | public void registerContentObserver(ContentObserver observer) { |
| 178 | mCursor.registerContentObserver(observer); |
| 179 | } |
| 180 | |
| 181 | public void registerDataSetObserver(DataSetObserver observer) { |
| 182 | mCursor.registerDataSetObserver(observer); |
| 183 | } |
| 184 | |
| 185 | public boolean requery() { |
| 186 | return mCursor.requery(); |
| 187 | } |
| 188 | |
| 189 | public Bundle respond(Bundle extras) { |
| 190 | return mCursor.respond(extras); |
| 191 | } |
| 192 | |
| 193 | public void setNotificationUri(ContentResolver cr, Uri uri) { |
| 194 | mCursor.setNotificationUri(cr, uri); |
| 195 | } |
| 196 | |
Dianne Hackborn | c87c92e | 2013-05-14 13:44:29 -0700 | [diff] [blame] | 197 | public Uri getNotificationUri() { |
| 198 | return mCursor.getNotificationUri(); |
| 199 | } |
| 200 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | public void unregisterContentObserver(ContentObserver observer) { |
| 202 | mCursor.unregisterContentObserver(observer); |
| 203 | } |
| 204 | |
| 205 | public void unregisterDataSetObserver(DataSetObserver observer) { |
| 206 | mCursor.unregisterDataSetObserver(observer); |
| 207 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 208 | } |
| 209 | |