Cursor (2)
いっちゃん下から読んでみます。
CrossProcessCursor
ここから。全部引用しちゃえ。
package android.database; public interface CrossProcessCursor extends Cursor{ /** * returns a pre-filled window, return NULL if no such window */ CursorWindow getWindow(); /** * copies cursor data into the window start at pos */ void fillWindow(int pos, CursorWindow winow); /** * This function is called every time the cursor is successfully scrolled * to a new position, giving the subclass a chance to update any state it * may have. If it returns false the move function will also do so and the * cursor will scroll to the beforeFirst position. * * @param oldPosition the position that we're moving from * @param newPosition the position that we're moving to * @return true if the move is successful, false otherwise */ boolean onMove(int oldPosition, int newPosition); }
- android.database.CrossProcessCursor か
- Cursor を継承したインターフェースになってます。
- 追加されているのは以下
- CursorWindow getWindos()
- void fillWindow(int pos, CursorWindow window)
- boolean onMove(int oldPosition, int newPosition)
- CursorWindow は別途確認
- コメントにもありますが_window_という概念の理解が必要な模様
- なんとなく Cursor の中の現在可視状態なコレクション的ソレなのかなぁ
- 追加されているのは以下
詳細スルーして一つ上に行きます。
AbstractCursor
- これも android.database パケジ
クラス定義の直上に以下なコメントがあります。
/** * This is an abstract cursor class that handles a lot of the common code * that all cursors need to deal with and is provided for convenience reasons. */
むむ。ちなみにこの AbstractCursor は interface ではなくて abstract class になってます。ので、上記コメントにもあるように具体的な記述もあるはず。
public abstract class AbstractCursor implements CrossProcessCursor { private static final String TAG = "Cursor"; DataSetObservable mDataSetObservable = new DataSetObservable(); ContentObservable mContentObservable = new ContentObservable();
とりあえず、DataSetObservable と ContentObservable と CursorWindow について確認入れてみたいと思います。
うーん
英語のドキュメントしかないな。なんとなくは理解できるんですが、具体的な部分は追い掛けてりゃだんだん明かになってきたりしないかな (を
とりあえず CursorWindow については、A buffer containing multiple cursor rows. との事でよく分からんかったのですが、super class が android.database.sqlite.SQLiteClosable との事だとか getter/setter に渡す情報が 行/列 なソレだとか微妙。
あと Observable なナニについても
- Observable が DataSetObservable と COntentObservable の super class
- 何かのリストを登録、登録解除する模様
- 例えば DataSetObservable は DataSetObserver というソレについて、通知というか callback の呼び出しを行なっている
- android の callback な仕組みって基本これなのだろうか
例えば DataSetObservable の notifyChanged を呼び出したら、登録されている DataSetObserver の onChanged メソドが呼び出される模様。
とりあえず続きを確認していきます。以下のいくつかは_Method that may optionally be implemented by subclasses_というコメントがあり、保険で中身が記述されていると見ておきます。
- CursorWindow getWindow()
- super class から継承したメソドではない模様
- int getColumnCount()
- Return total number of columns
- void deactivate()
- Deactivates the Cursor, making all calls on it fail until requery is called. Inactive Cursors use fewer resources than active Cursors.
- void deactivateInternal()
- internal って言いつつ public だし
- おそらくこれも AbstractCursor で初出のはず
- boolean requery()
- Performs the query that created the cursor again, refreshing its contents. This may be done at any time, including after a call to deactivate.
- boolean isClosed()
- return true if the cursor is closed
- void close()
- む、ContentObservable#unregisterAll() してますな
- Closes the Cursor, releasing all of its resources and making ig completely invalid. Unlike deactivate() a call to requery() will not make the Cursor valid again.
- boolean commitUpdates()
- deprecated となってます
- use the ContentResolver update methods instead of the Cursor update methods. との記述あり
- boolean deleteRow()
- これも deprecated
- use ContentResolver#delete(Uri, String, String[])
- boolean onMove()
- Cursor.java に記述ナシ
- void copyStringToBuffer()
- Retrieves the requested column text and stores it in the buffer provided. If the buffer size is not sufficient, a new char buffer will be allocated and assigned to CharArrayBuffer.data
で、implementation というコメント以下でコンストラクタが定義されてたりなんかします。あ、上記に列挙したソレについては、super class にあるコメントを拾って追記してみようかな。
再開
もう少しだけ。AbstractCursor の subclass で実装を期待されている操作は以下か。
- int getCount
- String[] getColumnNames()
- String getString(int column)
- short getShort(int column)
- int getInt(int column)
- long getLong(int column)
- float getFloat(int column)
- double getDouble(int column)
- boolean isNull(int column)
- byte[] getBlob(int column)
これらに加えて上で列挙した操作、という事になる模様。元気があれば AbstractCursor の上記以外なメソドの中身について確認してみたいと思いますが、どうしたものやら。