Class ScriptTools
java.lang.Object
de.aristaflow.adept2.model.scripts.ScriptTools
Common functionality to detect and parse script declarations etc. in staff
assignment rules.
- Author:
- Patrick Schmidt
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsParameterReferences(Script script) Returns whether the given script contains parameter references.static booleanhasParameterDeclaration(String string) Returnstrueif the given string is a script declaration and contains at least the parentheses of the parameter declaration are present;falseotherwise.static booleanReturns whether the given string is a script declaration (identified by its prefix).static ScriptparseScriptDeclaration(String script) Parses the given script declaration in its string form and returns it as object where the components are easily accessible.static ScriptparseScriptDeclaration(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 ScriptresolveParameterReferences(Script script, Map<String, Serializable> paramValues) Resolves the parameter references of the given script using the available values.
-
Method Details
-
isScript
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
Returnstrueif the given string is a script declaration and contains at least the parentheses of the parameter declaration are present;falseotherwise.- Parameters:
string- the string to be tested- Returns:
- whether the given script contains a parameter declaration
-
parseScriptDeclaration
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
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 ScriptExceptionResolves 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
-