Class CursorWindow

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

    
    public class CursorWindow
    extends SQLiteClosable
                        

    A buffer containing multiple cursor rows.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • 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.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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 reuse for 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 into a 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 a double.
      short getShort(int row, int column) Gets the value of the field at the specified row and column index as a short.
      int getInt(int row, int column) Gets the value of the field at the specified row and column index as an int.
      float getFloat(int row, int column) Gets the value of the field at the specified row and column index as a float.
      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 the specified 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.

        The cursor initially has no rows or columns. Call setNumColumns to set the number of columns before adding any rows to the cursor.

        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 reuse for 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 contains relative to the entire result set of the Cursor.

        Returns:

        The zero-based start position.

      • 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 contains relative 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.

        Returns:

        The number of rows in this cursor 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, otherwise it will fail to set the number of columns if it differs from the current number of columns.

        Parameters:
        columnNum - The new number of columns.
        Returns:

        True if successful.

      • allocRow

         boolean allocRow()

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

        Returns:

        True if successful, false if the cursor window is out of memory.

      • 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.
        Returns:

        The value of the field as a byte array.

      • 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 result is null.
        • If the field is of type FIELD_TYPE_STRING, then the result is the string value.
        • If the field is of type FIELD_TYPE_INTEGER, then the result is a string representation of the integer in decimal, obtained by formatting the value with the printf family of functions using format specifier %lld.
        • If the field is of type FIELD_TYPE_FLOAT, then the result is a string representation of the floating-point value in decimal, obtained by formatting the value with the printf family of functions using format 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.
        Returns:

        The value of the field as a string.

      • copyStringToBuffer

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

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

        The buffer is populated as follows:

        • If the buffer is too small for the value to be copied, then it is automatically resized.
        • If the field is of type FIELD_TYPE_NULL, then the buffer is set to an empty string.
        • If the field is of type FIELD_TYPE_STRING, then the buffer is set to the contents of the string.
        • If the field is of type FIELD_TYPE_INTEGER, then the buffer is set to a string representation of the integer in decimal, obtained by formatting the value with the printf family of functions using format specifier %lld.
        • If the field is of type FIELD_TYPE_FLOAT, then the buffer is set to a string representation of the floating-point value in decimal, obtained by formatting the value with the printf family of functions using format 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.
        Returns:

        The value of the field as a long.

      • getDouble

         double getDouble(int row, int column)

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

        The result is determined as follows:

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
        Returns:

        The value of the field as a double.

      • getShort

         short getShort(int row, int column)

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

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

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
        Returns:

        The value of the field as a short.

      • getInt

         int getInt(int row, int column)

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

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

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
        Returns:

        The value of the field as an int.

      • getFloat

         float getFloat(int row, int column)

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

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

        Parameters:
        row - The zero-based row index.
        column - The zero-based column index.
        Returns:

        The value of the field as an float.

      • 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.
        Returns:

        True if successful.

      • 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.
        Returns:

        True if successful.

      • 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.
        Returns:

        True if successful.

      • putDouble

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

        Puts a double-precision floating point value 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.
        Returns:

        True if successful.

      • 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.
        Returns:

        True if successful.

      • isNull

         boolean isNull(int row, int column)
      • isBlob

         boolean isBlob(int row, int column)