FileDocCategorySizeDatePackage
AlertDatabase.javaAPI DocJ2ME MIDP 2.04989Thu Nov 07 12:02:18 GMT 2002example.stock

AlertDatabase

public class AlertDatabase extends Database

This class provides an implementation of the Database class specific to alert records.

Fields Summary
Constructors Summary
public AlertDatabase()
Default Constructor

        rc = new AlertComparator();
    
Methods Summary
public synchronized RecordEnumerationenumerateRecords(java.lang.String tkrSymbol, int price)

Get a RecordEnumeration of records in the database who match the AlertFilter conditions

return
RecordEnumeration of all stock records that match the RecordFilter
param
tkrSymbol The name of the stock to retrieve alerts for
param
price The price of the stock to retrieve alerts for
throws
RecordStoreNotOpenException is thrown when trying to close a RecordStore that is not open

        return database.enumerateRecords(new AlertFilter(tkrSymbol, price),
					 null, false);
    
public synchronized voidremoveUselessAlerts(java.lang.String tkrSymbol)

This methods cleans out the database of all alerts that match the tkrSymbol passed in. An appropriate use would be when removing a stock from the database, all alerts for that stock are no longer valid, so call this method then.

param
tkrSymbol The name of the stock to match with alerts

        Enumeration IDs = recordIDs.elements();
        while (IDs.hasMoreElements()) {
            int index = ((Integer) IDs.nextElement()).intValue();
            try {
                String data = new String(database.getRecord(index));
                data = data.substring(0, data.indexOf(';"));
                if (data.equals(tkrSymbol)) {
                    database.deleteRecord(index);
                    recordIDs.removeElement(new Integer(index));
                }
            } catch (RecordStoreException rse) {
                return;
            }
        }