Package jsl.utilities.controls
Class Controls
- java.lang.Object
-
- jsl.utilities.controls.Controls
-
- Direct Known Subclasses:
Distribution.RandomControls,DPopulation.DPopControls,RVControls,TwoStateMarkovChain.RandomControls
public abstract class Controls extends java.lang.ObjectThis class acts holds different types of Maps to allow named controls and their associated values to be viewed and set. A named control must be unique across all the different types. There should be a default value provided for each named control.Implementors of ControllableIfc are responsible for making instances of this class that are filled appropriately by implementing the fillControls() method.
The hasXControl() methods can be used to check if the control data type has been defined.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedControls()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddControllableIfcControl(java.lang.String key, ControllableIfc value)protected voidaddDoubleArrayControl(java.lang.String key, double[] value)protected voidaddDoubleControl(java.lang.String key, double value)protected voidaddFloatControl(java.lang.String key, float value)protected voidaddIntegerControl(java.lang.String key, int value)protected voidaddLongControl(java.lang.String key, long value)protected voidaddStringControl(java.lang.String key, java.lang.String value)double[]changeDoubleArrayControl(java.lang.String key, double[] value)Changes the value associated with the key to the supplied value.doublechangeDoubleControl(java.lang.String key, double value)Changes the value associated with the key to the supplied value.floatchangeFloatControl(java.lang.String key, float value)Changes the value of the key to the supplied value.intchangeIntegerControl(java.lang.String key, int value)Changes the value of the key to the supplied value.longchangeLongControl(java.lang.String key, long value)Changes the value of the key to the supplied value.java.lang.StringchangeStringControl(java.lang.String key, java.lang.String value)Changes the value associated with the key to the supplied value.protected voidcheckKey(java.lang.String key)Checks if name is null or if key is not defined as a controlbooleancontainsControl(java.lang.String name)Checks if the supplied key is contained in the controlsprotected abstract voidfillControls()booleangetBooleanControl(java.lang.String key)Gets the value associated with the supplied key.java.util.Set<java.lang.String>getBooleanControlKeySet()Returns an unmodifiable Set of the control's keys for Boolean Controlsjava.lang.ClassgetControlClass(java.lang.String name)Can be used to determine which of the getXControl(String key) methods to callControllableIfcgetControllableControl(java.lang.String key)Gets the value associated with the supplied key as a ControllableIfc.java.util.Set<java.lang.String>getControllableIfcControlKeySet()Returns an unmodifiable Set of the control's keys for RandomIfc Controlsjava.util.Set<java.lang.String>getControlNames()double[]getDoubleArrayControl(java.lang.String key)Gets the value associated with the supplied key as a double{].java.util.Set<java.lang.String>getDoubleArrayControlKeySet()Returns an unmodifiable Set of the control's keys for double[] ControlsintgetDoubleArrayControlSize(java.lang.String key)Returns the size (array length) of the DoubleArray control.doublegetDoubleControl(java.lang.String key)Gets the value associated with the supplied key as a double.java.util.Set<java.lang.String>getDoubleControlKeySet()Returns an unmodifiable Set of the control's keys for Double ControlsfloatgetFloatControl(java.lang.String key)Gets the value associated with the supplied key.java.util.Set<java.lang.String>getFloatControlKeySet()Returns an unmodifiable Set of the control's keys for Float ControlsintgetIntegerControl(java.lang.String key)Gets the value associated with the supplied key.java.util.Set<java.lang.String>getIntegerControlKeySet()Returns an unmodifiable Set of the control's keys for Integer ControlslonggetLongControl(java.lang.String key)Gets the value associated with the supplied key.java.util.Set<java.lang.String>getLongControlKeySet()Returns an unmodifiable Set of the control's keys for Long Controlsjava.lang.StringgetName()java.lang.StringgetStringControl(java.lang.String key)Gets the value associated with the supplied key as a String.java.util.Set<java.lang.String>getStringControlKeySet()Returns an unmodifiable Set of the control's keys for String ControlsbooleanhasBooleanControl()Returns true if at least one Boolean control has been setbooleanhasControllableIfcControl()Returns true if at least one RandomIfc control has been setbooleanhasDoubleArrayControl()Returns true if at least one double[] control has been setbooleanhasDoubleControl()Returns true if at least one Double control has been setbooleanhasFloatControl()Returns true if at least one Float control has been setbooleanhasIntegerControl()Returns true if at least one Integer control has been setbooleanhasLongControl()Returns true if at least one Long control has been setbooleanhasStringControl()Returns true if at least one String control has been setjava.lang.BooleansetBooleanControl(java.lang.String key, boolean value)Sets the value of the key to the supplied value.ControllableIfcsetControllableControl(java.lang.String key, ControllableIfc value)Sets the value associated with the key to the supplied value.protected voidsetName(java.lang.String name)Use for labeling, etcjava.lang.StringtoString()
-
-
-
Method Detail
-
fillControls
protected abstract void fillControls()
-
setName
protected final void setName(java.lang.String name)
Use for labeling, etc- Parameters:
name- the name of the control
-
getName
public final java.lang.String getName()
- Returns:
- the name of the control
-
addStringControl
protected final void addStringControl(java.lang.String key, java.lang.String value)- Parameters:
key- the name of the control, must not be null, must not already have been addedvalue- the value of the control
-
addDoubleControl
protected final void addDoubleControl(java.lang.String key, double value)- Parameters:
key- the name of the control, must not be null, must not already have been addedvalue- the value of the control
-
addIntegerControl
protected final void addIntegerControl(java.lang.String key, int value)- Parameters:
key- the name of the control, must not be null, must not already have been addedvalue- the value of the control
-
addFloatControl
protected final void addFloatControl(java.lang.String key, float value)- Parameters:
key- the name of the control, must not be null, must not already have been addedvalue- the value of the control
-
addLongControl
protected final void addLongControl(java.lang.String key, long value)- Parameters:
key- the name of the control, must not be null, must not already have been addedvalue- the value of the control
-
addDoubleArrayControl
protected final void addDoubleArrayControl(java.lang.String key, double[] value)- Parameters:
key- the name of the control, must not be null, must not already have been addedvalue- the value of the control
-
addControllableIfcControl
protected final void addControllableIfcControl(java.lang.String key, ControllableIfc value)- Parameters:
key- the name of the control, must not be null, must not already have been addedvalue- the value of the control
-
containsControl
public final boolean containsControl(java.lang.String name)
Checks if the supplied key is contained in the controls- Parameters:
name- the name of the control- Returns:
- true if is has the named control
-
checkKey
protected final void checkKey(java.lang.String key)
Checks if name is null or if key is not defined as a control- Parameters:
key- name of the control
-
getControlNames
public final java.util.Set<java.lang.String> getControlNames()
- Returns:
- an unmodifiable Set view of the control names
-
getControlClass
public final java.lang.Class getControlClass(java.lang.String name)
Can be used to determine which of the getXControl(String key) methods to call- Parameters:
name- the name of the control- Returns:
- the Class type of the control
-
getStringControl
public java.lang.String getStringControl(java.lang.String key)
Gets the value associated with the supplied key as a String. If the key is null or there is no control for the supplied key, then an exception occurs- Parameters:
key- the name of the control- Returns:
- the value
-
changeStringControl
public java.lang.String changeStringControl(java.lang.String key, java.lang.String value)Changes the value associated with the key to the supplied value. The key must already exist in the controls and cannot be null.- Parameters:
key- must not be nullvalue- the new value associated with the key- Returns:
- the previous value that was associated with the key
-
getDoubleControl
public double getDoubleControl(java.lang.String key)
Gets the value associated with the supplied key as a double. If the key is null or there is no control for the supplied key, then an exception occurs- Parameters:
key- the name of the control- Returns:
- the value of the control
-
changeDoubleControl
public double changeDoubleControl(java.lang.String key, double value)Changes the value associated with the key to the supplied value. If the key is null or there is no control for the supplied key, then an exception occurs- Parameters:
key- key with which the value is to be associatedvalue- the value to be associated with key- Returns:
- the previous value that was associated with the key
-
getDoubleArrayControl
public double[] getDoubleArrayControl(java.lang.String key)
Gets the value associated with the supplied key as a double{]. If the key is null or there is no control for the supplied key, then an exception occurs- Parameters:
key- the name of the control- Returns:
- a copy of the associated double[] is returned
-
getDoubleArrayControlSize
public int getDoubleArrayControlSize(java.lang.String key)
Returns the size (array length) of the DoubleArray control. If the key is null or there is no control for the supplied key, then an exception occurs- Parameters:
key- the name of the control- Returns:
- the size of the array
-
changeDoubleArrayControl
public double[] changeDoubleArrayControl(java.lang.String key, double[] value)Changes the value associated with the key to the supplied value. If the key is null or there is no control for the supplied key, then an exception occurs.The supplied array is copied.
- Parameters:
key- key with which the double[] value is to be associatedvalue- the double[] value to be associated with key, cannot be null, must be same size as original double[]- Returns:
- the previous double[] value that was associated with the key
-
getIntegerControl
public int getIntegerControl(java.lang.String key)
Gets the value associated with the supplied key. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- the name of the control- Returns:
- the value of the control
-
changeIntegerControl
public int changeIntegerControl(java.lang.String key, int value)Changes the value of the key to the supplied value. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- the name of the controlvalue- the value of the control- Returns:
- the previous value that was associated with the key
-
getLongControl
public long getLongControl(java.lang.String key)
Gets the value associated with the supplied key. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- the name of the control- Returns:
- the value of the control
-
changeLongControl
public long changeLongControl(java.lang.String key, long value)Changes the value of the key to the supplied value. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- the name of the controlvalue- the value of the control- Returns:
- the previous value that was associated with the key
-
getFloatControl
public float getFloatControl(java.lang.String key)
Gets the value associated with the supplied key. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- the name of the control- Returns:
- the value of the control
-
changeFloatControl
public float changeFloatControl(java.lang.String key, float value)Changes the value of the key to the supplied value. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- the name of the controlvalue- the value of the control- Returns:
- the previous value that was associated with the key
-
getBooleanControl
public boolean getBooleanControl(java.lang.String key)
Gets the value associated with the supplied key. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- the name of the control- Returns:
- the value of the control
-
setBooleanControl
public java.lang.Boolean setBooleanControl(java.lang.String key, boolean value)Sets the value of the key to the supplied value. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- the name of the controlvalue- the value of the control- Returns:
- the previous value that was associated with the key
-
getControllableControl
public ControllableIfc getControllableControl(java.lang.String key)
Gets the value associated with the supplied key as a ControllableIfc. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- the name of the control- Returns:
- the value of the control
-
setControllableControl
public ControllableIfc setControllableControl(java.lang.String key, ControllableIfc value)
Sets the value associated with the key to the supplied value. If the key is null or there is no control for the supplied key, then an exception occurs.- Parameters:
key- key with which the string form of value is to be associatedvalue- the value to be associated with key- Returns:
- the previous value that was associated with the key
-
hasStringControl
public boolean hasStringControl()
Returns true if at least one String control has been set- Returns:
- true if is has at least one
-
hasDoubleControl
public boolean hasDoubleControl()
Returns true if at least one Double control has been set- Returns:
- true if is has at least one
-
hasControllableIfcControl
public boolean hasControllableIfcControl()
Returns true if at least one RandomIfc control has been set- Returns:
- true if is has at least one
-
hasDoubleArrayControl
public boolean hasDoubleArrayControl()
Returns true if at least one double[] control has been set- Returns:
- true if is has at least one
-
hasIntegerControl
public boolean hasIntegerControl()
Returns true if at least one Integer control has been set- Returns:
- true if is has at least one
-
hasLongControl
public boolean hasLongControl()
Returns true if at least one Long control has been set- Returns:
- true if is has at least one
-
hasBooleanControl
public boolean hasBooleanControl()
Returns true if at least one Boolean control has been set- Returns:
- true if is has at least one
-
hasFloatControl
public boolean hasFloatControl()
Returns true if at least one Float control has been set- Returns:
- true if is has at least one
-
getStringControlKeySet
public java.util.Set<java.lang.String> getStringControlKeySet()
Returns an unmodifiable Set of the control's keys for String Controls- Returns:
- the unmodifiable set
-
getDoubleControlKeySet
public java.util.Set<java.lang.String> getDoubleControlKeySet()
Returns an unmodifiable Set of the control's keys for Double Controls- Returns:
- the unmodifiable set
-
getDoubleArrayControlKeySet
public java.util.Set<java.lang.String> getDoubleArrayControlKeySet()
Returns an unmodifiable Set of the control's keys for double[] Controls- Returns:
- the unmodifiable set
-
getIntegerControlKeySet
public java.util.Set<java.lang.String> getIntegerControlKeySet()
Returns an unmodifiable Set of the control's keys for Integer Controls- Returns:
- the unmodifiable set
-
getLongControlKeySet
public java.util.Set<java.lang.String> getLongControlKeySet()
Returns an unmodifiable Set of the control's keys for Long Controls- Returns:
- the unmodifiable set
-
getFloatControlKeySet
public java.util.Set<java.lang.String> getFloatControlKeySet()
Returns an unmodifiable Set of the control's keys for Float Controls- Returns:
- the unmodifiable set
-
getBooleanControlKeySet
public java.util.Set<java.lang.String> getBooleanControlKeySet()
Returns an unmodifiable Set of the control's keys for Boolean Controls- Returns:
- the unmodifiable set
-
getControllableIfcControlKeySet
public java.util.Set<java.lang.String> getControllableIfcControlKeySet()
Returns an unmodifiable Set of the control's keys for RandomIfc Controls- Returns:
- the unmodifiable set
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-