public interface ScriptContext
For example, if you need to calculate the change of an observed numeric value between script invocations, you can use the context as follows:
long previousValue = scriptContext.getLong("myValue");
long currentValue = ...;
long delta = currentValue - previousValue;
// Use delta
scriptContext.putLong("myValue", currentValue); // for the next invocation of the script
| Modifier and Type | Method and Description |
|---|---|
long |
getLong(java.lang.Object key)
Store a key-value pair of value type long in the script context.
|
java.lang.Object |
getObject(java.lang.Object key)
Store a key-value pair in the script context.
|
long |
putLong(java.lang.Object key,
long value)
Store a key-value pair of value type long in the script context.
|
java.lang.Object |
putObject(java.lang.Object key,
java.lang.Object value)
Store a key-value pair in the script context.
|
java.lang.Object getObject(java.lang.Object key)
key - the keynull if there was no mapping for the key.java.lang.Object putObject(java.lang.Object key,
java.lang.Object value)
key - the keyvalue - the valuenull if there was no mapping for the key.long getLong(java.lang.Object key)
key - the keylong putLong(java.lang.Object key,
long value)
key - the keyvalue - the long value