suncertify.db
Interface DBMain

All Known Implementing Classes:
Data

public interface DBMain


Method Summary
 int create(java.lang.String[] data)
          Creates a new record in the database (possibly reusing a deleted entry).
 void delete(int recNo)
          Deletes a record, making the record number and associated disk storage available for reuse.
 int[] find(java.lang.String[] criteria)
          Returns an array of record numbers that match the specified criteria.
 boolean isLocked(int recNo)
          Determines if a record is currenly locked.
 void lock(int recNo)
          Locks a record so that it can only be updated or deleted by this client.
 java.lang.String[] read(int recNo)
          Reads a record from the file.
 void unlock(int recNo)
          Releases the lock on a record.
 void update(int recNo, java.lang.String[] data)
          Modifies the fields of a record.
 

Method Detail

read

public java.lang.String[] read(int recNo)
                        throws RecordNotFoundException
Reads a record from the file. Returns an array where each element is a record value.

Parameters:
recNo - the index of the requested record
Returns:
string array with the values of requested record fields
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.

update

public void update(int recNo,
                   java.lang.String[] data)
            throws RecordNotFoundException
Modifies the fields of a record. The new value for field n appears in data[n].

Parameters:
recNo - the index of the record to operate on
data - the new set of data for the requested record
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.

delete

public void delete(int recNo)
            throws RecordNotFoundException
Deletes a record, making the record number and associated disk storage available for reuse.

Parameters:
recNo - the index of the record to delete
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.

find

public int[] find(java.lang.String[] criteria)
           throws RecordNotFoundException
Returns an array of record numbers that match the specified criteria. Field n in the database file is described by criteria[n]. A null value in criteria[n] matches any field value. A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)

Parameters:
criteria - String array representing the criteria for each record field
Returns:
array containig indexes of all records meeting the criteria
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.

create

public int create(java.lang.String[] data)
           throws DuplicateKeyException
Creates a new record in the database (possibly reusing a deleted entry). Inserts the given data, and returns the record number of the new record.

Returns:
index of the newly created record
DuplicateKeyException

lock

public void lock(int recNo)
          throws RecordNotFoundException
Locks a record so that it can only be updated or deleted by this client. If the specified record is already locked, the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked.

Parameters:
recNo - the index of the record to lock
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.

unlock

public void unlock(int recNo)
            throws RecordNotFoundException
Releases the lock on a record.

Parameters:
recNo - the index of the record to lock
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.

isLocked

public boolean isLocked(int recNo)
                 throws RecordNotFoundException
Determines if a record is currenly locked. Returns true if the record is locked, false otherwise.

Parameters:
recNo - the index of the record to check
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.