Class ScriptTools
- java.lang.Object
-
- de.aristaflow.adept2.model.scripts.ScriptTools
-
public final class ScriptTools extends Object
Common functionality to detect and parse script declarations etc. in staff assignment rules.- Author:
- Patrick Schmidt
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
containsParameterReferences(Script script)
Returns whether the given script contains parameter references.static boolean
hasParameterDeclaration(String string)
Returnstrue
if the given string is a script declaration and contains at least the parentheses of the parameter declaration are present;false
otherwise.static boolean
isScript(String string)
Returns whether the given string is a script declaration (identified by its prefix).static Script
parseScriptDeclaration(String script)
Parses the given script declaration in its string form and returns it as object where the components are easily accessible.static Script
parseScriptDeclaration(String script, boolean paramRefsAllowed)
Parses the given script declaration in its string form and returns it as object where the components are easily accessible.static Script
resolveParameterReferences(Script script, Map<String,Serializable> paramValues)
Resolves the parameter references of the given script using the available values.
-
-
-
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)
Returnstrue
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 declarationparamRefsAllowed
- 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 referencesparamValues
- the available parameter values- Returns:
- a new script with all parameter references resolved
- Throws:
ScriptException
- if not all parameter references could be resolved
-
-