| java.lang.Object example.stock.Database
All known Subclasses: example.stock.StockDatabase, example.stock.AlertDatabase,
Database | abstract public class Database (Code) | | This class provides a wrapper class for the
RecordStore class.
It allows for easier addition and deletion as well as better searching and
updating of records. The used recordIDs are kept in a Vector
which we use to access the indices of the records. The last used recordID
is stored at the beginning of the database and when the database is opened,
each recordID up to the last one used is tested to see if a record exists in
that position and a new Vector of used recordIDs
is generated.
|
database | protected volatile RecordStore database(Code) | | The database storing all the records and the last
used recordID in position 1
|
lastID | protected int lastID(Code) | | The last used ID in the database
|
rc | protected RecordComparator rc(Code) | | The object used to compare two records and see if they are equal
|
recordIDs | protected volatile Vector recordIDs(Code) | | The Vector of used recordIDs that are in the database
|
add | public synchronized void add(String record) throws RecordStoreNotOpenException, RecordStoreFullException, RecordStoreException(Code) | | Add the record to the database
Add the recordID to our vector
Update the database's last ID counter
Parameters: record - The record data to be added to the database RecordStoreNotOpenException is thrown whentrying to close a RecordStore that is not open RecordStoreFullException is thrown when the storagesystem is is full RecordStoreException is thrown when a generalexception occurs in a RecordStore operation |
cleanUp | public void cleanUp(String fileName) throws RecordStoreNotFoundException, RecordStoreException(Code) | | Remove the database from persistant storage
Parameters: fileName - the name of the RecordStore to remove |
close | public void close() throws RecordStoreNotOpenException, RecordStoreException(Code) | | Close the database and remove it from persistant
storage if it is empty
RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open RecordStoreException is thrown when a generalexception occurs in a RecordStore operation |
delete | public synchronized void delete(String s) throws RecordStoreNotOpenException, RecordStoreException(Code) | | Delete the record from the database and remove that recordID from the
vector of used recordIDs
Parameters: s - The name of the record to delete from the database RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open RecordStoreException is thrown when a generalexception occurs in a RecordStore operation |
getNumRecords | public int getNumRecords() throws RecordStoreNotOpenException(Code) | | Return the number of records in the database
the number of records in the database RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open |
open | public void open(String fileName) throws RecordStoreNotFoundException, RecordStoreException, RecordStoreFullException(Code) | | Initializes the database and if it's not a new database, loads the
recordID of the last record out of the first position in the
RecordStore . We have stored it there when we closed the
database, then checks each ID from 1 to lastID to see if they exist in
the database and then add the IDs that exist to the recordIDs
Vector
Parameters: fileName - The name of the RecordStore to open RecordStoreNotFoundException is thrown if theRecordStore indicated with fileName cannot be found RecordStoreException is thrown when a generalexception occurs in a RecordStore operation RecordStoreFullException is thrown when thestorage system is is full |
search | public synchronized String search(String s) throws RecordStoreNotOpenException, RecordStoreException(Code) | | Find and return a record
The record that we're looking for ornull if not found Parameters: s - The name of the record to search for RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open RecordStoreException is thrown when a generalexception occurs in a RecordStore operation |
update | public synchronized void update(String s, byte[] data) throws RecordStoreNotOpenException, RecordStoreFullException, RecordStoreException(Code) | | Update the record with the name s with the data
in the byte[] array
Parameters: s - The name of the record to update Parameters: data - the new data to update the record with RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open RecordStoreFullException is thrown when the storagesystem is is full RecordStoreException is thrown when a generalexception occurs in a RecordStore operation |
|
|