Class ReadInputParameters

java.lang.Object
nl.tudelft.simulation.dsol.model.inputparameters.reader.ReadInputParameters

public final class ReadInputParameters extends Object
Read InputParameters from a Properties file or from an array of Strings. For the properties file, the format is one parameter per line. Keys for the sub-parameters are indicated with a dot notation. The general format is key=value. The value for an integer value called 'nrServers' in the root category:
 nrServers = 2
 
The key for a Duration parameter called 'serviceTime' in the category 'server':
 server.serviceTime = 5.0min
 

Copyright (c) 2003-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information www.simulation.tudelft.nl. The source code and binary code of this software is proprietary information of Delft University of Technology.
Author:
Alexander Verbraeck
  • Method Details

    • loadfromProperties

      public static void loadfromProperties(String filename, InputParameterMap map) throws InputParameterException, FileNotFoundException, IOException
      Read the input parameters from a properties file. Note: the input parameter map given as input will be used to store the values read.
      Parameters:
      filename - String; the file to read (URLResource is used to resolve the file), with one key=value entry per line
      map - InputParameterMap; the map of input parameters to be read
      Throws:
      InputParameterException - when the parameter cannot be found or is given an illegal value
      FileNotFoundException - when the file cannot be found
      IOException - on read error from properties file
    • loadFromArgs

      public static void loadFromArgs(String[] args, boolean ignore, InputParameterMap map) throws InputParameterException
      Read the input parameters from an array of Strings, e.g. the args of a command line execution. Note: the input parameter map given as input will be used to store the values read. Do not use whitespace on either side of the equals sign. Values with spaces can be escaped with double quotes or single quotes. These quotes will be removed. Escaping the first single or double quote can be done with a backslash.
      Parameters:
      args - String[]; the strings to contain the parameters with one key=value entry per string
      ignore - boolean; whether to ignore entries without an 'equals' sign
      map - InputParameterMap; the map of input parameters to be read
      Throws:
      InputParameterException - when the parameter cannot be found or is given an illegal value
    • loadFromArgs

      public static void loadFromArgs(String[] args, InputParameterMap map) throws InputParameterException
      Read the input parameters from an array of Strings, e.g. the args of a command line execution. Note: the input parameter map given as input will be used to store the values read. This method ignores arguments without an 'equals' sign. Do not use whitespace on either side of the equals sign. Values with spaces can be escaped with double quotes or single quotes. These quotes will be removed. Escaping the first single or double quote can be done with a backslash.
      Parameters:
      args - String[]; the strings to contain the parameters with one key=value entry per string
      map - InputParameterMap; the map of input parameters to be read
      Throws:
      InputParameterException - when the parameter cannot be found or is given an illegal value
    • setParameter

      public static void setParameter(InputParameter<?,?> parameter, String value) throws InputParameterException
      Set a parameter in the input parameter map based on a String value.
      Parameters:
      parameter - the parameter to set
      value - the String value of the parameter
      Throws:
      InputParameterException - when the parameter value is illegal