Package ru.curs.celesta.dbutils
Class Cursor
- java.lang.Object
-
- ru.curs.celesta.dbutils.CsqlBasicDataAccessor<CallContext>
-
- ru.curs.celesta.dbutils.BasicDataAccessor
-
- ru.curs.celesta.dbutils.BasicCursor
-
- ru.curs.celesta.dbutils.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 Summary
Constructors Constructor Description Cursor(CallContext context)Cursor(CallContext context, ColumnMeta<?>... columns)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclear()Resets filters, sorting and fully cleans the buffer.static Cursorcreate(Table table, CallContext callContext)Creates a table specific cursor.static Cursorcreate(Table table, CallContext callContext, Set<String> fields)Creates a table specific cursor.voiddelete()Deletes current record.voiddeleteAll()Deletes all records that were caught by current filter.voidgetByValuesArray(Object... values)Performs a search of a record by key fields, throwing an exception if the record is not found.Object[]getCurrentKeyValues()Returns an array of field values of the primary key.IngetIn()intgetMaxStrLen(String name)Deprecated.intgetMaxStrLen(ColumnMeta<String> column)Returns maximal length of the text field .intgetRecversion()Returns version of the record.CursorgetXRec()Returns a copy of the buffer containing values that were received by the last read from the database.voidinit()Resets all fields of the buffer except for the key ones.voidinsert()Performs cursor insert into the DB.Tablemeta()Returns table description (meta information).FieldsLookupsetIn(BasicCursor otherCursor)voidsetRecversion(int v)Sets version of the record.booleantryGetByValuesArray(Object... values)Tries to perform a search of a record by the key fields, returning a value whether the record was found or not.booleantryGetCurrent()Retrieves a record from the database that corresponds to the fields of current primary key.booleantryInsert()Tries to perform cursor insert into the DB.booleantryUpdate()Tries to perform an update of the cursor content in the DB.voidupdate()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.-
Methods inherited from class ru.curs.celesta.dbutils.BasicCursor
asCSVLine, canDelete, canInsert, canModify, clearBuffer, copyFieldsFrom, copyFiltersFrom, copyOrderFrom, count, descOrders, findSet, first, getBufferCopy, getComplexFilter, getCurrentValues, getOrderBy, getValue, isEquivalent, last, limit, navigate, navigate, next, nextInSet, orderBy, orderBy, orderBy, orderByColumnNames, position, previous, reset, setComplexFilter, setFilter, setFilter, setRange, setRange, setRange, setRange, setRange, setRange, setValue, tryFindSet, tryFirst, tryLast
-
Methods inherited from class ru.curs.celesta.dbutils.BasicDataAccessor
canRead
-
Methods inherited from class ru.curs.celesta.dbutils.CsqlBasicDataAccessor
callContext, close, isClosed
-
-
-
-
Constructor Detail
-
Cursor
public Cursor(CallContext context)
-
Cursor
public Cursor(CallContext context, ColumnMeta<?>... columns)
-
-
Method Detail
-
create
public static Cursor create(Table table, CallContext callContext)
Creates a table specific cursor.- Parameters:
table- Cursor related tablecallContext- 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 tablecallContext- Call context that is used for cursor creationfields- 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:
TRUEif 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:
TRUEif 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.
-
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:
trueif 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:
trueif 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:
metain classBasicCursor- Returns:
-
clear
public final void clear()
Description copied from class:BasicCursorResets filters, sorting and fully cleans the buffer.- Overrides:
clearin classBasicCursor
-
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:
setInin interfaceInFilterSupport
-
getIn
public In getIn()
- Specified by:
getInin interfaceInFilterSupport
-
getCurrentKeyValues
public final Object[] getCurrentKeyValues()
Returns an array of field values of the primary key.- Returns:
-
-