Class BasicCursor

All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
Cursor, MaterializedViewCursor, ParameterizedViewCursor, ReadOnlyTableCursor, ViewCursor

public abstract class BasicCursor extends BasicDataAccessor
Base cursor class for reading data from views.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    BasicCursor(CallContext context, Set<String> fields)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final String
    Returns current state of the cursor in form of CSV string with comma delimiters.
    boolean
    Whether the session has rights to delete data from current table.
    boolean
    Whether the session has rights to insert data into current table.
    boolean
    Whether the session has rights to modify data of current table.
    void
    Resets filters, sorting and fully cleans the buffer.
    final void
    clearBuffer(boolean withKeys)
    Clears current cursor buffer (sets all fields to null).
    abstract void
    Copy field values from a cursor of the same type.
    final void
    Gets a copy of filters along with values of limit (offset and rowcount) from a cursor of the same type.
    final void
    Gets a copy of orderings from a cursor of the same type.
    final int
    Returns number of records in the filtered data set.
    boolean[]
    Returns mask of DESC orders.
    final void
    Moves to the first record in the filtered data set causing an error in the case if the transition was not successful.
    final void
    The same as tryFirst() but causes an error if no record is found.
    getBufferCopy(CallContext context, Collection<? extends ColumnMeta<?>> fetchedFields)
    Clones the current cursor.
    final String
    Returns (reformatted) expression of the complex filter in CelestaSQL dialect.
    final Object[]
    Returns an array of field values.
    final String
    Returns "order by" clause for the cursor.
    final Object
    Returns a value of a field by its name.
    boolean
    Checks if filters and sorting are equivalent for this and other cursor.
    final void
    The same as tryLast() but causes an error if no record is found.
    final void
    limit(long offset, long rowCount)
    Sets filter to a range of records returned by the cursor.
    Metadata object (table, view or sequence) on the basis of which current data object was created.
    boolean
    navigate(String command)
    Navigation method (step-by-step transition in the filtered and sorted data set).
    boolean
    navigate(String command, long offset)
    Navigate forwards or backwards for the given offset.
    final boolean
    The same as navigate(">").
    final boolean
    Moves to the next record in the sorted data set.
    final void
    Clears sorting.
    final void
    orderBy(String... names)
    Deprecated.
    final void
    orderBy(ColumnMeta<?>... columns)
    Sets sorting.
    Returns column names that are in sorting.
    final int
    Method that returns total count of rows that precede the current one in the set.
    final boolean
    The same as navigate("invalid input: '&lt'").
    final void
    Resets filters and sorting.
    final void
    Sets complex condition to the data set.
    final void
    setFilter(String name, String value)
    Deprecated.
    final void
    setFilter(ColumnMeta<?> column, String value)
    Sets filter to the field.
    final void
    Deprecated.
    final void
    setRange(String name, Object value)
    Deprecated.
    final void
    setRange(String name, Object valueFrom, Object valueTo)
    Deprecated.
    final void
    setRange(ColumnMeta<?> column)
    Resets any filter on a field.
    final <T> void
    setRange(ColumnMeta<? super T> column, T value)
    Sets range from a single value on the field.
    final <T> void
    setRange(ColumnMeta<? super T> column, T valueFrom, T valueTo)
    Sets range from..to on the field.
    final void
    setValue(String name, Object value)
    Sets value of a field by its name.
    final boolean
    Moves to the first record in the filtered data set and returns information about the success of transition.
    final boolean
    The same as navigate("-").
    final boolean
    The same as navigate("+").

    Methods inherited from class ru.curs.celesta.dbutils.BasicDataAccessor

    canRead

    Methods inherited from class ru.curs.celesta.dbutils.CsqlBasicDataAccessor

    callContext, close, isClosed

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • meta

      public abstract DataGrainElement meta()
      Description copied from class: CsqlBasicDataAccessor
      Metadata object (table, view or sequence) on the basis of which current data object was created.
      Specified by:
      meta in class CsqlBasicDataAccessor<CallContext>
    • canInsert

      public boolean canInsert()
      Whether the session has rights to insert data into current table.
      Returns:
      true, if current record can be inserted
    • canModify

      public boolean canModify()
      Whether the session has rights to modify data of current table.
      Returns:
      true, if current record can be updated
    • canDelete

      public boolean canDelete()
      Whether the session has rights to delete data from current table.
      Returns:
      true, if current record can be deleted
    • getOrderBy

      public final String getOrderBy()
      Returns "order by" clause for the cursor.
      Returns:
    • orderByColumnNames

      public String[] orderByColumnNames()
      Returns column names that are in sorting.
      Returns:
    • descOrders

      public boolean[] descOrders()
      Returns mask of DESC orders.
      Returns:
    • tryFindSet

      public final boolean tryFindSet()
      Moves to the first record in the filtered data set and returns information about the success of transition.
      Returns:
      true if the transition was successful, false if there are no records in the data set.
    • tryFirst

      public final boolean tryFirst()
      The same as navigate("-").
      Returns:
    • first

      public final void first()
      The same as tryFirst() but causes an error if no record is found.
    • tryLast

      public final boolean tryLast()
      The same as navigate("+").
      Returns:
    • last

      public final void last()
      The same as tryLast() but causes an error if no record is found.
    • next

      public final boolean next()
      The same as navigate(">").
      Returns:
    • previous

      public final boolean previous()
      The same as navigate("invalid input: '&lt'").
      Returns:
    • findSet

      public final void findSet()
      Moves to the first record in the filtered data set causing an error in the case if the transition was not successful.
    • asCSVLine

      public final String asCSVLine()
      Returns current state of the cursor in form of CSV string with comma delimiters.
      Returns:
    • nextInSet

      public final boolean nextInSet()
      Moves to the next record in the sorted data set. Returns false if the end of the set is reached.
      Returns:
    • setRange

      @Deprecated public final void setRange(String name)
      Deprecated.
      Resets any filter on a field.
      Parameters:
      name - field name
    • setRange

      public final void setRange(ColumnMeta<?> column)
      Resets any filter on a field.
      Parameters:
      column - field column
    • setRange

      @Deprecated public final void setRange(String name, Object value)
      Deprecated.
      Sets range from a single value on the field.
      Parameters:
      name - field name
      value - value along which filtering is performed
    • setRange

      public final <T> void setRange(ColumnMeta<? super T> column, T value)
      Sets range from a single value on the field.
      Type Parameters:
      T - Java type of value
      Parameters:
      column - field column
      value - value along which filtering is performed
    • setRange

      @Deprecated public final void setRange(String name, Object valueFrom, Object valueTo)
      Deprecated.
      Sets range from..to on the field.
      Parameters:
      name - field name
      valueFrom - value from
      valueTo - value to
    • setRange

      public final <T> void setRange(ColumnMeta<? super T> column, T valueFrom, T valueTo)
      Sets range from..to on the field.
      Type Parameters:
      T - Java type of value
      Parameters:
      column - field column
      valueFrom - value from
      valueTo - value to
    • setFilter

      @Deprecated public final void setFilter(String name, String value)
      Deprecated.
      Sets filter to the field.
      Parameters:
      name - field name
      value - filter
    • setFilter

      public final void setFilter(ColumnMeta<?> column, String value)
      Sets filter to the field.
      Parameters:
      column - field column
      value - filter
    • setComplexFilter

      public final void setComplexFilter(String condition)
      Sets complex condition to the data set.
      Parameters:
      condition - condition that corresponds to WHERE clause.
    • getComplexFilter

      public final String getComplexFilter()
      Returns (reformatted) expression of the complex filter in CelestaSQL dialect.
    • limit

      public final void limit(long offset, long rowCount)
      Sets filter to a range of records returned by the cursor.
      Parameters:
      offset - number of records that has to be skipped (0 - start from the beginning).
      rowCount - maximal number of records that has to be returned (0 - return all records).
    • reset

      public final void reset()
      Resets filters and sorting.
    • orderBy

      @Deprecated public final void orderBy(String... names)
      Deprecated.
      Sets sorting.
      Parameters:
      names - array of fields for sorting
    • orderBy

      public final void orderBy(ColumnMeta<?>... columns)
      Sets sorting.
      Parameters:
      columns - columns array for sorting
    • orderBy

      public final void orderBy()
      Clears sorting.
    • clear

      public void clear()
      Resets filters, sorting and fully cleans the buffer.
      Specified by:
      clear in class CsqlBasicDataAccessor<CallContext>
    • count

      public final int count()
      Returns number of records in the filtered data set.
      Returns:
    • position

      public final int position()
      Method that returns total count of rows that precede the current one in the set. This method is intended for internal use by GridDriver. Since rows counting is a resource-consuming operation, usage of this method should be avoided.
      Returns:
    • copyFiltersFrom

      public final void copyFiltersFrom(BasicCursor c)
      Gets a copy of filters along with values of limit (offset and rowcount) from a cursor of the same type.
      Parameters:
      c - cursor the filters of which have to be copied
    • copyOrderFrom

      public final void copyOrderFrom(BasicCursor c)
      Gets a copy of orderings from a cursor of the same type.
      Parameters:
      c - cursor the sortings of which have to be copied
    • isEquivalent

      public boolean isEquivalent(BasicCursor c)
      Checks if filters and sorting are equivalent for this and other cursor.
      Parameters:
      c - Other cursor.
      Returns:
    • setValue

      public final void setValue(String name, Object value)
      Sets value of a field by its name. This is needed for an indirect filling of the cursor with data from Java (in Python, naturally, there is setattr(...) procedure for this goal).
      Parameters:
      name - field name
      value - field value
    • getValue

      public final Object getValue(String name)
      Returns a value of a field by its name. This is needed for accessing data when using generic cursors, such as Cursor.
      Parameters:
      name - field name
      Returns:
    • copyFieldsFrom

      public abstract void copyFieldsFrom(BasicCursor from)
      Copy field values from a cursor of the same type.
      Parameters:
      from - cursor that field values have to be copied from
    • getCurrentValues

      public final Object[] getCurrentValues()
      Returns an array of field values.
      Returns:
    • clearBuffer

      public final void clearBuffer(boolean withKeys)
      Clears current cursor buffer (sets all fields to null).
      Parameters:
      withKeys - if true, all fields will be cleared, otherwise, primary key fields will remain unchanged.
    • getBufferCopy

      public final BasicCursor getBufferCopy(CallContext context, Collection<? extends ColumnMeta<?>> fetchedFields)
      Clones the current cursor.
      Parameters:
      context - call context
      fetchedFields - list of fields to be fetched