Class ScriptInterpreter

  • Direct Known Subclasses:
    RhinoScriptInterpreter

    public abstract class ScriptInterpreter
    extends java.lang.Object
    Script interpreter abstract wrapper
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CP  
      static java.lang.String CW  
      static java.lang.String PM  
      static java.lang.String[] STANDARD_CLASSES
      Standard additional classes
      static java.lang.String[] STANDARD_PACKAGES
      Standard packages
      static java.lang.String WP  
    • Method Summary

      Modifier and Type Method Description
      abstract void check​(java.lang.String script)  
      abstract void debug​(java.lang.String name, java.lang.String src)
      Debug source
      java.lang.Object eval​(ExternalObject ext, java.lang.String script, java.util.Map<java.lang.String,​java.lang.Object> in, java.util.Map<java.lang.String,​java.lang.Object> out)  
      java.lang.Object eval​(ObjectCore obj, int context, java.lang.String script)  
      java.lang.Object eval​(ObjectCore obj, java.lang.String[] row, int context, java.lang.String script, java.util.Map<java.lang.String,​java.lang.Object> in, java.util.Map<java.lang.String,​java.lang.Object> out)  
      java.lang.Object eval​(java.lang.String script)  
      java.lang.Object eval​(java.lang.String script, java.util.Map<java.lang.String,​java.lang.Object> in, java.util.Map<java.lang.String,​java.lang.Object> out)  
      static java.lang.Class<?> findClass​(java.lang.String cls)
      Find class among the standard packages
      static java.lang.String[][] getArrayOfStringArray​(int arraylength, int length)
      Create a new array of Java string array suitable for scripting usage (typical usage for list rows)
      javax.script.ScriptEngine getEngine()  
      abstract java.lang.String getEngineName()  
      abstract java.lang.String getEngineVersion()  
      java.lang.String getInitializers()  
      static org.json.JSONObject getJavadocInfo​(java.lang.String cls)
      Get javadoc info from specified class (looked up in standard packages if non fully qalified name)
      static java.lang.Object getObject()
      Create a new Java object suitable for scripting usage
      static java.lang.Object[] getObjectArray​(int length)
      Create a new Java object array suitable for scripting usage
      static java.lang.String[] getPublicMethods​(java.lang.String cls)
      Get public methods from specified class (looked up in standard packages if non fully qalified name)
      static java.lang.String getString()
      Create a new Java string suitable for scripting usage
      static java.lang.String[] getStringArray​(int length)
      Create a new Java string array suitable for scripting usage
      static java.lang.Boolean parseBoolean​(java.lang.Object res)
      Parses single Boolean result
      static byte[] parseByteArray​(java.lang.Object res)
      Parses single byte array result or null
      static java.lang.Character parseChar​(java.lang.Object res)
      Parses single Char result
      static java.util.Date parseDate​(java.lang.Object res)
      Parses single Date result
      static java.lang.Integer parseInt​(java.lang.Object res)
      Parses single Integer result
      static java.util.List<?> parseList​(java.lang.Object res)
      Parses result as List of objects
      static java.lang.Long parseLong​(java.lang.Object res)
      Parses single Long result
      static Message parseMessage​(java.lang.Object res)
      Parses single message result
      static java.lang.String parseString​(java.lang.Object res)
      Parses single String result
      static java.util.List<java.lang.String> parseStringArray​(java.lang.Object res)
      Parses String Array result
      static java.util.List<java.lang.String[]> parseStringArrayList​(java.lang.Object res)
      Parses String array list result
      static java.util.Vector<java.lang.String> parseStringVector​(java.lang.Object res)
      Deprecated.
      static java.util.Vector<?> parseVector​(java.lang.Object res)
      Deprecated.
      void runtimeError​(java.lang.String method, javax.script.ScriptException e, java.util.List<SharedScript>[] scrs, java.lang.String[] names, java.lang.String[] sources, Grant g)
      Log the script error with the corresponding source part (in many scripts or sources)
      void syntaxError​(java.lang.String method, java.lang.Exception e, java.lang.String scriptId, java.lang.String code, java.lang.String source, Grant g)
      Log the script error with the corresponding source part
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • STANDARD_PACKAGES

        public static final java.lang.String[] STANDARD_PACKAGES
        Standard packages
      • STANDARD_CLASSES

        public static final java.lang.String[] STANDARD_CLASSES
        Standard additional classes
    • Constructor Detail

      • ScriptInterpreter

        public ScriptInterpreter()
      • ScriptInterpreter

        public ScriptInterpreter​(GrantCore grant)
    • Method Detail

      • getEngineName

        public abstract java.lang.String getEngineName()
      • getEngineVersion

        public abstract java.lang.String getEngineVersion()
      • getEngine

        public javax.script.ScriptEngine getEngine()
      • findClass

        public static java.lang.Class<?> findClass​(java.lang.String cls)
        Find class among the standard packages
        Parameters:
        cls - Class name
        Returns:
        Class
      • eval

        public java.lang.Object eval​(java.lang.String script,
                                     java.util.Map<java.lang.String,​java.lang.Object> in,
                                     java.util.Map<java.lang.String,​java.lang.Object> out)
                              throws ScriptException
        Throws:
        ScriptException
      • getInitializers

        public java.lang.String getInitializers()
      • eval

        public java.lang.Object eval​(ObjectCore obj,
                                     java.lang.String[] row,
                                     int context,
                                     java.lang.String script,
                                     java.util.Map<java.lang.String,​java.lang.Object> in,
                                     java.util.Map<java.lang.String,​java.lang.Object> out)
                              throws ScriptException
        Throws:
        ScriptException
      • eval

        public java.lang.Object eval​(ExternalObject ext,
                                     java.lang.String script,
                                     java.util.Map<java.lang.String,​java.lang.Object> in,
                                     java.util.Map<java.lang.String,​java.lang.Object> out)
                              throws ScriptException
        Throws:
        ScriptException
      • getString

        public static java.lang.String getString()
        Create a new Java string suitable for scripting usage
        Returns:
        Java String
      • getObject

        public static java.lang.Object getObject()
        Create a new Java object suitable for scripting usage
        Returns:
        Java Object
      • getStringArray

        public static java.lang.String[] getStringArray​(int length)
        Create a new Java string array suitable for scripting usage
        Parameters:
        length - Array length
        Returns:
        Java String array
      • getArrayOfStringArray

        public static java.lang.String[][] getArrayOfStringArray​(int arraylength,
                                                                 int length)
        Create a new array of Java string array suitable for scripting usage (typical usage for list rows)
        Parameters:
        arraylength - Length of the array of string array
        length - Length of each string array
        Returns:
        Java array of String array
      • getObjectArray

        public static java.lang.Object[] getObjectArray​(int length)
        Create a new Java object array suitable for scripting usage
        Parameters:
        length - Array length
        Returns:
        Java Object array
      • parseByteArray

        public static byte[] parseByteArray​(java.lang.Object res)
        Parses single byte array result or null
        Parameters:
        res - Result
        Returns:
        Parsed single byte array
      • parseMessage

        public static Message parseMessage​(java.lang.Object res)
        Parses single message result
        Parameters:
        res - Result
        Returns:
        Parsed single message
      • parseBoolean

        public static java.lang.Boolean parseBoolean​(java.lang.Object res)
        Parses single Boolean result
        Parameters:
        res - Result
        Returns:
        Parsed single Boolean
      • parseLong

        public static java.lang.Long parseLong​(java.lang.Object res)
        Parses single Long result
        Parameters:
        res - Result
        Returns:
        Parsed single Long
      • parseInt

        public static java.lang.Integer parseInt​(java.lang.Object res)
        Parses single Integer result
        Parameters:
        res - Result
        Returns:
        Parsed single Integer
      • parseString

        public static java.lang.String parseString​(java.lang.Object res)
        Parses single String result
        Parameters:
        res - Result
        Returns:
        Parsed single String
      • parseDate

        public static java.util.Date parseDate​(java.lang.Object res)
        Parses single Date result
        Parameters:
        res - Result
        Returns:
        Parsed single Date
      • parseChar

        public static java.lang.Character parseChar​(java.lang.Object res)
        Parses single Char result
        Parameters:
        res - Result
        Returns:
        Parsed single Char
      • parseStringVector

        @Deprecated
        public static java.util.Vector<java.lang.String> parseStringVector​(java.lang.Object res)
        Deprecated.
        Parses String vector result
        Parameters:
        res - Result
        Returns:
        Parsed String vector result
      • parseStringArrayList

        public static java.util.List<java.lang.String[]> parseStringArrayList​(java.lang.Object res)
        Parses String array list result
        Parameters:
        res - Result
        Returns:
        Parsed String array list
      • parseVector

        @Deprecated
        public static java.util.Vector<?> parseVector​(java.lang.Object res)
        Deprecated.
        Parses result as vector of objects
        Parameters:
        res - Result
        Returns:
        Parsed vector of objects
      • parseList

        public static java.util.List<?> parseList​(java.lang.Object res)
        Parses result as List of objects
        Parameters:
        res - Result
        Returns:
        Parsed List of objects
      • parseStringArray

        public static java.util.List<java.lang.String> parseStringArray​(java.lang.Object res)
        Parses String Array result
        Parameters:
        res - Result
        Returns:
        Parsed string array
      • syntaxError

        public void syntaxError​(java.lang.String method,
                                java.lang.Exception e,
                                java.lang.String scriptId,
                                java.lang.String code,
                                java.lang.String source,
                                Grant g)
        Log the script error with the corresponding source part
        Parameters:
        method - Method name
        e - Script exception
        scriptId - Script Id or null
        code - Script name
        source - Source code
        g - User rights
      • runtimeError

        public void runtimeError​(java.lang.String method,
                                 javax.script.ScriptException e,
                                 java.util.List<SharedScript>[] scrs,
                                 java.lang.String[] names,
                                 java.lang.String[] sources,
                                 Grant g)
        Log the script error with the corresponding source part (in many scripts or sources)
        Parameters:
        method - Method name
        e - Script exception
        scrs - List of shared codes or null
        names - List of script names or null
        sources - List of sources related to names
        g - User rights
      • getPublicMethods

        public static java.lang.String[] getPublicMethods​(java.lang.String cls)
                                                   throws java.lang.Exception
        Get public methods from specified class (looked up in standard packages if non fully qalified name)
        Parameters:
        cls - Class name
        Returns:
        Methods names
        Throws:
        java.lang.Exception
      • getJavadocInfo

        public static org.json.JSONObject getJavadocInfo​(java.lang.String cls)
                                                  throws java.lang.Exception
        Get javadoc info from specified class (looked up in standard packages if non fully qalified name)
        Parameters:
        cls - Class name
        Returns:
        Javadoc info
        Throws:
        java.lang.Exception
      • debug

        public abstract void debug​(java.lang.String name,
                                   java.lang.String src)
                            throws java.lang.Exception
        Debug source
        Parameters:
        name - Source file name
        src - Source
        Throws:
        java.lang.Exception