Class BusinessAlgorithmContext

java.lang.Object
com.ptc.core.businessfield.server.businessObject.BusinessAlgorithmContext

public final class BusinessAlgorithmContext extends Object
This class provides a cache that custom BusinessAlgorithms can use to store state between executions of a calculation on a collection of BusinessObjects. This class contains the collection of BusinessObjects, the index to the current BusinessObject being processed and a cache that can contain anything the algorithm needs access to across different objects.

This class is not thread safe. It is the responsibility of users of this class to ensure it is handled correctly if used in multiple threads. Supported API: true

Extendable: false BusinessObject
  • Method Details

    • getLocale

      public Locale getLocale()
      Get the current locale.

      Supported API: true
      Returns:
      the current locale that should be applied to the evaluation
    • getCurrentBusinessObject

      public BusinessObject getCurrentBusinessObject()
      Returns the business object at the current index. This is the BusinessObject that is currently being processed.

      Supported API: true
      Returns:
    • getCurrentIndex

      public int getCurrentIndex()
      Returns the index info the collection of BusinessObjects for the particular BusinessObject that is currently being processed.

      Supported API: true
      Returns:
    • put

      public void put(String businessAlgorithmClassName, String cacheKey, Object cacheObject)
      Store an arbitrary piece of information in the context so that it can be reused in calculations across multiple BusinessObjects

      Supported API: true
      Parameters:
      businessAlgorithmClassName - The class name of the BusinessAlgorithm doing the calculation, this is required to prevent key collisions across algorithms
      cacheKey - An arbitrary cache key created by the BusinessAlgorithm author
      cacheObject - The object to cache
    • get

      public Object get(String businessAlgorithmClassName, String cacheKey)
      Retrieves an arbitrary Object that was previous placed in the cache.

      Supported API: true
      Parameters:
      businessAlgorithmClassName - The class name of the BusinessAlgorithm doing the calculation, this is required to prevent key collisions across algorithms
      cacheKey - An arbitrary cache key created by the BusinessAlgorithm author
      Returns:
      The object that was in the cache, or null if this key is not found in the cache yet.