Interface ScriptContext


public interface ScriptContext
Context object that is passed to all scripts and provides ways to store key-value pairs for all subsequent invocations of any custom script.

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
 
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Store a key-value pair of value type long in the script context.
    Store a key-value pair in the script context.
    long
    putLong(Object key, long value)
    Store a key-value pair of value type long in the script context.
    putObject(Object key, Object value)
    Store a key-value pair in the script context.
  • Method Details

    • getObject

      Object getObject(Object key)
      Store a key-value pair in the script context.
      Parameters:
      key - the key
      Returns:
      the value, or null if there was no mapping for the key.
    • putObject

      Object putObject(Object key, Object value)
      Store a key-value pair in the script context. An existing mapping is overwritten.
      Parameters:
      key - the key
      value - the value
      Returns:
      the value that was previously associated with specified key, or null if there was no mapping for the key.
    • getLong

      long getLong(Object key)
      Store a key-value pair of value type long in the script context.
      Parameters:
      key - the key
      Returns:
      the long value, or 0 if there was no mapping
    • putLong

      long putLong(Object key, long value)
      Store a key-value pair of value type long in the script context. An existing mapping is overwritten.
      Parameters:
      key - the key
      value - the long value
      Returns:
      the value that was previously associated with specified key, or 0 if there was no mapping for the key.