Rule Designer API

ilog.rules.dt.expression
Class ExpressionHelper

java.lang.Object
  extended by ilog.rules.dt.expression.ExpressionHelper

public class ExpressionHelper
extends Object

ExpressionHelper provides helper methods used to manipulate expressions in a DT Model.

Since:
JRules 7.0

Constructor Summary
ExpressionHelper()
           
 
Method Summary
static boolean equals(IlrDTExpressionDefinition e1, IlrDTExpressionDefinition e2, boolean includeProperties)
          Tests if the two given expression definitions are equal.
static boolean equals(IlrDTExpressionInstance e1, IlrDTExpressionInstance e2, boolean includeProperties)
          Tests if two given expression instances are equal.
static IlrDecorableElement getExpressionElement(IlrDTExpression expr, int index)
          Returns the placeholder or parameter located at a specific index in the given expression.
static int getExpressionElementCount(IlrDTExpression expr)
          Returns the number of placeholders in an expression definition or the number of parameters in an expression instance.
static IlrConcept getHolderConcept(IlrDTExpressionText expression)
          Returns the concept object of the holder role for a given expression.
static String getHolderText(IlrDTExpressionText expression)
          Returns the text of the holder role for the given expression.
static List<String> getParameterDisplayTexts(IlrDTExpressionParameter param)
          Returns a list of strings if the given parameter is a collection literal.
static String getParameterTextOrDefaultValue(IlrDTExpressionParameter parameter)
          This method returns the parameter text of the given ExpressionParameter.
static List<String> getParameterValues(IlrDTExpressionParameter param)
          Returns a list of strings if the given parameter is a collection literal.
static IlrDTExpressionPlaceHolder getPlaceHolderForParameter(IlrDTExpressionParameter param)
          Returns the placeholder that corresponds to the given expression parameter.
static String getPlaceHolderLabel(IlrDTExpressionDefinition expr, int index)
          Returns the placeholder label without the < and the > in the string.
static boolean isAction(IlrDTExpressionDefinition expr)
          Tests if the given expression definition represents an action.
static boolean isCollection(IlrDTExpressionParameter param)
          Tests if the given parameter stores a collection literal or if it is supposed to store a collection literal.
static boolean isCollection(IlrDTExpressionPlaceHolder placeHolder)
          Tests if the given placeholder has a multiple cardinality.
static boolean isExpressionComplete(IlrDTExpressionInstance instance)
          Tests if all parameters are nonempty or reference a placeholder that has a nonempty default value.
static boolean isExpressionSentenceMeaningfull(IlrDTExpressionInstance expression)
           
static boolean isOtherwise(IlrDTExpression expr)
          Tests if the given expression is an Otherwise expression.
static IlrDTExpressionInstance newExpressionInstance(IlrDTExpressionDefinition defExpr, boolean useDefaultValues)
          Creates a new expression instance derived from a given definition.
static IlrDTExpressionInstance newIsExpressionInstance(IlrDTContext dtContext, String holderRoleText, String paramText)
          Creates a new expression instance using the Object.is() predicate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionHelper

public ExpressionHelper()
Method Detail

getPlaceHolderLabel

public static 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,
                                                              String holderRoleText,
                                                              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 List<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 List<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 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 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.

Rule Designer API

© Copyright IBM Corp. 1987, 2013