Class Cursor

All Implemented Interfaces:
Closeable, AutoCloseable, InFilterSupport
Direct Known Subclasses:
CalllogCursor, GrainsCursor, HeaderCursor, LineCursor, LogCursor, LogsetupCursor, PermissionsCursor, RolesCursor, SequencesCursor, SessionlogCursor, TablesCursor, UserrolesCursor

public abstract class Cursor extends BasicCursor implements InFilterSupport
Cursor class for data modification in tables.
  • Constructor Details

  • Method Details

    • create

      public static Cursor create(Table table, CallContext callContext)
      Creates a table specific cursor.
      Parameters:
      table - Cursor related table
      callContext - Call context that is used for cursor creation
      Returns:
    • create

      public static Cursor create(Table table, CallContext callContext, Set<String> fields)
      Creates a table specific cursor.
      Parameters:
      table - Cursor related table
      callContext - Call context that is used for cursor creation
      fields - Fields the cursor should operate on
      Returns:
    • insert

      public final void insert()
      Performs cursor insert into the DB.
    • tryInsert

      public final boolean tryInsert()
      Tries to perform cursor insert into the DB.
      Returns:
      TRUE if inserted successfully, otherwise - FALSE.
    • update

      public final void update()
      Performs an update of the cursor content in the DB, throwing an exception in case if a record with such key fields is not found.
    • tryUpdate

      public final boolean tryUpdate()
      Tries to perform an update of the cursor content in the DB.
      Returns:
      TRUE if updated successfully, otherwise - FALSE.
    • delete

      public final void delete()
      Deletes current record.
    • deleteAll

      public final void deleteAll()
      Deletes all records that were caught by current filter.
    • renameByValuesArray

      public final void renameByValuesArray(Object... newKeyValues)
      Changes the values of the primary key fields of the current record (renames the record), throwing an exception if the current record does not exist or a record with the new key already exists.

      Only the key fields are changed in the database: modifications of the other fields of the cursor are not saved and no triggers are called. Related records are updated according to the ON UPDATE rules of the foreign keys.

      Parameters:
      newKeyValues - new values of the key fields
    • tryRenameByValuesArray

      public final boolean tryRenameByValuesArray(Object... newKeyValues)
      Tries to change the values of the primary key fields of the current record (to rename the record).
      Parameters:
      newKeyValues - new values of the key fields
      Returns:
      true if renamed successfully, false if the current record does not exist or a record with the new key already exists.
      See Also:
    • getByValuesArray

      public final void getByValuesArray(Object... values)
      Performs a search of a record by key fields, throwing an exception if the record is not found.
      Parameters:
      values - values of the key fields
    • tryGetByValuesArray

      public boolean tryGetByValuesArray(Object... values)
      Tries to perform a search of a record by the key fields, returning a value whether the record was found or not.
      Parameters:
      values - values of the key fields
      Returns:
      true if the record is found, otherwise - false
    • tryGetCurrent

      public final boolean tryGetCurrent()
      Retrieves a record from the database that corresponds to the fields of current primary key.
      Returns:
      true if the record is retrieved, otherwise - false
    • setRecversion

      public final void setRecversion(int v)
      Sets version of the record.
      Parameters:
      v - new version.
    • getRecversion

      public final int getRecversion()
      Returns version of the record.
      Returns:
    • getMaxStrLen

      @Deprecated public final int getMaxStrLen(String name)
      Deprecated.
      Returns maximal length of the text field (if it is defined).
      Parameters:
      name - name of the text field
      Returns:
      length of the text field or -1 (minus one) if MAX is indicated instead of the length.
    • getMaxStrLen

      public final int getMaxStrLen(ColumnMeta<String> column)
      Returns maximal length of the text field .
      Parameters:
      column - the text field
      Returns:
      length of the text field or -1 (minus one) for TEXT fields.
    • init

      public final void init()
      Resets all fields of the buffer except for the key ones.
    • meta

      public final Table meta()
      Returns table description (meta information).
      Specified by:
      meta in class BasicCursor
      Returns:
    • clear

      public final void clear()
      Description copied from class: BasicCursor
      Resets filters, sorting and fully cleans the buffer.
      Overrides:
      clear in class BasicCursor
    • getXRec

      public final Cursor getXRec()
      Returns a copy of the buffer containing values that were received by the last read from the database.
      Returns:
    • setIn

      public FieldsLookup setIn(BasicCursor otherCursor)
      Specified by:
      setIn in interface InFilterSupport
    • getIn

      public In getIn()
      Specified by:
      getIn in interface InFilterSupport
    • getCurrentKeyValues

      public final Object[] getCurrentKeyValues()
      Returns an array of field values of the primary key.
      Returns: