uchicago.src.sim.parameter
Class DefaultParameterSetter

java.lang.Object
  extended by uchicago.src.sim.parameter.AbstractParameterSetter
      extended by uchicago.src.sim.parameter.DefaultParameterSetter
All Implemented Interfaces:
ParameterSetter

public class DefaultParameterSetter
extends AbstractParameterSetter

Implementation of ParameterSetter that works with the original "{" style repast parameter format.

Version:
$Revision: 1.11 $ $Date: 2004/11/03 19:51:04 $

Nested Class Summary
 
Nested classes/interfaces inherited from class uchicago.src.sim.parameter.AbstractParameterSetter
AbstractParameterSetter.ParamName, AbstractParameterSetter.ParamNameIterator
 
Constructor Summary
DefaultParameterSetter()
          Creates a DefaultParameterSetter.
DefaultParameterSetter(java.lang.Object o, java.lang.String[] properties)
          Creates a DefaultParameterSetter to set parameter on the specified object.
 
Method Summary
 java.util.Hashtable getDefaultModelParameters(SimModel model)
          Returns a Hashtable whose keys are parameter names and values are parameter values.
 java.util.ArrayList getDynamicParameterNames()
           
 java.lang.Object getParameter(java.lang.String name)
          Gets the current value of a named parameter.
 java.lang.Class getParameterType(java.lang.String name)
           
 java.lang.Object getParameterValue(java.lang.String name, SimModel model)
          Gets the current value of a named parameter.
 boolean hasNext()
           
 void init(java.lang.String file)
          Initialize the setter using the specified file.
 boolean isConstant(java.lang.String name)
           
 boolean isParameter(java.lang.String name)
           
 java.util.Iterator parameterNames()
           
 void setModelParameters(SimModel model)
          Sets the parameters for the specified model.
 void setNextModelParameters(SimModel model)
          Increments the parameters in this ParameterSetter and then sets the model's parameters.
 
Methods inherited from class uchicago.src.sim.parameter.AbstractParameterSetter
capitalize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultParameterSetter

public DefaultParameterSetter()
Creates a DefaultParameterSetter.


DefaultParameterSetter

public DefaultParameterSetter(java.lang.Object o,
                              java.lang.String[] properties)
                       throws java.lang.IllegalAccessException,
                              java.lang.reflect.InvocationTargetException
Creates a DefaultParameterSetter to set parameter on the specified object. The names of the parameters to set are given the properties array.

Parameters:
o - the Object whose properties or parameters we want to set
properties - the name of those parameters
Throws:
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
Method Detail

init

public void init(java.lang.String file)
          throws java.io.IOException
Initialize the setter using the specified file. ParameterSetters will most often be created using reflection via a no-arg constructor. This init method functions like a proper constructor.

Parameters:
file - the name of the parameter file
Throws:
java.io.IOException

isParameter

public boolean isParameter(java.lang.String name)
Parameters:
name - the name of the parameter to test
Returns:
true if the specified name is the name of a parameter in this ParameterSetter; otherwise false.

isConstant

public boolean isConstant(java.lang.String name)
Parameters:
name - the name of the parameter to test
Returns:
true if the specified name is the name of a constant parameter in this ParameterSetter. false if the named parameter is not constant or if the named parameter is not found.

getDynamicParameterNames

public java.util.ArrayList getDynamicParameterNames()
Returns:
a list of the names dynamic (non-constant) parameters defined in this ParameterSetter.

getDefaultModelParameters

public java.util.Hashtable getDefaultModelParameters(SimModel model)
Returns a Hashtable whose keys are parameter names and values are parameter values. The parameters themselves are those specified by the model in getInitParam with the addition of the random seed and the value is the current parameter file value if the parameter exists in the parameter file. If not, then the value is that of the model.

Parameters:
model - the model whose parameters we want to get
Returns:
a Hashtable whose keys are parameter names and values are parameter values.

setModelParameters

public void setModelParameters(SimModel model)
Sets the parameters for the specified model. Sets the model's parameters to the current values of the parameters contained by this ParameterSetter.

Parameters:
model - the model whose parameters are set

hasNext

public boolean hasNext()
Returns:
true if the parameter space described by this ParameterSetter has more parameter combinations to be explored; false if not.

setNextModelParameters

public void setNextModelParameters(SimModel model)
Increments the parameters in this ParameterSetter and then sets the model's parameters.

Parameters:
model - the model whose parameters are set

getParameterValue

public java.lang.Object getParameterValue(java.lang.String name,
                                          SimModel model)
Gets the current value of a named parameter. A reference to the model may be necessary for those ParameterSetters whose formats allow for some interaction with the model.

Parameters:
name - the name of the parameter
model - a reference to the SimModel associated with these parameters
Returns:
the current value of the named parameter. Returns null if the parameter is not found.

getParameter

public java.lang.Object getParameter(java.lang.String name)
Gets the current value of a named parameter. A reference to the model may be necessary for those ParameterSetters whose formats allow for some interaction with the model.

Parameters:
name - the name of the parameter
model - a reference to the SimModel associated with these parameters
Returns:
the named parameter. Returns null if the parameter is not found.

parameterNames

public java.util.Iterator parameterNames()
Returns:
An iterator returning the names of the parameters contained in this ParameterSetter.

getParameterType

public java.lang.Class getParameterType(java.lang.String name)