ilog.rules.dt.expression

Class ExpressionHelper

  • java.lang.Object
    • ilog.rules.dt.expression.ExpressionHelper


  • public class ExpressionHelper
    extends java.lang.Object
    ExpressionHelper provides helper methods used to manipulate expressions in a DT Model.
    Since:
    JRules 7.0
    • Constructor Detail

      • ExpressionHelper

        public ExpressionHelper()
    • Method Detail

      • getPlaceHolderLabel

        public static java.lang.String getPlaceHolderLabel(IlrDTExpressionDefinition expr,
                                           int index)
        Returns the placeholder label without the < and the > in the string.
        Parameters:
        expr - The expression definition.
        index - The index of the placeholder in the given expression definition.
        Returns:
        The placeholder label.
      • getExpressionElementCount

        public static int getExpressionElementCount(IlrDTExpression expr)
        Returns the number of placeholders in an expression definition or the number of parameters in an expression instance.
        Parameters:
        expr - The expression to check.
        Returns:
        The number of placeholders or parameters. If no parameters or placeholders are found in expr, -1 is returned.
      • getExpressionElement

        public static IlrDecorableElement getExpressionElement(IlrDTExpression expr,
                                               int index)
        Returns the placeholder or parameter located at a specific index in the given expression.
        Parameters:
        expr - An expression definition or an expression instance.
        index - The index to find the placeholder or parameter.
        Returns:
        An expression placeholder or an expression parameter. If one of these objects is not found at index, null is returned.
      • isExpressionComplete

        public static boolean isExpressionComplete(IlrDTExpressionInstance instance)
        Tests if all parameters are nonempty or reference a placeholder that has a nonempty default value. Nonvalid expression are not considered to be complete.
        Parameters:
        instance - The instance to test.
        Returns:
        If the expression is complete, true is returned.
      • isExpressionSentenceMeaningfull

        public static boolean isExpressionSentenceMeaningfull(IlrDTExpressionInstance expression)
      • getPlaceHolderForParameter

        public static IlrDTExpressionPlaceHolder getPlaceHolderForParameter(IlrDTExpressionParameter param)
        Returns the placeholder that corresponds to the given expression parameter. The placeholder comes from the expression instance definition this parameter belongs to.
        Parameters:
        param - A non-null expression parameter.
        Returns:
        An expression placeholder. This placeholder is not supposed to be null.
      • newExpressionInstance

        public static IlrDTExpressionInstance newExpressionInstance(IlrDTExpressionDefinition defExpr,
                                                    boolean useDefaultValues)
        Creates a new expression instance derived from a given definition. Use the useDefaultValues parameter to control if the parameters in defExpr are replaced with default values in the returned object.
        Parameters:
        defExpr - The expression to copy.
        useDefaultValues - Set to true so that default values are set as the parameters of the returned expression instance.
        Returns:
        The new expression instance.
      • newIsExpressionInstance

        public static IlrDTExpressionInstance newIsExpressionInstance(IlrDTContext dtContext,
                                                      java.lang.String holderRoleText,
                                                      java.lang.String paramText)
        Creates a new expression instance using the Object.is() predicate.
        Parameters:
        dtContext - The context.
        holderRoleText - The holder role.
        paramText - The parameter.
        Returns:
        An Expression Instance.
      • isAction

        public static boolean isAction(IlrDTExpressionDefinition expr)
        Tests if the given expression definition represents an action.
        Parameters:
        expr - The expression definition to test.
        Returns:
        If expr represents an action, true is returned.
      • isCollection

        public static boolean isCollection(IlrDTExpressionParameter param)
        Tests if the given parameter stores a collection literal or if it is supposed to store a collection literal.
        Parameters:
        param - The object to test.
        Returns:
        If the parameter value is a collection literal, null, or if the corresponding placeholder has a multiple cardinality, true is returned.
      • isCollection

        public static boolean isCollection(IlrDTExpressionPlaceHolder placeHolder)
        Tests if the given placeholder has a multiple cardinality.
        Parameters:
        placeHolder - The object to test.
        Returns:
        If placeHolder has a multiple cardinality, true is returned.
      • getParameterDisplayTexts

        public static java.util.List<java.lang.String> getParameterDisplayTexts(IlrDTExpressionParameter param)
        Returns a list of strings if the given parameter is a collection literal. The string returned are the display texts of the element of the collection.
        Parameters:
        param - The parameter to check.
        Returns:
        A list of String objects. If the expression is not a collection literal, null is returned.
      • getParameterValues

        public static java.util.List<java.lang.String> getParameterValues(IlrDTExpressionParameter param)
        Returns a list of strings if the given parameter is a collection literal. The string returned are the value texts of the element of the collection.
        Parameters:
        param - The parameter to check.
        Returns:
        A list of String objects. If the expression is not a collection literal, null is returned.
      • getParameterTextOrDefaultValue

        public static java.lang.String getParameterTextOrDefaultValue(IlrDTExpressionParameter parameter)
        This method returns the parameter text of the given ExpressionParameter. If null the the default value of the corresponding place-holder is returned.
        Parameters:
        parameter -
        Returns:
        the expression parameter text or the default value
      • isOtherwise

        public static boolean isOtherwise(IlrDTExpression expr)
        Tests if the given expression is an Otherwise expression.
        Parameters:
        expr - The expression to test.
        Returns:
        If expr is an Otherwise expression, true is returned.
      • getHolderText

        public static java.lang.String getHolderText(IlrDTExpressionText expression)
        Returns the text of the holder role for the given expression.
        Parameters:
        expression - The expression.
        Returns:
        If this expression is valid and has a top sentence which has a holder role, the expression holder concept is returned. If not, null is returned.
      • getHolderConcept

        public static IlrConcept getHolderConcept(IlrDTExpressionText expression)
        Returns the concept object of the holder role for a given expression.
        Parameters:
        expression - The expression.
        Returns:
        If this expression is valid and has a holder role, the expression holder concept is returned.
      • equals

        public static boolean equals(IlrDTExpressionDefinition e1,
                     IlrDTExpressionDefinition e2,
                     boolean includeProperties)
        Tests if the two given expression definitions are equal.
        Parameters:
        e1 - The first expression definition to test.
        e2 - The second expression definition to test.
        includeProperties - Set to true to include the properties of e1 and e2 in the equality tests.
        Returns:
        If e1 and e2 are equal, true is returned.
      • equals

        public static boolean equals(IlrDTExpressionInstance e1,
                     IlrDTExpressionInstance e2,
                     boolean includeProperties)
        Tests if two given expression instances are equal.
        Parameters:
        e1 - The first expression instance to test.
        e2 - The second expression instance to test.
        includeProperties - Set to true to include the properties of e1 and e2 in the equality tests.
        Returns:
        If e1 and e2 are equal, true is returned.

© Copyright IBM Corp. 1987, 2017