public class JsScriptEngine extends ScriptEngine
ScriptEngine
implementation for JavaScriptScriptEngine.SupportedScriptLang
NAMESPACE_SEPARATOR
Constructor and Description |
---|
JsScriptEngine() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
eval(java.lang.String expr) |
static JsScriptEngine |
getInstance() |
protected java.util.Map<java.lang.String,java.lang.Object> |
getParamsFromVariables()
Returns a map from local variable names to their values
|
protected java.lang.String |
getScriptingLang()
Gets ScriptEngine classname or keyword for the scripting language
|
java.lang.Object |
jsCall(java.lang.String functionName,
java.lang.Object[] passedParams)
call a javascript function
|
java.lang.Object |
jsEval(java.lang.String name,
java.io.Reader scriptReader)
evaluate javascript from a reader
|
java.lang.Object |
jsEval(java.lang.String name,
java.lang.String script)
evaluate a javascript String
|
org.mozilla.javascript.Scriptable |
jsNewArray(long size)
creates a new javascript array
|
org.mozilla.javascript.Scriptable |
jsNewObject()
creates a new JavaScript object
|
void |
jsPut(java.lang.String name,
java.lang.Object value)
put a value in the current scope
|
protected void |
load(java.lang.String name,
java.io.InputStream script) |
protected java.util.Map<java.lang.String,java.util.List<PigStats>> |
main(PigContext pigContext,
java.lang.String scriptFile)
Actually runs the script file.
|
void |
registerFunctions(java.lang.String path,
java.lang.String namespace,
PigContext pigContext)
Registers scripting language functions as Pig functions with given namespace
|
getInstance, getJarPath, getPigStatsMap, getScriptAsStream, getSupportedScriptLang, run
public static JsScriptEngine getInstance()
public java.lang.Object jsEval(java.lang.String name, java.lang.String script)
name
- the name of the script (for error messages)script
- the content of the scriptpublic java.lang.Object jsEval(java.lang.String name, java.io.Reader scriptReader)
name
- the name of the script (for error messages)scriptReader
- the content of the scriptpublic void jsPut(java.lang.String name, java.lang.Object value)
name
- the name of the variablevalue
- its valuepublic java.lang.Object jsCall(java.lang.String functionName, java.lang.Object[] passedParams)
functionName
- the name of the functionpassedParams
- the parameters to passpublic org.mozilla.javascript.Scriptable jsNewObject()
public org.mozilla.javascript.Scriptable jsNewArray(long size)
size
- the size of the arrayprotected java.lang.Object eval(java.lang.String expr)
protected void load(java.lang.String name, java.io.InputStream script)
protected java.util.Map<java.lang.String,java.util.List<PigStats>> main(PigContext pigContext, java.lang.String scriptFile) throws java.io.IOException
ScriptEngine
main
in class ScriptEngine
pigContext
- ScriptPigContext
to run the script filescriptFile
- the filejava.io.IOException
public void registerFunctions(java.lang.String path, java.lang.String namespace, PigContext pigContext) throws java.io.IOException
ScriptEngine
registerFunctions
in class ScriptEngine
path
- path of the scriptnamespace
- namespace for the functionspigContext
- pigcontext to register functions to pig in the given namespacejava.io.IOException
protected java.util.Map<java.lang.String,java.lang.Object> getParamsFromVariables() throws java.io.IOException
ScriptEngine
getParamsFromVariables
in class ScriptEngine
java.io.IOException
protected java.lang.String getScriptingLang()
ScriptEngine
getScriptingLang
in class ScriptEngine
Copyright © 2007-2017 The Apache Software Foundation