|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--suncertify.db.Data
This class provides the basic database services. It uses two other support classes: DataInfo and FieldInfo.
Constructor Summary | |
Data(java.lang.String dbname)
This constructor opens an existing database given the name of the disk file containing it. |
|
Data(java.lang.String dbname,
FieldInfo[] fields)
This constructor creates a new database file, using the name provided for the disk file and using the FieldInfo array to describe the field names and sizes that should be created. |
Method Summary | |
void |
add(java.lang.String[] newData)
This method adds a new record to the database. |
void |
close()
This method closes the database, flushing any outstanding writes at the same time. |
void |
delete(DataInfo toDelete)
This method deletes the record referred to by the record number in the DataInfo argument. |
protected void |
finalize()
The finalize method to close the underlying DataBase file when DataBase is garbage collected. |
DataInfo |
find(java.lang.String toMatch)
This method searches the database for an entry which has a first field which exactly matches the string supplied. |
DataInfo[] |
findCriteria(java.lang.String criteria)
The method to search in the database all records that matches a given criteria. |
FieldInfo[] |
getFieldInfo()
This method returns a description of the database schema, as an array of FieldInfo objects. |
DataInfo |
getRecord(int recNum)
Gets a requested record from the database based on record number. |
int |
getRecordCount()
Gets the number of records stored in the database. |
protected void |
invariant()
Ensures that the database structure is valid. |
void |
lock(int recNum,
java.lang.String clientID)
Lock the requested record. |
void |
modify(DataInfo newData)
This method updates the record specified by the record number field in the DataInfo argument. |
void |
releaseLocks()
This method is use to clear all locks at time of bringing down the database server and also when there are no client references to the Remote Server. |
void |
releaseLocks(java.lang.String clientID)
The method to release all locks held by the ClientId which just got severed. |
void |
unLock(int recNum,
java.lang.String clientID)
Unlock the requested record. |
Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Data(java.lang.String dbname) throws java.io.IOException
String
- dbname The name of the database file to open.public Data(java.lang.String dbname, FieldInfo[] fields) throws java.io.IOException
String
- dbname The name of the database file to open.FieldInfo[]
- fields The list of fields for the schema of
this database.Method Detail |
public FieldInfo[] getFieldInfo()
public int getRecordCount()
public DataInfo getRecord(int recNum) throws DatabaseException
recNum
- The number of the record to read (first record is 1).public DataInfo find(java.lang.String toMatch) throws DatabaseException
toMatch
- The key field value to match upon for
a successful find.public void add(java.lang.String[] newData) throws DatabaseException
newData
- The elements of the record to add.public void modify(DataInfo newData) throws DatabaseException
newData
- The updated record to modify.public void delete(DataInfo toDelete) throws DatabaseException
DataInfo
- newData The record to delete.public void close()
protected void finalize()
protected final void invariant()
public void lock(int recNum, java.lang.String clientID) throws DatabaseException
recNum:
- The record number to lock.public void unLock(int recNum, java.lang.String clientID)
recNum:
- The record number to unLock.public void releaseLocks(java.lang.String clientID)
clientID
- : the id of the client whose connection just got severed.public void releaseLocks()
public DataInfo[] findCriteria(java.lang.String criteria) throws DatabaseException
criteria
- : A string of the form (fieldName1=value1,...fieldNamen=valuen)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |