Class JavaScriptRunner

java.lang.Object
java.util.AbstractMap<String,Object>
com.pervasive.datarush.coercion.JavaScriptRunner
All Implemented Interfaces:
Map<String,Object>
Direct Known Subclasses:
Drunner

public class JavaScriptRunner extends AbstractMap<String,Object>
  • Field Details

    • charset

      protected Charset charset
    • contextManager

      protected final com.pervasive.datarush.coercion.ContextManager contextManager
    • scope

      protected final org.mozilla.javascript.Scriptable scope
  • Constructor Details

    • JavaScriptRunner

      public JavaScriptRunner(com.pervasive.datarush.coercion.ContextManager contextManager)
  • Method Details

    • getAs

      public <T> T getAs(Class<T> targetType, String key, T defaultValue)
      Gets the value to which the specified key is mapped, and coerces that value to the specified target type. If this map contains no mapping for the key, a specified default value is returned instead.
      Type Parameters:
      T - the target type
      Parameters:
      targetType - the type to coerce the retrieved value to
      key - the key of the value to retrieve
      defaultValue - the default value
      Returns:
      the value, coerced to targetType, to which key is mapped or defaultValue
      See Also:
      • #getAs(Class, String)
    • requireAs

      public <T> T requireAs(Class<T> targetType, String key)
      Gets the value to which the specified key is mapped, and coerces that value to a specified type. If this map contains no mapping for the key, or the key is mapped to a null value, a user-friendly exception is thrown.
      Type Parameters:
      T - the target type
      Parameters:
      targetType - the type to coerce the retrieved value to
      key - the key of the value to retrieve
      Returns:
      the value, coerced to valueType, to which key is mapped
    • eval

      public Object eval(String source, CodeSource securityDomain)
    • eval

      public Object eval(File sourceFile, CodeSource securityDomain)
    • eval

      public Object eval(URL sourceUrl, CodeSource securityDomain)
    • processCliArgs

      public void processCliArgs(String[] args, CodeSource domain)
    • fromArgs

      public static JavaScriptRunner fromArgs(String[] args, CodeSource domain)
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
      Specified by:
      entrySet in interface Map<String,Object>
      Specified by:
      entrySet in class AbstractMap<String,Object>
    • put

      public Object put(String key, Object value)
      Specified by:
      put in interface Map<String,Object>
      Overrides:
      put in class AbstractMap<String,Object>
    • jsToJava

      public static Object jsToJava(com.pervasive.datarush.coercion.ContextManager contextManager, Object jsObject)