Package ru.curs.celesta.dbutils
Class BasicCursor
java.lang.Object
ru.curs.celesta.dbutils.CsqlBasicDataAccessor<CallContext>
ru.curs.celesta.dbutils.BasicDataAccessor
ru.curs.celesta.dbutils.BasicCursor
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
Cursor,MaterializedViewCursor,ParameterizedViewCursor,ReadOnlyTableCursor,ViewCursor
Base cursor class for reading data from views.
-
Constructor Summary
ConstructorsConstructorDescriptionBasicCursor(CallContext context) BasicCursor(CallContext context, Set<String> fields) -
Method Summary
Modifier and TypeMethodDescriptionfinal StringReturns current state of the cursor in form of CSV string with comma delimiters.booleanWhether the session has rights to delete data from current table.booleanWhether the session has rights to insert data into current table.booleanWhether the session has rights to modify data of current table.voidclear()Resets filters, sorting and fully cleans the buffer.final voidclearBuffer(boolean withKeys) Clears current cursor buffer (sets all fields to null).abstract voidcopyFieldsFrom(BasicCursor from) Copy field values from a cursor of the same type.final voidGets a copy of filters along with values of limit (offset and rowcount) from a cursor of the same type.final voidGets a copy of orderings from a cursor of the same type.final intcount()Returns number of records in the filtered data set.boolean[]Returns mask of DESC orders.final voidfindSet()Moves to the first record in the filtered data set causing an error in the case if the transition was not successful.final voidfirst()The same as tryFirst() but causes an error if no record is found.final BasicCursorgetBufferCopy(CallContext context, Collection<? extends ColumnMeta<?>> fetchedFields) Clones the current cursor.final StringReturns (reformatted) expression of the complex filter in CelestaSQL dialect.final Object[]Returns an array of field values.final StringReturns "order by" clause for the cursor.final ObjectReturns a value of a field by its name.booleanChecks if filters and sorting are equivalent for this and other cursor.final voidlast()The same as tryLast() but causes an error if no record is found.final voidlimit(long offset, long rowCount) Sets filter to a range of records returned by the cursor.abstract DataGrainElementmeta()Metadata object (table, view or sequence) on the basis of which current data object was created.booleanNavigation method (step-by-step transition in the filtered and sorted data set).booleanNavigate forwards or backwards for the given offset.final booleannext()The same as navigate(">").final booleanMoves to the next record in the sorted data set.final voidorderBy()Clears sorting.final voidDeprecated.final voidorderBy(ColumnMeta<?>... columns) Sets sorting.String[]Returns column names that are in sorting.final intposition()Method that returns total count of rows that precede the current one in the set.final booleanprevious()The same as navigate("invalid input: '<'").final voidreset()Resets filters and sorting.final voidsetComplexFilter(String condition) Sets complex condition to the data set.final voidDeprecated.final voidsetFilter(ColumnMeta<?> column, String value) Sets filter to the field.final voidDeprecated.final voidDeprecated.final voidDeprecated.final voidsetRange(ColumnMeta<?> column) Resets any filter on a field.final <T> voidsetRange(ColumnMeta<? super T> column, T value) Sets range from a single value on the field.final <T> voidsetRange(ColumnMeta<? super T> column, T valueFrom, T valueTo) Sets range from..to on the field.final voidSets value of a field by its name.final booleanMoves to the first record in the filtered data set and returns information about the success of transition.final booleantryFirst()The same as navigate("-").final booleantryLast()The same as navigate("+").Methods inherited from class ru.curs.celesta.dbutils.BasicDataAccessor
canReadMethods inherited from class ru.curs.celesta.dbutils.CsqlBasicDataAccessor
callContext, close, isClosed
-
Constructor Details
-
BasicCursor
-
BasicCursor
-
-
Method Details
-
meta
Description copied from class:CsqlBasicDataAccessorMetadata object (table, view or sequence) on the basis of which current data object was created.- Specified by:
metain classCsqlBasicDataAccessor<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
Returns "order by" clause for the cursor.- Returns:
-
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:
trueif the transition was successful,falseif 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: '<'").- 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
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. Returnsfalseif the end of the set is reached.- Returns:
-
setRange
Deprecated.Resets any filter on a field.- Parameters:
name- field name
-
setRange
Resets any filter on a field.- Parameters:
column- field column
-
setRange
Deprecated.Sets range from a single value on the field.- Parameters:
name- field namevalue- value along which filtering is performed
-
setRange
Sets range from a single value on the field.- Type Parameters:
T- Java type of value- Parameters:
column- field columnvalue- value along which filtering is performed
-
setRange
Deprecated.Sets range from..to on the field.- Parameters:
name- field namevalueFrom- value fromvalueTo- value to
-
setRange
Sets range from..to on the field.- Type Parameters:
T- Java type of value- Parameters:
column- field columnvalueFrom- value fromvalueTo- value to
-
setFilter
Deprecated.Sets filter to the field.- Parameters:
name- field namevalue- filter
-
setFilter
Sets filter to the field.- Parameters:
column- field columnvalue- filter
-
setComplexFilter
Sets complex condition to the data set.- Parameters:
condition- condition that corresponds to WHERE clause.
-
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.Sets sorting.- Parameters:
names- array of fields for sorting
-
orderBy
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:
clearin classCsqlBasicDataAccessor<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
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
Gets a copy of orderings from a cursor of the same type.- Parameters:
c- cursor the sortings of which have to be copied
-
isEquivalent
Checks if filters and sorting are equivalent for this and other cursor.- Parameters:
c- Other cursor.- Returns:
-
setValue
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 issetattr(...)procedure for this goal).- Parameters:
name- field namevalue- field value
-
getValue
Returns a value of a field by its name. This is needed for accessing data when using generic cursors, such asCursor.- Parameters:
name- field name- Returns:
-
copyFieldsFrom
Copy field values from a cursor of the same type.- Parameters:
from- cursor that field values have to be copied from
-
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 contextfetchedFields- list of fields to be fetched
-