mil.af.afit.router
Class SiteList

java.lang.Object
  |
  +--java.util.Observable
        |
        +--mil.af.afit.router.SiteList
All Implemented Interfaces:
java.util.Observer, java.io.Serializable

public class SiteList
extends java.util.Observable
implements java.util.Observer, java.io.Serializable

This maintains a list of sites and allows interested objects to listen for changes by implementing the Observer interface.

Since:
1.0
See Also:
Site, Observer, Serialized Form

Field Summary
static int ASCENDING
           
static int DESCENDING
           
 
Constructor Summary
SiteList()
          Constructs an empty site list
 
Method Summary
 void addSite(Site site)
          Adds a single site to the end of the site list and notifies registered Observers of the change.
 void addSites(Site[] moreSites)
          Adds the array of sites to the end of the site list and notifies registered Observers of the change.
 int countEnabledSites()
          Returns the number of enabled sites in list.
 int getEarliestTimeWindow()
          Returns earliest time window.
 int getLatestTimeWindow()
          Returns latest time window.
 Site[] getSites()
          Returns an array of the sites in the list.
 java.lang.String lastSortKey()
          Returns last key used to sort.
 boolean lastSortWasAscending()
          Returns whether or not the last sort performed was ascending.
 boolean lastSortWasDescending()
          Returns whether or not the last sort performed was descending.
 void removeSite(Site site)
          Removes a site by checking site == sites[i] for each site in the list and notifies registered Observers of the change
 void removeSiteAt(int index)
          Removes a site at a particular index and notifies registered Observers of the change.
 void removeSitesAt(int[] indeces)
          Removes sites at the specified indeces and notifies registered Observers of the change.
 void replace(SiteList newList)
          Replaces this list with newList.
 void sortByEarliestArrivalTime(boolean ascending)
          Sort by beginning of time window.
 void sortByEarliestRestrictedTime(boolean ascending)
          Sort by beginning of time wall.
 void sortByEnabled(boolean ascending)
          Sort by enabled.
 void sortByLatestDepartureTime(boolean ascending)
          Sort by ending of time window.
 void sortByLatestRestrictedTime(boolean ascending)
          Sort by ending of time wall.
 void sortByLatitude(boolean ascending)
          Sort by latitude.
 void sortByLongitude(boolean ascending)
          Sort by longitude.
 void sortByName(boolean ascending)
          Sort by name.
 void sortByPriority(boolean ascending)
          Sort by priority.
 void sortByRequirementType(boolean ascending)
          Sort by requirement type.
 void sortByServiceTime(boolean ascending)
          Sort by service time.
 java.lang.String toString()
           
 void update(java.util.Observable thing, java.lang.Object arg)
          Called when an Observable registers a change.
 
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, wait, wait, wait
 

Field Detail

ASCENDING

public static final int ASCENDING

DESCENDING

public static final int DESCENDING
Constructor Detail

SiteList

public SiteList()
Constructs an empty site list
Since:
1.0
Method Detail

addSites

public final void addSites(Site[] moreSites)
Adds the array of sites to the end of the site list and notifies registered Observers of the change.
Parameters:
moreSites - array of sites to add to list
See Also:
Site, Observer

addSite

public final void addSite(Site site)
Adds a single site to the end of the site list and notifies registered Observers of the change.
Parameters:
site - site to add to list
See Also:
Site, Observer

removeSiteAt

public final void removeSiteAt(int index)
Removes a site at a particular index and notifies registered Observers of the change.
Parameters:
index - index of site to remove
See Also:
Site, Observer

removeSite

public final void removeSite(Site site)
Removes a site by checking site == sites[i] for each site in the list and notifies registered Observers of the change
Parameters:
site - site to remove
See Also:
Site, Observer

removeSitesAt

public final void removeSitesAt(int[] indeces)
Removes sites at the specified indeces and notifies registered Observers of the change.
Parameters:
site - site to remove
See Also:
Site, Observer

lastSortWasAscending

public final boolean lastSortWasAscending()
Returns whether or not the last sort performed was ascending.
Returns:
whether or not the last sort performed was ascending
Since:
1.0

lastSortWasDescending

public final boolean lastSortWasDescending()
Returns whether or not the last sort performed was descending.
Returns:
whether or not the last sort performed was descending
Since:
1.0

lastSortKey

public final java.lang.String lastSortKey()
Returns last key used to sort.
Returns:
last key used to sort
Since:
1.0

sortByName

public final void sortByName(boolean ascending)
Sort by name.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByPriority

public final void sortByPriority(boolean ascending)
Sort by priority.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByServiceTime

public final void sortByServiceTime(boolean ascending)
Sort by service time.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByEarliestArrivalTime

public final void sortByEarliestArrivalTime(boolean ascending)
Sort by beginning of time window.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByLatestDepartureTime

public final void sortByLatestDepartureTime(boolean ascending)
Sort by ending of time window.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByEarliestRestrictedTime

public final void sortByEarliestRestrictedTime(boolean ascending)
Sort by beginning of time wall.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByLatestRestrictedTime

public final void sortByLatestRestrictedTime(boolean ascending)
Sort by ending of time wall.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByEnabled

public final void sortByEnabled(boolean ascending)
Sort by enabled.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByRequirementType

public final void sortByRequirementType(boolean ascending)
Sort by requirement type.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByLatitude

public final void sortByLatitude(boolean ascending)
Sort by latitude.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

sortByLongitude

public final void sortByLongitude(boolean ascending)
Sort by longitude.
Parameters:
ascending - whether or not sort should be in ascending order
Since:
1.0

update

public void update(java.util.Observable thing,
                   java.lang.Object arg)
Called when an Observable registers a change. The list registers with sites. The list then notifies its own registered Observers of the change.
Specified by:
update in interface java.util.Observer
Parameters:
thing - thing that was updated
arg - argument passed by thing
Since:
1.0
See Also:
Observable, Observer

getSites

public final Site[] getSites()
Returns an array of the sites in the list.
Returns:
array of sites in the list
Since:
1.0

toString

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

countEnabledSites

public final int countEnabledSites()
Returns the number of enabled sites in list.
Returns:
the number of enabled sites in list
Since:
1.0

getEarliestTimeWindow

public final int getEarliestTimeWindow()
Returns earliest time window.
Returns:
earliest time window
Since:
1.0

getLatestTimeWindow

public final int getLatestTimeWindow()
Returns latest time window.
Returns:
latest time window
Since:
1.0

replace

public final void replace(SiteList newList)
Replaces this list with newList. This is used when loading a new Kernel. Observers registered with the original list will still be registered, but anything registered with newList will not still be registered.
Parameters:
newList - the new site list to use
Since:
1.0