Class ScriptingUtils


  • public class ScriptingUtils
    extends java.lang.Object
    Since:
    5.1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      ScriptingUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T executeGroovyScript​(groovy.lang.GroovyObject groovyObject, java.lang.Object[] args, java.lang.Class<T> clazz, boolean failOnError)
      Execute groovy script.
      static <T> T executeGroovyScript​(groovy.lang.GroovyObject groovyObject, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<T> clazz, boolean failOnError)
      Execute groovy script t.
      static <T> T executeGroovyScript​(org.springframework.core.io.Resource groovyScript, java.lang.Object[] args, java.lang.Class<T> clazz, boolean failOnError)
      Execute groovy script via run object.
      static <T> T executeGroovyScript​(org.springframework.core.io.Resource groovyScript, java.lang.String methodName, java.lang.Class<T> clazz)
      Execute groovy script.
      static <T> T executeGroovyScript​(org.springframework.core.io.Resource groovyScript, java.lang.String methodName, java.lang.Class<T> clazz, java.lang.Object... args)
      Execute groovy script t.
      static <T> T executeGroovyScript​(org.springframework.core.io.Resource groovyScript, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<T> clazz, boolean failOnError)
      Execute groovy script.
      static <T> T executeGroovyScriptEngine​(java.lang.String script, java.util.Map<java.lang.String,​java.lang.Object> variables, java.lang.Class<T> clazz)
      Execute inline groovy script engine.
      static <T> T executeGroovyShellScript​(groovy.lang.Script script, java.lang.Class<T> clazz)
      Execute groovy shell script t.
      static <T> T executeGroovyShellScript​(groovy.lang.Script script, java.util.Map<java.lang.String,​java.lang.Object> variables, java.lang.Class<T> clazz)
      Execute groovy shell script t.
      static <T> T executeScriptEngine​(java.lang.String scriptFile, java.lang.Object[] args, java.lang.Class<T> clazz)
      Execute groovy script engine t.
      static java.util.regex.Matcher getMatcherForExternalGroovyScript​(java.lang.String script)
      Gets groovy file script matcher.
      static java.util.regex.Matcher getMatcherForInlineGroovyScript​(java.lang.String script)
      Gets inline groovy script matcher.
      static <T> T getObjectInstanceFromGroovyResource​(org.springframework.core.io.Resource resource, java.lang.Class[] constructorArgs, java.lang.Object[] args, java.lang.Class<T> expectedType)
      Gets object instance from groovy resource.
      static <T> T getObjectInstanceFromGroovyResource​(org.springframework.core.io.Resource resource, java.lang.Class<T> expectedType)
      Gets object instance from groovy resource.
      static java.lang.String getScriptEngineName​(java.lang.String scriptFile)
      Gets script engine name.
      static boolean isExternalGroovyScript​(java.lang.String script)
      Is external groovy script ?.
      static boolean isInlineGroovyScript​(java.lang.String script)
      Is inline groovy script ?.
      static groovy.lang.GroovyObject parseGroovyScript​(org.springframework.core.io.Resource groovyScript, boolean failOnError)
      Parse groovy script groovy object.
      static groovy.lang.Script parseGroovyShellScript​(java.lang.String script)
      Parse groovy shell script script.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ScriptingUtils

        public ScriptingUtils()
    • Method Detail

      • isInlineGroovyScript

        public static boolean isInlineGroovyScript​(java.lang.String script)
        Is inline groovy script ?.
        Parameters:
        script - the script
        Returns:
        true/false
      • isExternalGroovyScript

        public static boolean isExternalGroovyScript​(java.lang.String script)
        Is external groovy script ?.
        Parameters:
        script - the script
        Returns:
        true/false
      • getMatcherForInlineGroovyScript

        public static java.util.regex.Matcher getMatcherForInlineGroovyScript​(java.lang.String script)
        Gets inline groovy script matcher.
        Parameters:
        script - the script
        Returns:
        the inline groovy script matcher
      • getMatcherForExternalGroovyScript

        public static java.util.regex.Matcher getMatcherForExternalGroovyScript​(java.lang.String script)
        Gets groovy file script matcher.
        Parameters:
        script - the script
        Returns:
        the groovy file script matcher
      • executeGroovyShellScript

        public static <T> T executeGroovyShellScript​(groovy.lang.Script script,
                                                     java.lang.Class<T> clazz)
        Execute groovy shell script t.
        Type Parameters:
        T - the type parameter
        Parameters:
        script - the script
        clazz - the clazz
        Returns:
        the t
      • executeGroovyShellScript

        public static <T> T executeGroovyShellScript​(groovy.lang.Script script,
                                                     java.util.Map<java.lang.String,​java.lang.Object> variables,
                                                     java.lang.Class<T> clazz)
        Execute groovy shell script t.
        Type Parameters:
        T - the type parameter
        Parameters:
        script - the script
        variables - the variables
        clazz - the clazz
        Returns:
        the t
      • executeGroovyScript

        public static <T> T executeGroovyScript​(org.springframework.core.io.Resource groovyScript,
                                                java.lang.Object[] args,
                                                java.lang.Class<T> clazz,
                                                boolean failOnError)
        Execute groovy script via run object.
        Type Parameters:
        T - the type parameter
        Parameters:
        groovyScript - the groovy script
        args - the args
        clazz - the clazz
        failOnError - the fail on error
        Returns:
        the object
      • executeGroovyScript

        public static <T> T executeGroovyScript​(groovy.lang.GroovyObject groovyObject,
                                                java.lang.Object[] args,
                                                java.lang.Class<T> clazz,
                                                boolean failOnError)
        Execute groovy script.
        Type Parameters:
        T - the type parameter
        Parameters:
        groovyObject - the groovy object
        args - the args
        clazz - the clazz
        failOnError - the fail on error
        Returns:
        the result
      • executeGroovyScript

        public static <T> T executeGroovyScript​(org.springframework.core.io.Resource groovyScript,
                                                java.lang.String methodName,
                                                java.lang.Class<T> clazz,
                                                java.lang.Object... args)
        Execute groovy script t.
        Type Parameters:
        T - the type parameter
        Parameters:
        groovyScript - the groovy script
        methodName - the method name
        clazz - the clazz
        args - the args
        Returns:
        the type to return
      • executeGroovyScript

        public static <T> T executeGroovyScript​(org.springframework.core.io.Resource groovyScript,
                                                java.lang.String methodName,
                                                java.lang.Class<T> clazz)
        Execute groovy script.
        Type Parameters:
        T - the type parameter
        Parameters:
        groovyScript - the groovy script
        methodName - the method name
        clazz - the clazz
        Returns:
        the t
      • executeGroovyScript

        public static <T> T executeGroovyScript​(org.springframework.core.io.Resource groovyScript,
                                                java.lang.String methodName,
                                                java.lang.Object[] args,
                                                java.lang.Class<T> clazz,
                                                boolean failOnError)
        Execute groovy script.
        Type Parameters:
        T - the type parameter
        Parameters:
        groovyScript - the groovy script
        methodName - the method name
        args - the args
        clazz - the clazz
        failOnError - the fail on error
        Returns:
        the t
      • executeGroovyScript

        public static <T> T executeGroovyScript​(groovy.lang.GroovyObject groovyObject,
                                                java.lang.String methodName,
                                                java.lang.Object[] args,
                                                java.lang.Class<T> clazz,
                                                boolean failOnError)
        Execute groovy script t.
        Type Parameters:
        T - the type parameter
        Parameters:
        groovyObject - the groovy object
        methodName - the method name
        args - the args
        clazz - the clazz
        failOnError - the fail on error
        Returns:
        the t
      • parseGroovyShellScript

        public static groovy.lang.Script parseGroovyShellScript​(java.lang.String script)
        Parse groovy shell script script.
        Parameters:
        script - the script
        Returns:
        the script
      • parseGroovyScript

        public static groovy.lang.GroovyObject parseGroovyScript​(org.springframework.core.io.Resource groovyScript,
                                                                 boolean failOnError)
        Parse groovy script groovy object.
        Parameters:
        groovyScript - the groovy script
        failOnError - the fail on error
        Returns:
        the groovy object
      • executeScriptEngine

        public static <T> T executeScriptEngine​(java.lang.String scriptFile,
                                                java.lang.Object[] args,
                                                java.lang.Class<T> clazz)
        Execute groovy script engine t.
        Type Parameters:
        T - the type parameter
        Parameters:
        scriptFile - the script file
        args - the args
        clazz - the clazz
        Returns:
        the t
      • executeGroovyScriptEngine

        public static <T> T executeGroovyScriptEngine​(java.lang.String script,
                                                      java.util.Map<java.lang.String,​java.lang.Object> variables,
                                                      java.lang.Class<T> clazz)
        Execute inline groovy script engine.
        Type Parameters:
        T - the type parameter
        Parameters:
        script - the script
        variables - the variables
        clazz - the clazz
        Returns:
        the t
      • getObjectInstanceFromGroovyResource

        public static <T> T getObjectInstanceFromGroovyResource​(org.springframework.core.io.Resource resource,
                                                                java.lang.Class<T> expectedType)
        Gets object instance from groovy resource.
        Type Parameters:
        T - the type parameter
        Parameters:
        resource - the resource
        expectedType - the expected type
        Returns:
        the object instance from groovy resource
      • getObjectInstanceFromGroovyResource

        public static <T> T getObjectInstanceFromGroovyResource​(org.springframework.core.io.Resource resource,
                                                                java.lang.Class[] constructorArgs,
                                                                java.lang.Object[] args,
                                                                java.lang.Class<T> expectedType)
        Gets object instance from groovy resource.
        Type Parameters:
        T - the type parameter
        Parameters:
        resource - the resource
        constructorArgs - the constructor args
        args - the args
        expectedType - the expected type
        Returns:
        the object instance from groovy resource
      • getScriptEngineName

        public static java.lang.String getScriptEngineName​(java.lang.String scriptFile)
        Gets script engine name.
        Parameters:
        scriptFile - the script file
        Returns:
        the script engine name