|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.birt.core.script.JavascriptEvalUtil
public class JavascriptEvalUtil
Utilities to faciliate the evaluation of Javascript expressions. Handles common evaluation tasks like exception handling, data type conversion and script caching
Field Summary | |
---|---|
protected static java.util.Map |
compiledScriptCache
|
protected static int |
SCRIPT_CACHE_SIZE
|
Constructor Summary | |
---|---|
JavascriptEvalUtil()
|
Method Summary | |
---|---|
static java.lang.Object |
convertJavascriptValue(java.lang.Object inputObj)
Handles a Rhino script evaluation result, converting Javascript object into equivalent Java objects if necessary. |
static java.lang.Object[] |
convertToJavaObjects(java.lang.Object[] args)
|
static java.lang.Object |
convertToJavascriptValue(java.lang.Object value)
If caller does not have a scope for evaluation, the caller can use this method to evaluate expression. |
static java.lang.Object |
convertToJavascriptValue(java.lang.Object value,
org.mozilla.javascript.Scriptable scope)
Creates Javascript native wrapper for Java objects, if necessary. |
static java.lang.Object |
evaluateRawScript(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
java.lang.String scriptText,
java.lang.String source,
int lineNo)
This method will not convert the data of return value, so it might the Java data type or that of Java Script. |
static java.lang.Object |
evaluateScript(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
java.lang.String scriptText,
java.lang.String source,
int lineNo)
Evaluates Javascript expression and return its result, doing the necessary Javascript -> Java data type conversion if necessary |
protected static org.mozilla.javascript.Script |
getCompiledScript(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
java.lang.String scriptText,
java.lang.String source,
int lineNo)
Gets a compiled script, using and updating the script cache if necessary |
static java.lang.String |
transformToJsConstants(java.lang.String s)
This method transforms a string to JS string constants. |
static BirtException |
wrapRhinoException(org.mozilla.javascript.RhinoException e,
java.lang.String scriptText,
java.lang.String source,
int lineNo)
Converts Rhino exception (a runtime exception) to BirtException |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int SCRIPT_CACHE_SIZE
protected static java.util.Map compiledScriptCache
Constructor Detail |
---|
public JavascriptEvalUtil()
Method Detail |
---|
public static java.lang.Object evaluateRawScript(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, java.lang.String scriptText, java.lang.String source, int lineNo) throws BirtException
cx
- scope
- scriptText
- source
- lineNo
-
BirtException
public static java.lang.Object evaluateScript(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, java.lang.String scriptText, java.lang.String source, int lineNo) throws BirtException
cx
- Javascript context. If null, current thread's context is usedscope
- Javascript scope to evaluate script inscriptText
- text of Javascript expressionsource
- descriptive text of script source (for error reporting)lineNo
- line number of script in it source
BirtException
- If evaluation failedprotected static org.mozilla.javascript.Script getCompiledScript(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, java.lang.String scriptText, java.lang.String source, int lineNo)
public static java.lang.Object convertToJavascriptValue(java.lang.Object value, org.mozilla.javascript.Scriptable scope)
value
- Java object to convert frompublic static java.lang.Object convertToJavascriptValue(java.lang.Object value)
value
-
public static java.lang.Object convertJavascriptValue(java.lang.Object inputObj)
inputObj
- Object returned by rhino engine.
public static BirtException wrapRhinoException(org.mozilla.javascript.RhinoException e, java.lang.String scriptText, java.lang.String source, int lineNo)
e
- Rhino exceptionscriptText
- Javascript code which resulted in the exception (for error reporting purpose)source
- description of the source script. If null, get this info from Rhino exceptionlineNo
- lineNo of error location
public static java.lang.Object[] convertToJavaObjects(java.lang.Object[] args)
args
-
public static java.lang.String transformToJsConstants(java.lang.String s)
s
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |