Class Controls

  • Direct Known Subclasses:
    Distribution.RandomControls, DPopulation.DPopControls, RVControls, TwoStateMarkovChain.RandomControls

    public abstract class Controls
    extends java.lang.Object
    This 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
      protected Controls()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addControllableIfcControl​(java.lang.String key, ControllableIfc value)  
      protected void addDoubleArrayControl​(java.lang.String key, double[] value)  
      protected void addDoubleControl​(java.lang.String key, double value)  
      protected void addFloatControl​(java.lang.String key, float value)  
      protected void addIntegerControl​(java.lang.String key, int value)  
      protected void addLongControl​(java.lang.String key, long value)  
      protected void addStringControl​(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.
      double changeDoubleControl​(java.lang.String key, double value)
      Changes the value associated with the key to the supplied value.
      float changeFloatControl​(java.lang.String key, float value)
      Changes the value of the key to the supplied value.
      int changeIntegerControl​(java.lang.String key, int value)
      Changes the value of the key to the supplied value.
      long changeLongControl​(java.lang.String key, long value)
      Changes the value of the key to the supplied value.
      java.lang.String changeStringControl​(java.lang.String key, java.lang.String value)
      Changes the value associated with the key to the supplied value.
      protected void checkKey​(java.lang.String key)
      Checks if name is null or if key is not defined as a control
      boolean containsControl​(java.lang.String name)
      Checks if the supplied key is contained in the controls
      protected abstract void fillControls()  
      boolean getBooleanControl​(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 Controls
      java.lang.Class getControlClass​(java.lang.String name)
      Can be used to determine which of the getXControl(String key) methods to call
      ControllableIfc getControllableControl​(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 Controls
      java.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[] Controls
      int getDoubleArrayControlSize​(java.lang.String key)
      Returns the size (array length) of the DoubleArray control.
      double getDoubleControl​(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 Controls
      float getFloatControl​(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 Controls
      int getIntegerControl​(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 Controls
      long getLongControl​(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 Controls
      java.lang.String getName()  
      java.lang.String getStringControl​(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 Controls
      boolean hasBooleanControl()
      Returns true if at least one Boolean control has been set
      boolean hasControllableIfcControl()
      Returns true if at least one RandomIfc control has been set
      boolean hasDoubleArrayControl()
      Returns true if at least one double[] control has been set
      boolean hasDoubleControl()
      Returns true if at least one Double control has been set
      boolean hasFloatControl()
      Returns true if at least one Float control has been set
      boolean hasIntegerControl()
      Returns true if at least one Integer control has been set
      boolean hasLongControl()
      Returns true if at least one Long control has been set
      boolean hasStringControl()
      Returns true if at least one String control has been set
      java.lang.Boolean setBooleanControl​(java.lang.String key, boolean value)
      Sets the value of the key to the supplied value.
      ControllableIfc setControllableControl​(java.lang.String key, ControllableIfc value)
      Sets the value associated with the key to the supplied value.
      protected void setName​(java.lang.String name)
      Use for labeling, etc
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Controls

        protected Controls()
    • 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 added
        value - 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 added
        value - 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 added
        value - 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 added
        value - 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 added
        value - 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 added
        value - 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 added
        value - 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 null
        value - 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 associated
        value - 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 associated
        value - 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 control
        value - 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 control
        value - 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 control
        value - 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 control
        value - 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 associated
        value - 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:
        toString in class java.lang.Object