bir
Class StorageManager

java.lang.Object
  extended by bir.StorageManager

public class StorageManager
extends java.lang.Object

StorageManager handles all connections with the database for the dictionary and history


Field Summary
static java.lang.String SQLITE_DRIVER_NAME
           
 
Method Summary
 int addWord(DictionaryWord dictWord)
          Add a word to the dictionary, if it doesn't exist.
 void close()
          Closes all database connections, if they exist
 boolean customInit()
          Custom initialization for seeding dictionary With future dictionary improvement may be unnecessary
 java.util.ArrayList<DictionaryWord> getDictionary()
          Retrieves the entire dictionary from the database
static StorageManager getInstance()
          Singleton accessor
 java.util.ArrayList<java.lang.String> getLastSearches(int numSearches)
          Get the last numSearches search terms from the search history
 int recordSearchHistory(java.lang.String searchTerm, java.util.ArrayList<RankingResult> results)
          Stores the top ten results in the history
 int recordSearchTerm(java.lang.String searchTerm)
          Stores the search term in the history
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SQLITE_DRIVER_NAME

public static final java.lang.String SQLITE_DRIVER_NAME
See Also:
Constant Field Values
Method Detail

getInstance

public static StorageManager getInstance()
                                  throws java.lang.ClassNotFoundException,
                                         java.sql.SQLException
Singleton accessor

Returns:
The StorageManager instance
Throws:
java.lang.ClassNotFoundException
java.sql.SQLException

customInit

public boolean customInit()
Custom initialization for seeding dictionary With future dictionary improvement may be unnecessary

Returns:
Returns false if an error ocurred, true otherwise

close

public void close()
Closes all database connections, if they exist


addWord

public int addWord(DictionaryWord dictWord)
Add a word to the dictionary, if it doesn't exist. If it does exist, update its score.

Parameters:
dictWord -
Returns:
-1 if an error ocurred, the number of rows affected otherwise

getDictionary

public java.util.ArrayList<DictionaryWord> getDictionary()
Retrieves the entire dictionary from the database

Returns:
The list of Dictionary words

recordSearchTerm

public int recordSearchTerm(java.lang.String searchTerm)
Stores the search term in the history

Parameters:
searchTerm -
Returns:
The number of rows updated or -1 if an error occured

recordSearchHistory

public int recordSearchHistory(java.lang.String searchTerm,
                               java.util.ArrayList<RankingResult> results)
Stores the top ten results in the history

Parameters:
searchTerm -
results -
Returns:
The number of rows inserted or -1 if an error occured

getLastSearches

public java.util.ArrayList<java.lang.String> getLastSearches(int numSearches)
Get the last numSearches search terms from the search history

Parameters:
numSearches -
Returns:
A list of the last numSeraches searches made