Home | History | Annotate | Download | only in database
      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      */
     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      */
     44     public Cursor getWrappedCursor() {
     45         return mCursor;
     46     }
     47 
     48     public void close() {
     49         mCursor.close();
     50     }
     51 
     52     public boolean isClosed() {
     53         return mCursor.isClosed();
     54     }
     55 
     56     public int getCount() {
     57         return mCursor.getCount();
     58     }
     59 
     60     public void deactivate() {
     61         mCursor.deactivate();
     62     }
     63 
     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 
    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 
    145     public int getType(int columnIndex) {
    146         return mCursor.getType(columnIndex);
    147     }
    148 
    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 
    197     public Uri getNotificationUri() {
    198         return mCursor.getNotificationUri();
    199     }
    200 
    201     public void unregisterContentObserver(ContentObserver observer) {
    202         mCursor.unregisterContentObserver(observer);
    203     }
    204 
    205     public void unregisterDataSetObserver(DataSetObserver observer) {
    206         mCursor.unregisterDataSetObserver(observer);
    207     }
    208 }
    209 
    210