mil.af.afit.router
Class PriorityModelList

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

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

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

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

Constructor Summary
PriorityModelList()
          Constructs an empty priority model list
 
Method Summary
 void addPriorityModel(PriorityModel priorityModel)
          Adds a single priorityModel to the end of the priorityModel list and notifies registered Observers of the change.
 void addPriorityModels(PriorityModel[] morePriorityModels)
          Adds the array of models to the end of the list and notifies registered Observers of the change.
 PriorityModel[] getPriorityModels()
          Returns an array of the priorityModels in the list.
 void initializeAfterDeserialization(Kernel kernel)
          Register as observer after deserialization.
 void makeStandardModels(Kernel kernel)
          Makes the standard models which includes three models:
Infinite relative worths (not editable) Relative worths of 5 to 1 (not editable) Customizable relative worths with a default of 10
 void removePriorityModel(PriorityModel priorityModel)
          Removes a priorityModel by checking priorityModel == priorityModels[i] for each priorityModel in the list and notifies registered Observers of the change
 void removePriorityModelAt(int index)
          Removes a priorityModel at a particular index and notifies registered Observers of the change.
 void removePriorityModelsAt(int[] indeces)
          Removes priorityModels at the specified indeces and notifies registered Observers of the change.
 void replace(PriorityModelList newList)
          Replaces this list with newList.
 java.lang.String toString()
          Returns "Number of priorityModels: " + priorityModels.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

PriorityModelList

public PriorityModelList()
Constructs an empty priority model list
Since:
1.0
Method Detail

makeStandardModels

public final void makeStandardModels(Kernel kernel)
Makes the standard models which includes three models:
  • Infinite relative worths (not editable)
  • Relative worths of 5 to 1 (not editable)
  • Customizable relative worths with a default of 10
  • Parameters:
    kernel - kernel being used
    Since:
    1.0

    addPriorityModels

    public final void addPriorityModels(PriorityModel[] morePriorityModels)
    Adds the array of models to the end of the list and notifies registered Observers of the change.
    Parameters:
    morePriorityModels - array of models to add to list
    See Also:
    PriorityModel, Observer

    addPriorityModel

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

    removePriorityModelAt

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

    removePriorityModel

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

    removePriorityModelsAt

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

    getPriorityModels

    public final PriorityModel[] getPriorityModels()
    Returns an array of the priorityModels in the list.
    Returns:
    array of priorityModels in the list
    Since:
    1.0

    toString

    public java.lang.String toString()
    Returns "Number of priorityModels: " + priorityModels.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 priorityModels. 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

    initializeAfterDeserialization

    public final void initializeAfterDeserialization(Kernel kernel)
    Register as observer after deserialization.
    Parameters:
    kernel - kernel being used
    Since:
    1.0

    replace

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