com.kednos.jphone
Class Database

java.lang.Object
  extended byvs.VmsStruct
      extended bycom.kednos.jphone.Database

public class Database
extends vs.VmsStruct

Java interface to Phone Book file.

This class is an extension of the vs.VmsStruct class. This means that the instantiated object also represents the current record.


Constructor Summary
Database()
          Create the connection to the database file.
 
Method Summary
 void clearRecord()
          Clear the internal record storage.
 boolean deleteRecord()
          Delete a record from the file.
 void finalize()
          Perform final cleanup.
 boolean getDateRecord(java.lang.String date, boolean first, boolean bday)
          Search for a specific record by date.
 boolean getMonthRecord(java.lang.String month, boolean first, boolean bday)
          Search for a specific record by month.
 boolean getRecord(java.lang.String name, boolean first)
          Search for a specific record by name.
 void writeRecord()
          Write the current record to the file.
 
Methods inherited from class vs.VmsStruct
get, get, getTarget, put, put, put, put
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database

public Database()
Create the connection to the database file.

Initialize the internal record buffer and open the phone book database file.

Method Detail

finalize

public void finalize()
              throws java.lang.Throwable
Perform final cleanup.

Close the phone book file.

Throws:
java.lang.Throwable

clearRecord

public void clearRecord()
Clear the internal record storage.

This method clears the internal record storage.


deleteRecord

public boolean deleteRecord()
Delete a record from the file.

Use this method to remove the current record from the phonebook file.

Returns:
set to true if the delete successed.

writeRecord

public void writeRecord()
Write the current record to the file.

This method writes the current record to the phone book file. It does not replace matching records. Use the deleteRecord() method first, then write the record.


getRecord

public boolean getRecord(java.lang.String name,
                         boolean first)
Search for a specific record by name.

This method will attempt to locate a record that matches the specified name. This is then loaded into the internal buffer making the record accessible via the get and put methods inherited from vs.VmsStruct.

Parameters:
name - the name to look for. It is in the format "Last First".
first - begin the search from the first record.
Returns:
set to true if a matching record was found.

getMonthRecord

public boolean getMonthRecord(java.lang.String month,
                              boolean first,
                              boolean bday)
Search for a specific record by month.

This method attempts to find a record with an event that occurs in the specified month. This event can either be a birthday or anniversary. If bday is true then birthdays are matched, otherwise anniversarys are matched.

Parameters:
month - month to fetch record for. This is the first three letters of the month.
first - begin the search from the first record.
bday - flag to indicate if the caller is looking for birthday or anniversary records.
Returns:
set to true if a matching record was found.

getDateRecord

public boolean getDateRecord(java.lang.String date,
                             boolean first,
                             boolean bday)
Search for a specific record by date.

This method attempts to find a record with an event that occurs on the specified date. This event can either be a birthday or anniversary. If bday is true then birthdays are matched, otherwise anniversarys are matched.

The date is specified as a String in the format DDMMM.

Parameters:
date - date to fetch record for.
first - begin the search from the first record.
bday - flag to indicate if the caller is looking for birthday or anniversary records.
Returns:
set to true if a matching record was found.