Class JavaScriptRunner

    • Field Detail

      • charset

        protected Charset charset
      • contextManager

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

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

      • JavaScriptRunner

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

      • 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
      • processCliArgs

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

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