- java.lang.Object
-
- java.util.AbstractMap<String,Object>
-
- com.pervasive.datarush.coercion.JavaScriptRunner
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description protected Charset
charset
protected com.pervasive.datarush.coercion.ContextManager
contextManager
protected org.mozilla.javascript.Scriptable
scope
-
Constructor Summary
Constructors Constructor Description JavaScriptRunner(com.pervasive.datarush.coercion.ContextManager contextManager)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<Map.Entry<String,Object>>
entrySet()
Object
eval(File sourceFile, CodeSource securityDomain)
Object
eval(String source, CodeSource securityDomain)
Object
eval(URL sourceUrl, CodeSource securityDomain)
static JavaScriptRunner
fromArgs(String[] args, CodeSource domain)
<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.static Object
jsToJava(com.pervasive.datarush.coercion.ContextManager contextManager, Object jsObject)
void
processCliArgs(String[] args, CodeSource domain)
Object
put(String key, Object value)
<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.-
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Field Detail
-
charset
protected Charset charset
-
contextManager
protected final com.pervasive.datarush.coercion.ContextManager contextManager
-
scope
protected final org.mozilla.javascript.Scriptable scope
-
-
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 tokey
- the key of the value to retrievedefaultValue
- the default value- Returns:
- the value, coerced to
targetType
, to whichkey
is mapped ordefaultValue
- 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 tokey
- the key of the value to retrieve- Returns:
- the value, coerced to
valueType
, to whichkey
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)
-
-