mil.af.afit.router
Class VehicleList

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

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

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

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

Constructor Summary
VehicleList()
          Constructs an empty Vehicle list
 
Method Summary
 void addVehicle(Vehicle vehicle)
          Adds a single Vehicle to the end of the Vehicle list and notifies registered Observers of the change.
 void addVehicles(Vehicle[] moreVehicles)
          Adds the array of Vehicles to the end of the Vehicle list and notifies registered Observers of the change.
 int countEnabledVehicles()
          Returns the number of enabled vehicles in list.
 Vehicle[] getVehicles()
          Returns an array of the Vehicles in the list.
 void initializeAfterDeserialization(Kernel kernel)
          After deserialization, reconnect links.
 void removeVehicle(Vehicle vehicle)
          Removes a Vehicle by checking Vehicle == Vehicles[i] for each Vehicle in the list and notifies registered Observers of the change
 void removeVehicleAt(int index)
          Removes a Vehicle at a particular index and notifies registered Observers of the change.
 void removeVehiclesAt(int[] indeces)
          Removes Vehicles at the specified indeces and notifies registered Observers of the change.
 void replace(VehicleList newList, BaseList baseList)
          Replaces this list with newList.
 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
 

Constructor Detail

VehicleList

public VehicleList()
Constructs an empty Vehicle list
Since:
1.0
Method Detail

addVehicles

public final void addVehicles(Vehicle[] moreVehicles)
Adds the array of Vehicles to the end of the Vehicle list and notifies registered Observers of the change.
Parameters:
moreVehicles - array of Vehicles to add to list
See Also:
Vehicle, Observer

addVehicle

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

removeVehicleAt

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

removeVehicle

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

removeVehiclesAt

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

getVehicles

public final Vehicle[] getVehicles()
Returns an array of the Vehicles in the list.
Returns:
array of Vehicles in the list
Since:
1.0

initializeAfterDeserialization

public final void initializeAfterDeserialization(Kernel kernel)
After deserialization, reconnect links.
Parameters:
kernel - kernel being used
Since:
1.0

toString

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

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

countEnabledVehicles

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

replace

public final void replace(VehicleList newList,
                          BaseList baseList)
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 vehicle list to use
Since:
1.0