Class ScalarGlobalVariable

All Implemented Interfaces:
AsciiSerializable, FieldAccessor, GlobalVariable, Serializable, Cloneable, Comparable, Observer, rma.lang.Modifiable

public class ScalarGlobalVariable extends BaseGlobalVariable implements GlobalVariable
See Also:
  • Field Details

  • Constructor Details

    • ScalarGlobalVariable

      public ScalarGlobalVariable()
    • ScalarGlobalVariable

      public ScalarGlobalVariable(RssSystem network)
  • Method Details

    • clone

      public ScalarGlobalVariable clone()
      Description copied from class: NamedType
      Creates a new object of the same class as this object.
      It then initializes each of the new object's fields by assigning it the same value as the corresponding field in this object. No
      constructor is called.
      Specified by:
      clone in interface GlobalVariable
      Overrides:
      clone in class BaseGlobalVariable
    • getType

      public GlobalVariableType getType()
      Specified by:
      getType in interface GlobalVariable
    • setSelectionList

      public void setSelectionList(List<String> selectionList)
      set the selection list
      Parameters:
      selectionList - the new selection list
    • setValue

      public void setValue(Object value)
      set the value on the ScalarGlobalVariable
      Parameters:
      value - the new value
    • setValue

      public void setValue(int value)
      set the value on the ScalarGlobalVariable
      Parameters:
      value - the new value
    • setValue

      public void setValue(double value)
      set the value on the ScalarGlobalVariable
      Parameters:
      value - the new value
    • setValue

      public void setValue(boolean value)
      set the value on the ScalarGlobalVariable
      Parameters:
      value - the new value
    • setMinLimit

      public void setMinLimit(Object minLimit)
      set the minimum limit for the input ScalarGlobalVariable
      Parameters:
      minLimit - the new minimum limit
    • setMinLimit

      public void setMinLimit(int minLimit)
      set the minimum limit for input ScalarGlobalVariables with a ScalarDataType of INTEGER
      Parameters:
      minLimit - the new minimum limit
    • setMinLimit

      public void setMinLimit(double minLimit)
      set the minimum limit for input ScalarGlobalVariables with a ScalarDataType of DOUBLE
      Parameters:
      minLimit - the new minimum limit
    • getMinLimit

      public Object getMinLimit()
      get the min limit, if set, for this ScalarGlobalVariable
      Returns:
      the min limit or null if not set
    • getMinLimit

      public Object getMinLimit(RunTimeStep rts)
      get the min limit, if set, for this ScalarGlobalVariable. This method should be used for SeasonalDates
      Parameters:
      rts - the current RunTimeStep.
      Returns:
      the min limit or null if not set
    • getMaxLimit

      public Object getMaxLimit()
      get the max limit, if set, for this ScalarGlobalVariable
      Returns:
      the max limit or null if not set
    • getMaxLimit

      public Object getMaxLimit(RunTimeStep rts)
      get the max limit, if set, for this ScalarGlobalVariable. This method should be used for SeasonalDates
      Parameters:
      rts - the current RunTimeStep.
      Returns:
      the max limit or null if not set
    • setMaxLimit

      public void setMaxLimit(Object maxLimit)
      Parameters:
      maxLimit -
    • setMaxLimit

      public void setMaxLimit(int maxLimit)
      set the maximum limit for ScalarGlobalVariables with a ScalarDataType of INTEGER
      Parameters:
      maxLimit - the new maximum limit
    • setMaxLimit

      public void setMaxLimit(double maxLimit)
      set the maximum limit for ScalarGlobalVariables with a ScalarDataType of DOUBLE
      Parameters:
      maxLimit - the new maximum limit
    • getSelectionList

      public List<String> getSelectionList()
      Returns:
    • appendToSelectionList

      public void appendToSelectionList(Object newItem)
      append an item to the selection list
      Parameters:
      newItem - the new non-null Item to append to the selection list
    • appendToSelectionList

      public void appendToSelectionList(int newInt)
      add an int to the selection list
      Parameters:
      newInt - the new int value to add to the selection list
    • appendToSelectionList

      public void appendToSelectionList(double newDouble)
      add a double to the selection list
      Parameters:
      newDouble - the new double value to add to the selection list
    • getSelectionListIndex

      public int getSelectionListIndex()
      get the index of the Scalar Variable's value in its selection list.
      Returns:
      -1 selection not found in list -2 not using selection list >0 index in list
    • getSelectionListLength

      public int getSelectionListLength()
      get the length of the selection list
      Returns:
      the length of the selection. 0 if empty
    • isSelection

      public boolean isSelection()
      Returns:
    • getDataType

      public ScalarDataType getDataType()
      Returns:
    • getValue

      public Object getValue()
      get the GlobalVariable's value. if this version of getValue() is called on a SeasonalDate then the year will be set to the Run Time Window's start year. returned types:
      • ScalarDataType.INTEGER -> Integer
      • lcalarDataType.DOUBLE -> Double
      • ScalarDataType.BOOLEAN -> Boolean
      • ScalarDataType.DAYOFWEEK -> hec.model.DayOfWeek
      • ScalarDataType.DATE -> hec.heclib.util.HecTime
      • ScalarDataType.MONTHOFYEAR -> java.time.Month
      • ScalarDataType.DATEANDTIME -> hec.heclib.util.HecTime
      • ScalarDataType.SEASONAL_DATE -> hec.heclib.util.HecTime
      • ScalarDataType.TIME -> java.time.LocalTime
      Returns:
      the GlobalVariable's value
    • getValue

      public Object getValue(RunTimeStep rts)
      get the GlobalVariable's value. this version of getValue() should be called for SeasonalDates so the year can be set appropriately
      Parameters:
      rts - the current RunTimeStep. can be null for most ScalarDataTypes except SeasonalDate
      Returns:
      the GlobalVariable's value
    • setDataType

      public void setDataType(ScalarDataType type)
    • setIsSelectionList

      public void setIsSelectionList(boolean selected)
      set that the global variable is using a selection list
      Parameters:
      selected -
    • setIsMinSelected

      public void setIsMinSelected(boolean selected)
      set that the global variable is using a min limit
      Parameters:
      selected -
    • setIsMaxSelected

      public void setIsMaxSelected(boolean selected)
      set that the global variable is using a max limit
      Parameters:
      selected -
    • isSelectionList

      public boolean isSelectionList()
      is the global variable using a selection list
      Returns:
      true if the global variable is using a selection list
    • isMinSelected

      public boolean isMinSelected()
      is the global variable using a minimum limit
      Returns:
      true if there is a min limit set
    • isMaxSelected

      public boolean isMaxSelected()
      is the the global variable using a max limit
      Returns:
      true if there is a max limit set
    • getMinLimitAsString

      public String getMinLimitAsString()
      get the minimum limit as a String
      Returns:
      a String that's the min limit
    • getMaxLimitAsString

      public String getMaxLimitAsString()
      get the maximum limit as a String
      Returns:
      a String that's the max limit
    • getDescriptiveText

      public String getDescriptiveText()
      return a short descriptive String of the global variable. used for things like tooltips
      Specified by:
      getDescriptiveText in interface GlobalVariable
      Returns:
      short description String of the global variable
    • getParameter

      public String getParameter()
      Returns:
    • setParameter

      public void setParameter(String parameter)
    • hasValidValue

      public String hasValidValue()
      check to see if the ScalarGlobalVariable has a valid value
      Specified by:
      hasValidValue in interface GlobalVariable
      Overrides:
      hasValidValue in class BaseGlobalVariable
      Returns:
      null if the value is valid or the ScalarGlobalVariable has no value
    • outputReport

      public void outputReport(AlternativeInputReport report, org.jdom.Element myElem)
      add the scalar global variable information to the alternative report
      Specified by:
      outputReport in interface GlobalVariable
      Overrides:
      outputReport in class BaseGlobalVariable
      Parameters:
      report - the Alternative Report
      myElem - the element for this global variable
    • getFieldObject

      public Object getFieldObject(Field fld)
      Description copied from interface: FieldAccessor
      This method allows access to java.lang.reflect.Field objects within the implementing class.
      Specified by:
      getFieldObject in interface FieldAccessor
      Overrides:
      getFieldObject in class BaseGlobalVariable
      Parameters:
      fld - The field to get.
      Returns:
      The data object that is stored in the given field
    • setFieldObject

      public boolean setFieldObject(Field fld, Object fobj)
      Description copied from interface: FieldAccessor
      This allows access to fields withing the implementing object to set there data.
      Specified by:
      setFieldObject in interface FieldAccessor
      Overrides:
      setFieldObject in class BaseGlobalVariable
      Parameters:
      fld - The java field object representing the member field to be set
      fobj - The data to set in that field
      Returns:
      returns true if successful