Class Defaults

java.lang.Object
common.Defaults
All Implemented Interfaces:
CommonConstants, EngineNodeConstants

public class Defaults extends Object implements CommonConstants

Title: Simulation Defaults

Description: This class will provide methods to get default values of every parameter that can be set by the user. Default values can be overridden and will be saved on a config file.

Author:
Bertoli Marco Date: 12-lug-2005 Time: 14.04.02 Modified by Francesco D'Aquino 15/11/2005 Modified by Ashanka (July 2010) Desc: Added new defaults control of a Random CheckBox.
  • Field Details

  • Constructor Details

    • Defaults

      public Defaults()
  • Method Details

    • getDefaults

      protected static Properties getDefaults()
      Sets default properties. This function is called only once before initializing internal data structure. Upon inserting a new property, this function MUST be extended.
      Returns:
      default (factory hard coded) initial properties
    • getProperties

      public static Properties getProperties()
      Returns inner properties data structure
      Returns:
      inner properties data structure
    • get

      public static String get(String parameterName)
      Returns default value of chosen parameter
      Parameters:
      parameterName - name of the parameter to be selected
      Returns:
      selected parameter default value in String format
    • getAsInteger

      public static Integer getAsInteger(String parameterName)
      Returns default value of chosen parameter in Integer form
      Parameters:
      parameterName - name of the parameter to be selected
      Returns:
      selected parameter default value in Integer format
      Throws:
      NumberFormatException - if the parameter does not contain a parsable integer
    • getAsLong

      public static Long getAsLong(String parameterName)
      Returns default value of chosen parameter in Long form
      Parameters:
      parameterName - name of the parameter to be selected
      Returns:
      selected parameter default value in Long format
      Throws:
      NumberFormatException - if the parameter does not contain a parsable long
    • getAsDouble

      public static Double getAsDouble(String parameterName)
      Returns default value of chosen parameter in Double form
      Parameters:
      parameterName - name of the parameter to be selected
      Returns:
      selected parameter default value in Double format
      Throws:
      NumberFormatException - if the parameter does not contain a parsable integer
    • getAsBoolean

      public static Boolean getAsBoolean(String parameterName)
      Returns default value of chosen parameter in Boolean form
      Parameters:
      parameterName - name of the parameter to be selected
      Returns:
      selected parameter default value in Boolean format
    • getAsNewInstance

      public static Object getAsNewInstance(String parameterName)
      Returns a new instance of default value of chosen parameter. Uses reflection to instantiate selected parameter's class.
      Parameters:
      parameterName - name of the parameter to be selected
      Returns:
      new instance of default value for selected parameter or null if value of this parameter is not a class to be instantiated
    • set

      public static void set(String parameterName, String value)
      Sets a default value for a chosen parameter
      Parameters:
      parameterName - name of the parameter to be chosen
      value - new default value to be associated with given parameter
    • save

      public static boolean save()
      Saves current default values into FILENAME
      Returns:
      true iff file was correctly saved
    • reload

      public static void reload()
      Reloads current default values from FILENAME
    • revertToDefaults

      public static void revertToDefaults()
      Reverts current values to original default ones (hard coded)
    • getWorkingPath

      public static File getWorkingPath()
      Returns the working directory. Creates it if it does not exist.
      Returns:
      the working directory for JMT files