Class ReadInputParameters
java.lang.Object
nl.tudelft.simulation.dsol.model.inputparameters.reader.ReadInputParameters
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:
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.
nrServers = 2The 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 Summary
Modifier and TypeMethodDescriptionstatic void
loadFromArgs
(String[] args, boolean ignore, InputParameterMap map) Read the input parameters from an array of Strings, e.g.static void
loadFromArgs
(String[] args, InputParameterMap map) Read the input parameters from an array of Strings, e.g.static void
loadfromProperties
(String filename, InputParameterMap map) Read the input parameters from a properties file.static void
setParameter
(InputParameter<?, ?> parameter, String value) Set a parameter in the input parameter map based on a String value.
-
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 linemap
- InputParameterMap; the map of input parameters to be read- Throws:
InputParameterException
- when the parameter cannot be found or is given an illegal valueFileNotFoundException
- when the file cannot be foundIOException
- 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 stringignore
- boolean; whether to ignore entries without an 'equals' signmap
- 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 stringmap
- 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 InputParameterExceptionSet a parameter in the input parameter map based on a String value.- Parameters:
parameter
- the parameter to setvalue
- the String value of the parameter- Throws:
InputParameterException
- when the parameter value is illegal
-