mil.af.afit.router
Class BaseList

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

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

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

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

Constructor Summary
BaseList()
          Constructs an empty base list
 
Method Summary
 void addBase(Base base)
          Adds a single base to the end of the base list and notifies registered Observers of the change.
 void addBases(Base[] moreBases)
          Adds the array of bases to the end of the base list and notifies registered Observers of the change.
 Base[] getBases()
          Returns an array of the bases in the list.
 void removeBase(Base base)
          Removes a base by checking base == bases[i] for each base in the list and notifies registered Observers of the change
 void removeBaseAt(int index)
          Removes a base at a particular index and notifies registered Observers of the change.
 void removeBasesAt(int[] indeces)
          Removes bases at the specified indeces and notifies registered Observers of the change.
 void replace(BaseList newList)
          Replaces this list with newList.
 java.lang.String toString()
          Returns "Number of bases: " + bases.length;
 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
 

Constructor Detail

BaseList

public BaseList()
Constructs an empty base list
Since:
1.0
Method Detail

addBases

public final void addBases(Base[] moreBases)
Adds the array of bases to the end of the base list and notifies registered Observers of the change.
Parameters:
moreBases - array of bases to add to list
See Also:
Base, Observer

addBase

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

removeBaseAt

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

removeBase

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

removeBasesAt

public final void removeBasesAt(int[] indeces)
Removes bases at the specified indeces and notifies registered Observers of the change.
Parameters:
base - base to remove
See Also:
Base, Observer

getBases

public final Base[] getBases()
Returns an array of the bases in the list.
Returns:
array of bases in the list
Since:
1.0

toString

public java.lang.String toString()
Returns "Number of bases: " + bases.length;
Overrides:
toString in class java.lang.Object
Returns:
a string representation
Since:
1.0

update

public final void update(java.util.Observable thing,
                         java.lang.Object arg)
Called when an Observable registers a change. The list registers with bases. 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

replace

public final void replace(BaseList 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 base list to use
Since:
1.0