/** * Close the file. * Reset the current position. */ public void close() { m_bIsOpen = false; this.getRecord().setEditMode(Constants.EDIT_NONE); } /**
/** * Get the next record (return a null at EOF). * Note: Remember to set the data source before returning a NORMAL_RETURN. * @param iRelPosition The relative records to move. * @return A record status (NORMAL_RETURN means the move was successful). */ public int doMove(int iRelPosition) throws DBException { this.getRecord().setEditMode(Constants.EDIT_NONE); return Constants.ERROR_RETURN; // You better override this. } /**
/** * Reset the current position and open the file. * Note: This is called automatically on your first file access. */ public void open() throws DBException { m_bIsOpen = true; this.getRecord().setEditMode(Constants.EDIT_NONE); this.setDataSource(null); } /**
/** * Create a new empty record. * Discard the current fields, init all the fields and display them, * and set the status to EDIT_ADD. */ public void addNew() throws DBException { this.getRecord().initRecord(true); this.getRecord().setEditMode(Constants.EDIT_ADD); } /**
/** * Reset all the fields to their default value. * <p />NOTE: After executing, this records edit mode is set to NONE. * @param bDisplay The the new values (on work in the thick model). * @throws Exception An exception on initing a field. */ public void initRecord(boolean bDisplay) throws DBException { int iFieldCount = this.getFieldCount(); // Number of fields to read in for (int iFieldSeq = Constants.MAIN_FIELD; iFieldSeq < iFieldCount + Constants.MAIN_FIELD; iFieldSeq++) { FieldInfo field = this.getField(iFieldSeq); field.initField(bDisplay); } this.setEditMode(Constants.EDIT_NONE); } /**
/** * Read the record that matches this record's current key. * <p>NOTE: You do not need to Open to do a seek or addNew. * @param strSeekSign - Seek sign: * @return true if successful, false if not found. * @exception FILE_NOT_OPEN. * @exception KEY_NOT_FOUND - The key was not found on read. */ public boolean seek(String strSeekSign) throws DBException { this.getRecord().setEditMode(Constants.EDIT_NONE); if (strSeekSign == null) strSeekSign = Constants.EQUALS; boolean bSuccess = this.doSeek(strSeekSign); if (bSuccess) { this.dataToFields(this.getRecord()); this.setDataSource(null); this.getRecord().setEditMode(Constants.EDIT_CURRENT); return true; } else return false; // Not found } /**
/** * Get the next record (return a null at EOF). * @param iRelPosition The relative records to move. * @return next FieldList or null if EOF. */ public FieldList move(int iRelPosition) throws DBException { if (!m_bIsOpen) this.open(); // This will requery the table the first time this.getRecord().setEditMode(Constants.EDIT_NONE); int iRecordStatus = this.doMove(iRelPosition); if (iRecordStatus == Constants.NORMAL_RETURN) { this.dataToFields(this.getRecord()); // Usually, you would setDataSource(null), but if in hasNext(), you will need the dataSource. this.getRecord().setEditMode(Constants.EDIT_CURRENT); return m_record; } else return null; // Usually EOF } /**
this.getRecord().setEditMode(Constants.EDIT_NONE); Object objData = this.doGet(iRowIndex); if (objData instanceof Integer) this.getRecord().setEditMode(Constants.EDIT_NONE); // Invalid record return m_record; this.dataToFields(this.getRecord()); this.getRecord().setEditMode(Constants.EDIT_CURRENT); return m_record;
/** * Remove the current record. */ public void remove() throws DBException { if ((this.getRecord().getEditMode() != Constants.EDIT_CURRENT) && ((this.getRecord().getEditMode() != Constants.EDIT_IN_PROGRESS))) throw new DBException(Constants.INVALID_RECORD); this.doRemove(); this.getRecord().setEditMode(Constants.EDIT_NONE); } /**
/** * Add this record to this table. * Add this record to the table and set the current edit mode to NONE. * @param record The record to add. * @throws Exception */ public void add(Rec record) throws DBException { if (this.getRecord().getEditMode() != Constants.EDIT_ADD) throw new DBException(Constants.INVALID_RECORD); m_record = (FieldList)record; this.fieldsToData(record); this.doAdd(record); this.setDataSource(null); this.getRecord().setEditMode(Constants.EDIT_NONE); } /**
/** * Lock the current record. * This method responds differently depending on what open mode the record is in: * OPEN_DONT_LOCK - A physical lock is not done. This is usually where deadlocks are possible * (such as screens) and where transactions are in use (and locks are not needed). * OPEN_LOCK_ON_EDIT - Holds a lock until an update or close. (Update crucial data, or hold records for processing) * Returns false is someone alreay has a lock on this record. * OPEN_WAIT_FOR_LOCK - Don't return from edit until you get a lock. (ie., Add to the total). * Returns false if someone has a hard lock or time runs out. * @return true if successful, false is lock failed. * @exception DBException FILE_NOT_OPEN * @exception DBException INVALID_RECORD - Record not current. * NOTE: For a remote table it is not necessary to call edit, as edit will * be called automatically by the set() call. */ public int edit() throws DBException { if ((this.getRecord().getEditMode() != Constants.EDIT_CURRENT) && (this.getRecord().getEditMode() != Constants.EDIT_IN_PROGRESS)) throw new DBException(Constants.INVALID_RECORD); int iErrorCode = this.doEdit(); // Only call if edit is supported by remote db if (iErrorCode == Constants.NORMAL_RETURN) this.getRecord().setEditMode(Constants.EDIT_IN_PROGRESS); return iErrorCode; } /**
/** * Set the current record to this (new) record. * NOTE: In the thin model, it is not necessary to call edit() before set. * @exception Throws an exception if there is no current record. */ public void set(Rec record) throws DBException { if ((this.getRecord().getEditMode() != Constants.EDIT_CURRENT) && ((this.getRecord().getEditMode() != Constants.EDIT_IN_PROGRESS))) throw new DBException(Constants.INVALID_RECORD); m_record = (FieldList)record; this.fieldsToData(record); this.doSet(record); this.setDataSource(null); this.getRecord().setEditMode(Constants.EDIT_NONE); } /**
fieldListNew.setEditMode(Constants.EDIT_ADD); fieldListNew.setEditMode(Constants.EDIT_NONE);