|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
scheduler.db.locationdb.LocationDB
public class LocationDB
The class representing the location database.
Nested Class Summary | |
---|---|
class |
LocationDB.AvailabilityTuple
Class that holds a building, room, and list of availability. |
static class |
LocationDB.LocationDoesNotExistException
This exception is raised when a location is queried but does not exist. |
static class |
LocationDB.LocationExistsException
This exception is raised when a location already exists in the collection. |
static class |
LocationDB.NumberInvalidException
This exception is raised when the inputted number for converting to time is not correct. |
Field Summary | |
---|---|
protected java.util.Collection<LocationDB.AvailabilityTuple> |
availability
A collection of available days. |
protected java.util.Collection<Location> |
data
A collection of locations. |
private static int |
NUMDAYSINWEEK
Constant for the number of days in a week |
private static int |
ROWS
Constant for the number of rows in a table |
Constructor Summary | |
---|---|
LocationDB()
Location database constructor |
Method Summary | |
---|---|
void |
addLocation(Location l)
addLocation Adds a given location to the location database pre: // // "location" must be a valid Location // isValidLocation (location, locationdb); post: // // Only "location" was added to "locationdb" // forall (location' in locationdb') (location' in locationdb') iff ((location' = location) or (location' in locationdb));* |
void |
changeAvailability(java.util.ArrayList<DayAvail> data,
Location location)
Changes the availability stored in the database. |
void |
editLocation(Location location)
editLocation edits a given, already-existing Location in the database. |
java.util.ArrayList<DayAvail> |
getAvailability(Location location)
Returns the specified location's availability |
java.util.Collection<Location> |
getData()
Returns the collection of the data. |
Time |
getEndTime(int number)
Converts the inputted value into a corresponding Time object rounded up to the latest half-hour. |
Location |
getLocation(java.lang.String location)
Gets the location based on its string representation |
Time |
getStartTime(int number)
Converts the inputted value into a corresponding Time object rounded to the earliest half-hour. |
private java.util.ArrayList<DayAvail> |
initializeAvailability(java.util.ArrayList<DayAvail> avail)
Initializes seven DayAvail objects and adds them to a list. |
protected boolean |
isValidLocationDB(LocationDB[] ldb)
isValidLocationDB checks if the location database is valid. |
void |
removeLocation(Location l)
removeLocation removes a given, already existing location from the location database pre: // // "location" must be in "locationdb" // (location in locationdb); post: // // The new database differs from teh old only in the absence of "location" // forall (location':Location) (location' in locationdb) iff ((location' != location) and (location' in locationdb)); |
void |
setData(java.util.Collection<Location> data)
Sets the data in the locationDB |
void |
updateAvailability()
Updates the availability of the location objects in the local database. |
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 |
---|
private static final int NUMDAYSINWEEK
private static final int ROWS
protected java.util.Collection<Location> data
protected java.util.Collection<LocationDB.AvailabilityTuple> availability
Constructor Detail |
---|
public LocationDB()
Method Detail |
---|
private java.util.ArrayList<DayAvail> initializeAvailability(java.util.ArrayList<DayAvail> avail)
avail
- A list of day availability
public java.util.Collection<Location> getData()
public void setData(java.util.Collection<Location> data)
pre: // // The data field is not null // (data != null) post: // // The data field now equals the parameter. // (this.data == data)
data
- The data to be set.public void addLocation(Location l)
public void editLocation(Location location)
public void removeLocation(Location l)
public Location getLocation(java.lang.String location)
pre: // // location contains the '-' character // (location.contains('-') ) post: // // the returned location's toString() method is equal to // the parameter. // ( returnVal.toString().equals(location) )
protected boolean isValidLocationDB(LocationDB[] ldb)
public void changeAvailability(java.util.ArrayList<DayAvail> data, Location location)
data
- A list of day availabilitylocation
- The method will change the specified location's
availabilitypublic java.util.ArrayList<DayAvail> getAvailability(Location location)
location
- The method will change the specified location's
availability
public void updateAvailability()
public Time getStartTime(int number)
pre: // // number is between 0 and 30 // (number >= 0 && number < 30) post: // // the returned time corresponds to the number // (time.hour = ((number / 2) + 7) && time.minute = (number % 2) * 30 )
public Time getEndTime(int number)
pre: // // number is between 0 and 30 // (number >= 0 && number < 30) post: // // the returned time corresponds to the number // (time.hour = ((number / 2) + 7) && time.minute = (number % 2) * 30 )
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |