scheduler.db.preferencesdb
Class PreferencesDB

java.lang.Object
  extended by java.util.Observable
      extended by scheduler.db.preferencesdb.PreferencesDB

public class PreferencesDB
extends java.util.Observable

The class representing the preferences database.

Author:
Leland Garofalo

Field Summary
protected  java.util.Collection<Preferences> data
          Collection of preferences.
 
Constructor Summary
PreferencesDB()
          Default Constructor
 
Method Summary
 void addPreference(Preferences p)
          Adds a Preference to the database
 java.util.Collection<Preferences> getData()
          Returns the preference database as a collection
 Preferences getPreferences(java.lang.String name)
          Iterates through the PreferencesDB to return correct one
 void removePreference(Preferences p)
          Removes a Preference from the Preferences Database
 void setData(java.util.Collection<Preferences> data)
          Sets the data in the PreferencesDB
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected java.util.Collection<Preferences> data
Collection of preferences.

Constructor Detail

PreferencesDB

public PreferencesDB()
Default Constructor

Method Detail

addPreference

public void addPreference(Preferences p)
Adds a Preference to the database

Parameters:
p - Preference Object
 // ** Pre and Post conditions ** //

 Pre:

 // Preference can not be Null
 p != nil

 &&


 // Preference can not be in PreferencesDB
 
 !(PreferencesDB.contains(p))


 Post:

 //Preference must be stored into database
 PreferencesDB.contains(p)

 

 

removePreference

public void removePreference(Preferences p)
Removes a Preference from the Preferences Database

Parameters:
p - Preference Object
 // ** Pre and Post conditions ** //

 Pre:

 // Preference can not be Null
 p != nil

 &&

 //Preference must be in the Preferences Database
 PreferencesDB.contains(p)



 Post:

 // Preference can not be in PreferencesDB
 
 !(PreferencesDB.contains(p))
 

 

getData

public java.util.Collection<Preferences> getData()
Returns the preference database as a collection

Returns:
data the preference database as a collection.
 // ** Pre and Post conditions ** //

 Pre:

 // Collection cannot be null
 data != nil

 Post:

 //Return data must match the current PreferencesDB
 data = PreferencesDB.data

 

 

setData

public void setData(java.util.Collection<Preferences> data)
Sets the data in the PreferencesDB

Parameters:
data - Collection The data to be set.
 // ** Pre and Post conditions ** //

 Pre:

 // data cannot be null
 data != nil

 Post:

 // PreferencesDB data must equal the passed data
 PreferencesDB.data = data

 

getPreferences

public Preferences getPreferences(java.lang.String name)
Iterates through the PreferencesDB to return correct one

Parameters:
name - String containing name of preference to return
Returns:
The preference that was being looked for, or null if it is not found
 // ** Pre and Post conditions ** //

 Pre:

 // name cannot be null
 name != nil

 Post:

 // Name of returned preference matches the name parameter
 p.name = name