Package 

Class CursorWindow

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable

    
    public class CursorWindow
    extends SQLiteClosable
                        

    A buffer containing multiple cursor rows.

    • Constructor Summary

      Constructors 
      Constructor Description
      CursorWindow(String name) Creates a new empty cursor with default cursor size (currently 2MB)
      CursorWindow(String name, int windowSizeBytes) Creates a new empty cursor window and gives it a name.
    • Method Summary

      Modifier and Type Method Description
      String getName() Gets the name of this cursor window, never null.
      void clear() Clears out the existing contents of the window, making it safe to reusefor new data.
      int getStartPosition() Gets the start position of this cursor window.
      void setStartPosition(int pos) Sets the start position of this cursor window.
      int getNumRows() Gets the number of rows in this window.
      boolean setNumColumns(int columnNum) Sets the number of columns in this window.
      boolean allocRow() Allocates a new row at the end of this cursor window.
      void freeLastRow() Frees the last row in this cursor window.
      int getType(int row, int column) Returns the type of the field at the specified row and column index.
      Array<byte> getBlob(int row, int column) Gets the value of the field at the specified row and column index as a byte array.
      String getString(int row, int column) Gets the value of the field at the specified row and column index as a string.
      void copyStringToBuffer(int row, int column, CharArrayBuffer buffer) Copies the text of the field at the specified row and column index intoa CharArrayBuffer.
      long getLong(int row, int column) Gets the value of the field at the specified row and column index as a long.
      double getDouble(int row, int column) Gets the value of the field at the specified row and column index as adouble.
      short getShort(int row, int column) Gets the value of the field at the specified row and column index as ashort.
      int getInt(int row, int column) Gets the value of the field at the specified row and column index as anint.
      float getFloat(int row, int column) Gets the value of the field at the specified row and column index as afloat.
      boolean putBlob(Array<byte> value, int row, int column) Copies a byte array into the field at the specified row and column index.
      boolean putString(String value, int row, int column) Copies a string into the field at the specified row and column index.
      boolean putLong(long value, int row, int column) Puts a long integer into the field at the specified row and column index.
      boolean putDouble(double value, int row, int column) Puts a double-precision floating point value into the field at thespecified row and column index.
      boolean putNull(int row, int column) Puts a null value into the field at the specified row and column index.
      boolean isNull(int row, int column)
      boolean isBlob(int row, int column)
      String toString()
      int getWindowSizeBytes()
      • Methods inherited from class net.zetetic.database.sqlcipher.SQLiteClosable

        acquireReference, close, releaseReference, releaseReferenceFromContainer
      • Methods inherited from class java.io.Closeable

        close
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CursorWindow

        CursorWindow(String name)
        Creates a new empty cursor with default cursor size (currently 2MB)
      • CursorWindow

        CursorWindow(String name, int windowSizeBytes)
        Creates a new empty cursor window and gives it a name.
        Parameters:
        name - The name of the cursor window, or null if none.
        windowSizeBytes - Size of cursor window in bytes.Note: Memory is dynamically allocated as data rows are added tothe window.
    • Method Detail

      • getName

         String getName()

        Gets the name of this cursor window, never null.

      • clear

         void clear()

        Clears out the existing contents of the window, making it safe to reusefor new data.

        The start position (getStartPosition), number of rows (getNumRows),and number of columns in the cursor are all reset to zero.

      • getStartPosition

         int getStartPosition()

        Gets the start position of this cursor window.

        The start position is the zero-based index of the first row that this window containsrelative to the entire result set of the Cursor.

      • setStartPosition

         void setStartPosition(int pos)

        Sets the start position of this cursor window.

        The start position is the zero-based index of the first row that this window containsrelative to the entire result set of the Cursor.

        Parameters:
        pos - The new zero-based start position.
      • getNumRows

         int getNumRows()

        Gets the number of rows in this window.

      • setNumColumns

         boolean setNumColumns(int columnNum)

        Sets the number of columns in this window.

        This method must be called before any rows are added to the window, otherwiseit will fail to set the number of columns if it differs from the current numberof columns.

        Parameters:
        columnNum - The new number of columns.
      • allocRow

         boolean allocRow()

        Allocates a new row at the end of this cursor window.

      • freeLastRow

         void freeLastRow()

        Frees the last row in this cursor window.

      • getBlob

         Array<byte> getBlob(int row, int column)

        Gets the value of the field at the specified row and column index as a byte array.

        The result is determined as follows:

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
      • getString

         String getString(int row, int column)

        Gets the value of the field at the specified row and column index as a string.

        The result is determined as follows:

        • If the field is of type FIELD_TYPE_NULL, then the resultis null.
        • If the field is of type FIELD_TYPE_STRING, then the resultis the string value.
        • If the field is of type FIELD_TYPE_INTEGER, then the resultis a string representation of the integer in decimal, obtained by formatting thevalue with the printf family of functions usingformat specifier %lld.
        • If the field is of type FIELD_TYPE_FLOAT, then the resultis a string representation of the floating-point value in decimal, obtained byformatting the value with the printf family of functions usingformat specifier %g.
        • If the field is of type FIELD_TYPE_BLOB, then a SQLiteException is thrown.
        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
      • copyStringToBuffer

         void copyStringToBuffer(int row, int column, CharArrayBuffer buffer)

        Copies the text of the field at the specified row and column index intoa CharArrayBuffer.

        The buffer is populated as follows:

        • If the buffer is too small for the value to be copied, then it isautomatically resized.
        • If the field is of type FIELD_TYPE_NULL, then the bufferis set to an empty string.
        • If the field is of type FIELD_TYPE_STRING, then the bufferis set to the contents of the string.
        • If the field is of type FIELD_TYPE_INTEGER, then the bufferis set to a string representation of the integer in decimal, obtained by formatting thevalue with the printf family of functions usingformat specifier %lld.
        • If the field is of type FIELD_TYPE_FLOAT, then the buffer isset to a string representation of the floating-point value in decimal, obtained byformatting the value with the printf family of functions usingformat specifier %g.
        • If the field is of type FIELD_TYPE_BLOB, then a SQLiteException is thrown.
        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
        buffer - The CharArrayBuffer to hold the string.
      • getLong

         long getLong(int row, int column)

        Gets the value of the field at the specified row and column index as a long.

        The result is determined as follows:

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
      • getDouble

         double getDouble(int row, int column)

        Gets the value of the field at the specified row and column index as adouble.

        The result is determined as follows:

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
      • getShort

         short getShort(int row, int column)

        Gets the value of the field at the specified row and column index as ashort.

        The result is determined by invoking getLong and converting theresult to short.

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
      • getInt

         int getInt(int row, int column)

        Gets the value of the field at the specified row and column index as anint.

        The result is determined by invoking getLong and converting theresult to int.

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
      • getFloat

         float getFloat(int row, int column)

        Gets the value of the field at the specified row and column index as afloat.

        The result is determined by invoking getDouble and converting theresult to float.

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
      • putBlob

         boolean putBlob(Array<byte> value, int row, int column)

        Copies a byte array into the field at the specified row and column index.

        Parameters:
        value - The value to store.
        row - The zero-based row index.
        column - The zero-based column index.
      • putString

         boolean putString(String value, int row, int column)

        Copies a string into the field at the specified row and column index.

        Parameters:
        value - The value to store.
        row - The zero-based row index.
        column - The zero-based column index.
      • putLong

         boolean putLong(long value, int row, int column)

        Puts a long integer into the field at the specified row and column index.

        Parameters:
        value - The value to store.
        row - The zero-based row index.
        column - The zero-based column index.
      • putDouble

         boolean putDouble(double value, int row, int column)

        Puts a double-precision floating point value into the field at thespecified row and column index.

        Parameters:
        value - The value to store.
        row - The zero-based row index.
        column - The zero-based column index.
      • putNull

         boolean putNull(int row, int column)

        Puts a null value into the field at the specified row and column index.

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
      • isNull

         boolean isNull(int row, int column)
      • isBlob

         boolean isBlob(int row, int column)