This class is used to hold Groovy Expressions. This means that the code can start without any class or method signatures. For example, an expression could look like this:
1) input.resource.KEY == 10 2) $([BU:'agr',state:'OH') * 1.045 3) return input.state == 'OH' ? 1.0 : 2.0 4) output.result = 'answer computed'; return 1.4Of course, Java syntax can be used, however, there are many nice short-hands you can use if you know the Groovy language additions. For example, Maps can be accessed like this (the following 3 are equivalent):
1) input.get('BU') 2) input['BU'] 3) input.BUThere are variables available to you to access in your expression supplied by ncube. input which is the input coordinate Map that was used to get to the the cell containing the expression. output is a Map that your expression can write to. This allows the program calling into the ncube to get multiple return values, with possible structure to each one (a graph return). ncube is the current ncube of the cell containing the expression. ncubeMgr is a reference to the NCubeManager class so that you can access other ncubes. stack which is a List of StackEntry's where element 0 is the StackEntry for the currently executing cell. Element 1 would be the cell that called into the current cell (if it was during the same execution cycle). The StackEntry contains the name of the cube as one field, and the coordinate that called into this cell.
Modifiers | Name | Description |
---|---|---|
static java.lang.String |
EXP_CLASS |
|
static java.lang.String |
EXP_IMPORTS |
|
private static org.slf4j.Logger |
LOG |
|
static java.lang.String |
SYS_PROPERTY |
Fields inherited from class | Fields |
---|---|
class GroovyBase |
L2CacheKey, L2_CACHE, LOG, runnableCode |
class UrlCommandCell |
EXTENSION_SEPARATOR, LOG, cache, cacheable, cmd, errorMsg, hasBeenCached, hash, ncubeRuntimeClient, url |
Constructor and description |
---|
private GroovyExpression
() |
GroovyExpression
(java.lang.String cmd, java.lang.String url, boolean cache) |
Type Params | Return Type | Name and description |
---|---|---|
|
protected static void |
addPrototypeExpImports(java.util.Map<java.lang.String, java.lang.Object> ctx, java.lang.StringBuilder groovy, NCube prototype) |
|
protected java.lang.String |
buildGroovy(java.util.Map<java.lang.String, java.lang.Object> ctx, java.lang.String theirGroovy) |
|
protected static java.lang.String |
getPrototypeExpClass(java.util.Map<java.lang.String, java.lang.Object> ctx, NCube prototype) |
|
NCube |
getSysPrototype(ApplicationID appId) n-cube: ${ncube.name} axes: ${ncube.axisNames} |
|
protected static void |
handleException(java.lang.Exception e, java.lang.String msg) |
|
protected java.lang.Object |
invokeRunMethod(NCubeGroovyExpression instance, java.util.Map<java.lang.String, java.lang.Object> ctx) |
n-cube: ${ncube.name} axes: ${ncube.axisNames}