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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method 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.
    • Method Detail

      • getObject

        java.lang.Object getObject​(java.lang.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

        java.lang.Object putObject​(java.lang.Object key,
                                   java.lang.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​(java.lang.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​(java.lang.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.