Klasse FWSimHelper

java.lang.Object
net.simplace.sim.util.FWSimHelper

public class FWSimHelper extends Object
Helper instance consisting of helper methods with instances of an operation tree parser to evaluate rules while replacing parameters in variables
Autor:
Andreas Enders
  • Felddetails

    • PARAMPATTERN

      public static final Pattern PARAMPATTERN
      [$][{][^},^{]*[}]
    • PARAMSEARCHPATTERN

      public static final Pattern PARAMSEARCHPATTERN
      [$][{][^},^{]*[}]
    • EXPRESSIONPATTERN

      public static final Pattern EXPRESSIONPATTERN
      [!][A-Z]*:.*[!]
    • ARRAYVALUEPATTERN

      public static final Pattern ARRAYVALUEPATTERN
      [!][A-Z]*:.*[!]
    • FIELD_COMPERATOR

      public static Comparator<FWSimFieldContainer> FIELD_COMPERATOR
    • SIM_VAR_COMARATOR

      public static final Comparator<FWSimVariable<?>> SIM_VAR_COMARATOR
      Instantiates the Comparator for SimVariables to order them within the SimComponent (used for nice output)
  • Konstruktordetails

    • FWSimHelper

      public FWSimHelper()
  • Methodendetails

    • replaceParamTokens

      public static String replaceParamTokens(FWSimVarMap aParamMap, String aValue, Object aDefault)
      replaces Parameters in
      Parameter:
      aParamMap -
      aValue - matching the regexp '.*[${].*[}].*' with given parameters in
      aDefault -
      Gibt zurück:
      aNewValue
    • getValueFromSpecialParameter

      public static Object getValueFromSpecialParameter(FWSimVarMap aParamMap, String aKey, Object aDefault)
      getting parameter value from key if value is Map, Array, List or Date using '!' as a separator.
      Parameter:
      aParamMap -
      aKey -
      aDefault -
      Gibt zurück:
      the new value object - if not retrieved the default.
    • getParametersFromString

      public static Set<String> getParametersFromString(Pattern pattern, String aString)
      Parameter:
      pattern -
      aString -
      Gibt zurück:
      parameters from a given aString
    • ArrayToLinkedMap

      public static LinkedHashMap<String,String> ArrayToLinkedMap(Object[] aArray)
      converts a Object[] to a LinkedHashMap
      Parameter:
      aArray -
      Gibt zurück:
      the fixed ordered tree map
    • ArrayToMap

      public static TreeMap<Double,Double> ArrayToMap(Double[] aArray)
      converts a double[] to a tree map
      Parameter:
      aArray -
      Gibt zurück:
      the fixed ordered tree map
    • findSimComponents

      public static List<String> findSimComponents()
      Gibt zurück:
      a List of Strings representing the Classes extended from FWSimComponent
    • findResources

      public static Collection<String> findResources(String aPackage, String aRegexp)
      Parameter:
      aPackage -
      aRegexp -
      Gibt zurück:
      a List of Strings representing the Classes extended from FWSimComponent
    • findResourceTransformers

      public static List<String> findResourceTransformers()
      Gibt zurück:
      a List of Strings representing the Classes extended from FWSimResourceTransformer
    • findSelectors

      public static List<String> findSelectors()
      Gibt zurück:
      a List of Strings representing the Classes extended from FWSimulationSelector
    • findGenerators

      public static List<String> findGenerators()
      Gibt zurück:
      a List of Strings representing the Classes extended from FWSimulationSelector
    • findIterators

      public static List<String> findIterators()
      Gibt zurück:
      a List of Strings representing the Classes extended from FWSimulationSelector
    • showFields

      public static void showFields(FWSimFieldContainer aVertex)
      Parameter:
      aVertex -
    • edit

      public static void edit(FWSimFieldContainer aContainer, boolean aEnabled)
      Parameter:
      aContainer -
      aEnabled -
    • getDataTypeFromValue

      public static FWSimVariable.DATA_TYPE getDataTypeFromValue(String aFirstValue)
      Parameter:
      aFirstValue -
      Gibt zurück:
      the fitting data type
    • getObjectArrayFromVarMap

      public static Object[][] getObjectArrayFromVarMap(FWSimVarMap aVarMap)
      Parameter:
      aVarMap -
      Gibt zurück:
      the Object Array containing keys and values of the data
    • getParameterName

      public static String getParameterName(String aKey)
      Parameter:
      aKey -
      Gibt zurück:
      the first parameter in the key string
    • unzipArray

      public static Object unzipArray(FWSimVariable<?> aTargetVariable, ArrayList<String> aFieldMapIndizes, Object[] aSourceArray, Set<String> aParametersFromString, FWSimFieldContainer aContainer)
      Implement rules for expressions like !UNZIP_KEYS(${C[])! = A[] !UNZIP_VALUES(${C[]})! = B[]
      Parameter:
      aTargetVariable -
      aFieldMapIndizes -
      aSourceArray -
      aParametersFromString -
      aContainer -
      Gibt zurück:
      the unzipped array
    • zipArray

      public static Object zipArray(FWSimVariable<?> aTargetVariable, ArrayList<String> aFieldMapIndizes, Object[] aSourceArray, Set<String> aParametersFromString, FWSimFieldContainer aContainer)
      Implemented rules for expressions like !ZIP(${A[]},${B[]})! = C[]
      Parameter:
      aTargetVariable -
      aFieldMapIndizes -
      aSourceArray -
      aParametersFromString -
      aContainer -
      Gibt zurück:
      the zipped Array
    • filterVarMap

      public static HashMap<String,FWSimVariable<?>> filterVarMap(HashMap<String,FWSimVariable<?>> aMap, String aRegexp)
      Parameter:
      aMap -
      aRegexp -
      Gibt zurück:
      returns a HashMap that contains only the entries whose keys matched the regexp
    • addResourceFiles

      public static File addResourceFiles(String aWorkDir, String aSimulationExperimentPath, String aSolutionFileName, String aProjectFileName) throws MissingSimResourceException
      Parameter:
      aWorkDir -
      aSimulationExperimentPath -
      aSolutionFileName -
      aProjectFileName -
      Gibt zurück:
      the ZipFile with all resources of the simulation experiment.
      Löst aus:
      MissingSimResourceException
    • logInitialInfo

      public static void logInitialInfo(boolean aForce)
      Log system information at beginning of the application start
      Parameter:
      aForce -
    • prepareDatabase

      public static PreparedStatement prepareDatabase(String aTableName, HashMap<String,FWSimVariable<?>> aHeaderVariables, String aConnectionPoolDefault, boolean aDropIfExists, boolean aDoCreateTable) throws SQLException
      Parameter:
      aTableName -
      aHeaderVariables -
      aConnectionPoolDefault -
      aDropIfExists -
      aDoCreateTable -
      Gibt zurück:
      the preparedStatement
      Löst aus:
      SQLException
    • prepareLimitedSelect

      public static PreparedStatement prepareLimitedSelect(String aTableName, HashMap<String,FWSimVariable<?>> aFieldMap, String aConnectionPoolDefault) throws SQLException
      Parameter:
      aTableName -
      aFieldMap -
      aConnectionPoolDefault -
      aSimulationsList -
      Gibt zurück:
      the prepared select Statement
      Löst aus:
      SQLException
    • prepareCountSelect

      public static PreparedStatement prepareCountSelect(String aTableName, String aConnectionPoolDefault) throws SQLException
      Parameter:
      aTableName -
      aConnectionPoolDefault -
      Gibt zurück:
      Löst aus:
      SQLException
    • generateSimulationID

      public static String generateSimulationID(Integer aProjectIteration, String aProjectID, String aSimulationName, Integer aSimulationNumber)
    • splitProjectDataBySimulationCount

      public static LinkedHashMap<String,String> splitProjectDataBySimulationCount(File aProjectDataFile, String aDivider, int aSplitCount)
      Parameter:
      aProjectDataFile -
      aDivider -
      aSplitCount -
      Gibt zurück:
      a list divided by aSplitNumber
    • splitProjectDataBySimulationCount

      public static LinkedHashMap<String,String> splitProjectDataBySimulationCount(File aProjectDataFile, String aDivider, int aSplitNumber, String[][] aReadCSVtoArray)
    • splitProjectDataByNumberOfCores

      public static List<String> splitProjectDataByNumberOfCores(File aProjectDataFile, String aDivider, int[] aListOfCores)
      Parameter:
      aProjectDataFile -
      aDivider -
      aListOfCores -
      Gibt zurück:
      a list divided by aListOfCores
    • checkForAction

      public static Boolean checkForAction(LocalDateTime aCurrentDate, FWSimIOAdapter.FREQUENCE aFrequence, JexlRuleScript aJexlScript, FWSimVarMap aVarMap)