addbk.JAddressBook
Class AddressDataBase

java.lang.Object
  extended by java.util.Observable
      extended by addbk.JAddressBook.AddressDataBase

public final class AddressDataBase
extends java.util.Observable

Use the singleton design pattern to make sure that there is one and only one instance of the class.


Method Summary
 void addRecord(AddressRecord abr)
           
 void addRecord(java.lang.String s, DelimiterBean db)
          Add s, assuming it contains one records and is parsed using db.
 void addRecords(java.util.Vector vector)
           
 void clearDataBase()
           
 void combineDuplicates()
           
 void deleteCurrentRecord()
           
 void deleteRecord(AddressRecord abr)
           
static boolean equal(AddressRecord ar1, AddressRecord ar2)
           
 void exportCsv(DelimiterBean db)
           
 AddressRecord find(FindBean findBean)
          Use the findBean to locate an address record.
 void findLetter(java.lang.String text)
          Search the database until you find the letter or the letter just previous to it.
 void findRecordAndSetToCurrent(AddressRecord value)
           
 void findRecordAndSetToCurrentNoUpdate(AddressRecord value)
           
 java.util.Vector getAddressVector()
           
 AddressRecord getCurrentRecord()
           
 AddressRecord getNextRecord()
           
 AddressRecord[] getNextRecords(int n)
          getN records from addressbook.
 AddressRecord getPreviousRecord()
           
 AddressRecord getRecordAt(int recNumber)
           
 int getRecordNumber()
           
 java.lang.String getSaveFileName()
           
 int getSize()
           
 void gotoFirstRecord()
           
static boolean isFieldsEmpty(AddressRecord ar)
           
 boolean isModifiedButNotSaved()
           
 void mergeAdb()
           
 void mergeUsingDelimiters(DelimiterBean db)
           
 void mergeXml()
           
 void mergeXml(java.lang.String xmlString)
           
 void next(int numberOfRows)
           
 void openEncryptedGzDb()
           
 void openGzDb(CipherBean cb, java.io.File f)
           
 void openGzDb(java.lang.String readFileName)
           
 void previous(int numberOfRows)
           
 void print()
           
 AddressRecord readRecord()
           
 void recoverSerialData(java.lang.String readFileName)
           
 void removeDuplicates()
           
 void replaceCurrentRecord(AddressRecord ar)
           
static AddressDataBase restore()
           
 void save()
           
 void saveAsXml()
           
 void saveEncryptedGzDb()
           
 void saveGzDb()
          Uses the preferences and a gui to update the output file.
 void saveGzDb(CipherBean cb)
           
 void saveGzDb(CipherBean cb, java.io.File writeFile)
           
 void saveGzDb(java.io.File writeFile)
          Does not update the preferences with the new output file.
 void saveGzDb(java.lang.String uidPw)
           
 void saveGzippedDb()
           
 void setAddressVector(java.util.Vector addressVector)
           
 void setRecordNumber(int recordNumber)
           
 void sort()
           
 void top()
           
 java.lang.String toString()
           
static void trim(AddressRecord ar)
           
 void undoDelete()
           
 void update()
           
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

restore

public static AddressDataBase restore()

update

public void update()

mergeUsingDelimiters

public void mergeUsingDelimiters(DelimiterBean db)

addRecord

public void addRecord(java.lang.String s,
                      DelimiterBean db)
Add s, assuming it contains one records and is parsed using db.

Parameters:
s - string with record
db - has field and line delimiters

saveAsXml

public void saveAsXml()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

sort

public void sort()

readRecord

public AddressRecord readRecord()

getRecordAt

public AddressRecord getRecordAt(int recNumber)

undoDelete

public void undoDelete()

addRecord

public void addRecord(AddressRecord abr)

deleteRecord

public void deleteRecord(AddressRecord abr)

getSize

public int getSize()
Returns:
size of the currently held database

deleteCurrentRecord

public void deleteCurrentRecord()

saveGzippedDb

public void saveGzippedDb()

