Class ScriptUtil


  • public final class ScriptUtil
    extends Object
    Author:
    Sebastian Menski
    • Constructor Detail

      • ScriptUtil

        public ScriptUtil()
    • Method Detail

      • getScript

        public static ExecutableScript getScript​(String language,
                                                 String source,
                                                 String resource,
                                                 ExpressionManager expressionManager)
        Creates a new ExecutableScript from a source or resource. It excepts static and dynamic sources and resources. Dynamic means that the source or resource is an expression which will be evaluated during execution.
        Parameters:
        language - the language of the script
        source - the source code of the script or an expression which evaluates to the source code
        resource - the resource path of the script code or an expression which evaluates to the resource path
        expressionManager - the expression manager to use to generate the expressions of dynamic scripts
        Returns:
        the newly created script
        Throws:
        NotValidException - if language is null or empty or both of source and resource are null or empty
      • getScript

        public static ExecutableScript getScript​(String language,
                                                 String source,
                                                 String resource,
                                                 ExpressionManager expressionManager,
                                                 ScriptFactory scriptFactory)
        Creates a new ExecutableScript from a source or resource. It excepts static and dynamic sources and resources. Dynamic means that the source or resource is an expression which will be evaluated during execution.
        Parameters:
        language - the language of the script
        source - the source code of the script or an expression which evaluates to the source code
        resource - the resource path of the script code or an expression which evaluates to the resource path
        expressionManager - the expression manager to use to generate the expressions of dynamic scripts
        scriptFactory - the script factory used to create the script
        Returns:
        the newly created script
        Throws:
        NotValidException - if language is null or empty or both of source and resource are invalid
      • getScriptFormSource

        public static ExecutableScript getScriptFormSource​(String language,
                                                           String source,
                                                           ExpressionManager expressionManager,
                                                           ScriptFactory scriptFactory)
        Creates a new ExecutableScript from a source. It excepts static and dynamic sources. Dynamic means that the source is an expression which will be evaluated during execution.
        Parameters:
        language - the language of the script
        source - the source code of the script or an expression which evaluates to the source code
        expressionManager - the expression manager to use to generate the expressions of dynamic scripts
        scriptFactory - the script factory used to create the script
        Returns:
        the newly created script
        Throws:
        NotValidException - if language is null or empty or source is null
      • getScriptFromSource

        public static ExecutableScript getScriptFromSource​(String language,
                                                           String source,
                                                           ScriptFactory scriptFactory)
        Creates a new ExecutableScript from a static source.
        Parameters:
        language - the language of the script
        source - the source code of the script
        scriptFactory - the script factory used to create the script
        Returns:
        the newly created script
        Throws:
        NotValidException - if language is null or empty or source is null
      • getScriptFromSourceExpression

        public static ExecutableScript getScriptFromSourceExpression​(String language,
                                                                     Expression sourceExpression,
                                                                     ScriptFactory scriptFactory)
        Creates a new ExecutableScript from a dynamic source. Dynamic means that the source is an expression which will be evaluated during execution.
        Parameters:
        language - the language of the script
        sourceExpression - the expression which evaluates to the source code
        scriptFactory - the script factory used to create the script
        Returns:
        the newly created script
        Throws:
        NotValidException - if language is null or empty or sourceExpression is null
      • getScriptFromResource

        public static ExecutableScript getScriptFromResource​(String language,
                                                             String resource,
                                                             ExpressionManager expressionManager,
                                                             ScriptFactory scriptFactory)
        Creates a new ExecutableScript from a resource. It excepts static and dynamic resources. Dynamic means that the resource is an expression which will be evaluated during execution.
        Parameters:
        language - the language of the script
        resource - the resource path of the script code or an expression which evaluates to the resource path
        expressionManager - the expression manager to use to generate the expressions of dynamic scripts
        scriptFactory - the script factory used to create the script
        Returns:
        the newly created script
        Throws:
        NotValidException - if language or resource are null or empty
      • getScriptFromResource

        public static ExecutableScript getScriptFromResource​(String language,
                                                             String resource,
                                                             ScriptFactory scriptFactory)
        Creates a new ExecutableScript from a static resource.
        Parameters:
        language - the language of the script
        resource - the resource path of the script code
        scriptFactory - the script factory used to create the script
        Returns:
        the newly created script
        Throws:
        NotValidException - if language or resource are null or empty
      • getScriptFromResourceExpression

        public static ExecutableScript getScriptFromResourceExpression​(String language,
                                                                       Expression resourceExpression,
                                                                       ScriptFactory scriptFactory)
        Creates a new ExecutableScript from a dynamic resource. Dynamic means that the source is an expression which will be evaluated during execution.
        Parameters:
        language - the language of the script
        resourceExpression - the expression which evaluates to the resource path
        scriptFactory - the script factory used to create the script
        Returns:
        the newly created script
        Throws:
        NotValidException - if language is null or empty or resourceExpression is null
      • isDynamicScriptExpression

        public static boolean isDynamicScriptExpression​(String language,
                                                        String value)
        Checks if the value is an expression for a dynamic script source or resource.
        Parameters:
        language - the language of the script
        value - the value to check
        Returns:
        true if the value is an expression for a dynamic script source/resource, otherwise false
      • getScriptFactory

        public static ScriptFactory getScriptFactory()
        Returns the configured script factory in the context or a new one.