Class InstanceLocator

java.lang.Object
com.aquima.interactions.portal.util.InstanceLocator

public class InstanceLocator extends Object
Utility class that may be used to quickly locate instances in an inference context. All the method in this class support dotted notation, but only for single valued relation attributes.
Since:
5.0
Author:
O. Kerpershoek
  • Constructor Details

    • InstanceLocator

      public InstanceLocator(InferenceContext context)
      Constructs an instance locater for the specified inference context.
      Parameters:
      context - The context for which the locater should be created.
  • Method Details

    • getPath

      public IEntityInstance[] getPath(String attributePath)

      This method will retrieve all the instances that lead to the final attribute indicated by the attribute path provided. The attribute path provided should start with an entity type name, optionally followed by one or more relation attributes, and end with an attribute name (or relation attribute name). The content of the last attribute or relation will not be included in the resulting path.

      The currently active instance of the entity type at the start of the path will be used as starting point for the path.
      Parameters:
      attributePath - The attribute path for which the instances should be retrieved.
      Returns:
      Array containing all the instances corresponding to the attribute path.
      Throws:
      AppException - This exception is thrown when the method fails due to a definition error (for instance an unknown entity).
    • getPath

      public IEntityInstance[] getPath(IEntityInstance instance, String attributePath)
      This method will retrieve all the instances that lead to the final attribute indicated by the attribute path provided. The attribute path provided should start with an entity type name, optionally followed by one or more relation attributes, and end with an attribute name.
      Parameters:
      instance - The instance that should be used as starting point.
      attributePath - The attribute path for which the instances should be retrieved.
      Returns:
      Array containing all the instances corresponding to the attribute path.
      Throws:
      AppException - This exception is thrown when the method fails due to a definition error (for instance an unknown entity).
    • getValueOf

      public IAttributeValue getValueOf(String attributePath)
      This method retrieves the attribute value for the specified attribute path. The method is functionally equivalent to calling the getInstanceOf method followed by a getValue on the resulting instance. When one of the relation attributes specified in the path is unknown, this method will return a null value.
      Parameters:
      attributePath - The path to the attribute of which the value is requested.
      Returns:
      The value for the specified attribute, or null when a relation in the path was unknown.
      Throws:
      AppException - This exception is thrown when the method fails due to a definition error (for instance an unknown entity).
    • getInstanceOf

      public IEntityInstance getInstanceOf(String attributePath)
      This method returns the instance containing the attribute specified by the attribute path. The attribute path should start with an entity type, optionally followed by relation attributes, and end with an attribute name. The active instance for the type specified at the start of the attribute path is used as starting point. When a relation attribute from the path is encountered that has no value (empty relation), this method will return a null value.
      Parameters:
      attributePath - The attribute path for which the instance should be retrieved.
      Returns:
      The instance that contains the attribute indicated by the attribute path.
      Throws:
      AppException - This exception is thrown when the method fails due to a definition error (for instance an unknown entity).
    • getInstanceOf

      public IEntityInstance getInstanceOf(IEntityInstance instance, String attributePath)
      This method returns the instance containing the attribute specified by the attribute path. The attribute path should start with an entity type, optionally followed by relation attributes, and end with an attribute name. When a relation attribute from the path is encountered that has no value (empty relation), this method will return a null value.
      Parameters:
      instance - The instance that should be used as starting point.
      attributePath - The attribute path for which the instance should be retrieved.
      Returns:
      The instance that contains the attribute indicated by the attribute path.
      Throws:
      AppException - This exception is thrown when the method fails due to a definition error (for instance an unknown entity).