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 void
clear()
Resets filters, sorting and fully cleans the buffer.static Cursor
create(Table table, CallContext callContext)
Creates a table specific cursor.static Cursor
create(Table table, CallContext callContext, Set<String> fields)
Creates a table specific cursor.void
delete()
Deletes current record.void
deleteAll()
Deletes all records that were caught by current filter.void
getByValuesArray(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.In
getIn()
int
getMaxStrLen(String name)
Deprecated.int
getMaxStrLen(ColumnMeta<String> column)
Returns maximal length of the text field .int
getRecversion()
Returns version of the record.Cursor
getXRec()
Returns a copy of the buffer containing values that were received by the last read from the database.void
init()
Resets all fields of the buffer except for the key ones.void
insert()
Performs cursor insert into the DB.Table
meta()
Returns table description (meta information).FieldsLookup
setIn(BasicCursor otherCursor)
void
setRecversion(int v)
Sets version of the record.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.boolean
tryGetCurrent()
Retrieves a record from the database that corresponds to the fields of current primary key.boolean
tryInsert()
Tries to perform cursor insert into the DB.boolean
tryUpdate()
Tries to perform an update of the cursor content in the DB.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.-
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:
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.
-
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 classBasicCursor
- Returns:
-
clear
public final void clear()
Description copied from class:BasicCursor
Resets filters, sorting and fully cleans the buffer.- Overrides:
clear
in 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:
setIn
in interfaceInFilterSupport
-
getIn
public In getIn()
- Specified by:
getIn
in interfaceInFilterSupport
-
getCurrentKeyValues
public final Object[] getCurrentKeyValues()
Returns an array of field values of the primary key.- Returns:
-
-