Package com.singularsys.client
Class GWTInterop
java.lang.Object
com.singularsys.client.GWTInterop
- All Implemented Interfaces:
EntryPoint
@JsType(namespace="<global>",
name="Jep")
public class GWTInterop
extends Object
implements EntryPoint
GWT entry point exposing parts of the Jep system to JavaScript using the JsInterop system.
The class is renamed to Jep in JavaScript
- See Also:
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
consoleLog
(String msg) Native method to write to the JavaScript consoleevaluate
(GWTInterop.GWTNode node) Evaluate an expressionevaluateNE
(GWTInterop.GWTNode node) Evaluate an expression, does not throw exceptionsReturns the error message generated by the last action.getJavaValue
(Object val) Convert a JavaScript value to Java value suitable for Jep.getJSValue
(Object val) Convert values produced by Jep into values suitable for JavaScript.getVariableValue
(String name) Gets the value of a variable as an object valueprotected void
Calls the JavaScriptjepModuleLoaded()
method.void
Standard GWT method called when the module is loaded.Parse an expressionParse an expression, does not throw exceptionssetVariable
(String name, Object val) Set the value of a variable.setVariableNE
(String name, Object val) Set the value of a variable, does not throw exceptionstoString
(GWTInterop.GWTNode node) Construct a string representation of the node
-
Constructor Details
-
GWTInterop
@JsConstructor public GWTInterop()Creates a Jep instance using theStandardConfigurableParser
-
-
Method Details
-
onModuleLoad
@JsIgnore public void onModuleLoad()Standard GWT method called when the module is loaded. Calls theonModLoad()
native method which in turn calls the JavaScriptjepModuleLoaded()
method.- Specified by:
onModuleLoad
in interfaceEntryPoint
-
onModLoad
@JsIgnore protected void onModLoad()Calls the JavaScriptjepModuleLoaded()
method. -
parse
Parse an expression- Parameters:
S
- expression- Returns:
- root node of parse tree or null on ParseException
- Throws:
ParseException
- if an error in parsing
-
parseNE
Parse an expression, does not throw exceptions- Parameters:
S
- expression- Returns:
- root node of parse tree or null if an error in parsing
- See Also:
-
evaluate
Evaluate an expression- Parameters:
node
- root of the expression- Returns:
- result of evaluation converted to a format suitable for use in JavScript
- Throws:
EvaluationException
- if an error during evaluation
-
evaluateNE
Evaluate an expression, does not throw exceptions- Parameters:
node
- root of the expression- Returns:
- result of evaluation converted to a format suitable for use in JavScript, or null if an error during evaluation
- See Also:
-
setVariable
Set the value of a variable.- Parameters:
name
- name of variableval
- value- Returns:
- object representing the variable
- Throws:
JepException
- if the value cannot be converted a double, string or array, or an attempt to set a constant variable
-
setVariableNE
Set the value of a variable, does not throw exceptions- Parameters:
name
- name of variableval
- value- Returns:
- object representing the variable or null on error
-
getVariableValue
Gets the value of a variable as an object value- Parameters:
name
- variable name- Returns:
- value as an object or null if no such variable exists
-
getJavaValue
Convert a JavaScript value to Java value suitable for Jep. Most types are parsed directly apart from JsArray arrays which are converted toVectors<Object>
the type used by standard Jep.- Parameters:
val
- value from JavaScript, must be Number, String, Boolean or array.- Returns:
- converted value or null on error.
- Throws:
EvaluationException
- if the value cannot be converted to a Number, String or array
-
getJSValue
Convert values produced by Jep into values suitable for JavaScript. Changes Jeps Vector representation for arrays to- Parameters:
val
-- Returns:
-
getErrorMsg
Returns the error message generated by the last action.- Returns:
- the error message or "" if no error detected
-
toString
Construct a string representation of the node- Parameters:
node
- root node of an expression- Returns:
- a string representation
-
consoleLog
Native method to write to the JavaScript console- Parameters:
msg
-
-