Home | History | Annotate | Download | only in database
      1 /*
      2  * Copyright (C) 2008 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 /**
     20  * A cross process cursor is an extension of a {@link Cursor} that also supports
     21  * usage from remote processes.
     22  * <p>
     23  * The contents of a cross process cursor are marshalled to the remote process by
     24  * filling {@link CursorWindow} objects using {@link #fillWindow}.  As an optimization,
     25  * the cursor can provide a pre-filled window to use via {@link #getWindow} thereby
     26  * obviating the need to copy the data to yet another cursor window.
     27  */
     28 public interface CrossProcessCursor extends Cursor {
     29     /**
     30      * Returns a pre-filled window that contains the data within this cursor.
     31      * <p>
     32      * In particular, the window contains the row indicated by {@link Cursor#getPosition}.
     33      * The window's contents are automatically scrolled whenever the current
     34      * row moved outside the range covered by the window.
     35      * </p>
     36      *
     37      * @return The pre-filled window, or null if none.
     38      */
     39     CursorWindow getWindow();
     40 
     41     /**
     42      * Copies cursor data into the window.
     43      * <p>
     44      * Clears the window and fills it with data beginning at the requested
     45      * row position until all of the data in the cursor is exhausted
     46      * or the window runs out of space.
     47      * </p><p>
     48      * The filled window uses the same row indices as the original cursor.
     49      * For example, if you fill a window starting from row 5 from the cursor,
     50      * you can query the contents of row 5 from the window just by asking it
     51      * for row 5 because there is a direct correspondence between the row indices
     52      * used by the cursor and the window.
     53      * </p><p>
     54      * The current position of the cursor, as returned by {@link #getPosition},
     55      * is not changed by this method.
     56      * </p>
     57      *
     58      * @param position The zero-based index of the first row to copy into the window.
     59      * @param window The window to fill.
     60      */
     61     void fillWindow(int position, CursorWindow window);
     62 
     63     /**
     64      * This function is called every time the cursor is successfully scrolled
     65      * to a new position, giving the subclass a chance to update any state it
     66      * may have.  If it returns false the move function will also do so and the
     67      * cursor will scroll to the beforeFirst position.
     68      * <p>
     69      * This function should be called by methods such as {@link #moveToPosition(int)},
     70      * so it will typically not be called from outside of the cursor class itself.
     71      * </p>
     72      *
     73      * @param oldPosition The position that we're moving from.
     74      * @param newPosition The position that we're moving to.
     75      * @return True if the move is successful, false otherwise.
     76      */
     77     boolean onMove(int oldPosition, int newPosition);
     78 }
     79