Interface ScriptEngine


public interface ScriptEngine
Manage scriptEngine variables, statements and script execution.
Author:
Matti Rinta-Nikkola
  • Method Details

    • getEngineName

      String getEngineName()
      Returns:
      scriptEngine name
    • getExtensions

      Collection<String> getExtensions()
      Returns:
      script file name extensions
    • getScriptCompleter

      Completer getScriptCompleter()
      Returns:
      script tab completer
    • hasVariable

      boolean hasVariable(String name)
      Tests if console variable exists
      Parameters:
      name - variable name
      Returns:
      true if variable exists
    • put

      void put(String name, Object value)
      Creates variable
      Parameters:
      name - variable name
      value - value
    • get

      Object get(String name)
      Gets variable value
      Parameters:
      name - variable name
      Returns:
      value of the variable
    • find

      default Map<String,Object> find()
      Gets all variables with values
      Returns:
      map of the variables
    • find

      Map<String,Object> find(String name)
      Gets all the variables that match the name. Name can contain * wild cards.
      Parameters:
      name - variable name
      Returns:
      map the variables
    • del

      void del(String... vars)
      Deletes variables. Variable name can contain * wild cards.
      Parameters:
      vars - variables to be deleted
    • toJson

      String toJson(Object object)
      Serialize object to JSON string.
      Parameters:
      object - object to serialize to JSON
      Returns:
      formatted JSON string
    • toString

      String toString(Object object)
      Converts object to string.
      Parameters:
      object - the object
      Returns:
      object string value
    • toMap

      Map<String,Object> toMap(Object object)
      Converts object fields to map.
      Parameters:
      object - the object
      Returns:
      object fields map
    • deserialize

      default Object deserialize(String value)
      Deserialize value
      Parameters:
      value - the value
      Returns:
      deserialized value
    • deserialize

      Object deserialize(String value, String format)
      Deserialize value
      Parameters:
      value - the value
      format - serialization format
      Returns:
      deserialized value
    • getSerializationFormats

      List<String> getSerializationFormats()
      Returns:
      Supported serialization formats
    • getDeserializationFormats

      List<String> getDeserializationFormats()
      Returns:
      Supported deserialization formats
    • persist

      void persist(Path file, Object object)
      Persists object value to file.
      Parameters:
      file - file
      object - object
    • persist

      void persist(Path file, Object object, String format)
      Persists object value to file.
      Parameters:
      file - the file
      object - the object
      format - serialization format
    • execute

      Object execute(String statement) throws Exception
      Executes scriptEngine statement
      Parameters:
      statement - the statement
      Returns:
      result
      Throws:
      Exception - in case of error
    • execute

      default Object execute(File script) throws Exception
      Executes scriptEngine script
      Parameters:
      script - the script
      Returns:
      result
      Throws:
      Exception - in case of error
    • execute

      Object execute(File script, Object[] args) throws Exception
      Executes scriptEngine script
      Parameters:
      script - the script
      args - arguments
      Returns:
      result
      Throws:
      Exception - in case of error
    • execute

      Object execute(Object closure, Object... args)
      Executes scriptEngine closure
      Parameters:
      closure - closure
      args - arguments
      Returns:
      result