Class ScriptTools


  • public final class ScriptTools
    extends Object
    Common functionality to detect and parse script declarations etc. in staff assignment rules.
    Author:
    Patrick Schmidt
    • Method Detail

      • isScript

        public static boolean isScript​(String string)
        Returns whether the given string is a script declaration (identified by its prefix).
        Parameters:
        string - the string to be tested
        Returns:
        whether the given string is a script declaration
      • hasParameterDeclaration

        public static boolean hasParameterDeclaration​(String string)
        Returns true if the given string is a script declaration and contains at least the parentheses of the parameter declaration are present; false otherwise.
        Parameters:
        string - the string to be tested
        Returns:
        whether the given script contains a parameter declaration
      • parseScriptDeclaration

        public static Script parseScriptDeclaration​(String script)
                                             throws ScriptException
        Parses the given script declaration in its string form and returns it as object where the components are easily accessible. Parameter references are allowed.
        Parameters:
        script - the script declaration
        Returns:
        the parsed script declaration
        Throws:
        ScriptException - if the script declaration could not be parsed
      • parseScriptDeclaration

        public static Script parseScriptDeclaration​(String script,
                                                    boolean paramRefsAllowed)
                                             throws ScriptException
        Parses the given script declaration in its string form and returns it as object where the components are easily accessible.
        Parameters:
        script - the script declaration
        paramRefsAllowed - whether parameter references are allowed
        Returns:
        the parsed script declaration
        Throws:
        ScriptException - if the script declaration could not be parsed; if parameter references are encountered but no allowed
      • containsParameterReferences

        public static boolean containsParameterReferences​(Script script)
        Returns whether the given script contains parameter references.
        Parameters:
        script - the script to be tested
        Returns:
        whether the given script contains parameter references
      • resolveParameterReferences

        public static Script resolveParameterReferences​(Script script,
                                                        Map<String,​Serializable> paramValues)
                                                 throws ScriptException
        Resolves the parameter references of the given script using the available values.
        Parameters:
        script - the script containing parameter references
        paramValues - the available parameter values
        Returns:
        a new script with all parameter references resolved
        Throws:
        ScriptException - if not all parameter references could be resolved