mergeAdb

public void mergeAdb()

trim

public static void trim(AddressRecord ar)

combineDuplicates

public void combineDuplicates()

isFieldsEmpty

public static boolean isFieldsEmpty(AddressRecord ar)

removeDuplicates

public void removeDuplicates()

equal

public static boolean equal(AddressRecord ar1,
                            AddressRecord ar2)

addRecords

public void addRecords(java.util.Vector vector)

openGzDb

public void openGzDb(java.lang.String readFileName)
              throws java.io.IOException
Throws:
java.io.IOException

recoverSerialData

public void recoverSerialData(java.lang.String readFileName)
                       throws java.io.IOException
Throws:
java.io.IOException

openEncryptedGzDb

public void openEncryptedGzDb()

openGzDb

public void openGzDb(CipherBean cb,
                     java.io.File f)
              throws java.io.IOException,
                     java.security.InvalidKeyException
Throws:
java.io.IOException
java.security.InvalidKeyException

saveGzDb

public void saveGzDb()
              throws java.io.IOException
Uses the preferences and a gui to update the output file.

Throws:
java.io.IOException

saveEncryptedGzDb

public void saveEncryptedGzDb()

saveGzDb

public void saveGzDb(java.lang.String uidPw)
              throws java.io.IOException,
                     java.security.InvalidKeyException,
                     java.security.NoSuchAlgorithmException,
                     javax.crypto.NoSuchPaddingException
Throws:
java.io.IOException
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
javax.crypto.NoSuchPaddingException

saveGzDb

public void saveGzDb(CipherBean cb)
              throws java.io.IOException,
                     java.security.InvalidKeyException
Throws:
java.io.IOException
java.security.InvalidKeyException

saveGzDb

public void saveGzDb(CipherBean cb,
                     java.io.File writeFile)
              throws java.io.IOException,
                     java.security.InvalidKeyException
Throws:
java.io.IOException
java.security.InvalidKeyException

saveGzDb

public void saveGzDb(java.io.File writeFile)
              throws java.io.IOException
Does not update the preferences with the new output file. If this crashes during write, the output will be corrupt and VERY hard to read.

Parameters:
writeFile -
Throws:
java.io.IOException

getCurrentRecord

public AddressRecord getCurrentRecord()

getPreviousRecord

public AddressRecord getPreviousRecord()

getNextRecord

public AddressRecord getNextRecord()

exportCsv

public void exportCsv(DelimiterBean db)

find

public AddressRecord find(FindBean findBean)
Use the findBean to locate an address record. Return it if you find it, otherwise return null. Set the recordNumber, if you find the record, otherwise leave it alone.


clearDataBase

public void clearDataBase()

top

public void top()

replaceCurrentRecord

public void replaceCurrentRecord(AddressRecord ar)

findRecordAndSetToCurrentNoUpdate

public void findRecordAndSetToCurrentNoUpdate(AddressRecord value)

findRecordAndSetToCurrent

public void findRecordAndSetToCurrent(AddressRecord value)

getAddressVector

public java.util.Vector getAddressVector()

setAddressVector

public void setAddressVector(java.util.Vector addressVector)

getRecordNumber

public int getRecordNumber()

setRecordNumber

public void setRecordNumber(int recordNumber)

mergeXml

public void mergeXml()

mergeXml

public void mergeXml(java.lang.String xmlString)

print

public void print()

getNextRecords

public AddressRecord[] getNextRecords(int n)
getN records from addressbook. Do not notify observers. start at the recordNumber location. If there are no records, the first element will be null.


findLetter

public void findLetter(java.lang.String text)
Search the database until you find the letter or the letter just previous to it.


previous

public void previous(int numberOfRows)

next

public void next(int numberOfRows)

save

public void save()
          throws java.io.IOException
Throws:
java.io.IOException

getSaveFileName

public java.lang.String getSaveFileName()

isModifiedButNotSaved

public boolean isModifiedButNotSaved()

gotoFirstRecord

public void gotoFirstRecord()