Interface VerbalChoice

All Superinterfaces:
Choice, Serializable
All Known Implementing Classes:
AbstractPermutedChoice, AbstractVerbalChoice, ActionPermutedChoice, SimpleTestPermutedChoice, VerbalChoiceImpl

public interface VerbalChoice extends Choice
Since:
12.1.2 Represents a Choice for the value of a VerbalProperty Sample Usage:

To obtain the display value of a VerbalChoice 'verbalChoice' verbalChoice.getValue(); // This can be used to construct a list of auto-complete suggestions

To construct the editable display value for setting parameters and setting the choice on a VerbalRuleComponent VerbalChoiceTokenizer vcTokenizer = verbalChoice.getVerbalChoiceTokenizer(); for(int k = 0; k < vcTokenizer.size(); k++) { VerbalChoiceToken token = vcTokenizer.get(k); String tokenValue = token.getValue(); switch(token.getType()){ case VerbalChoiceToken.Type.value: // Render tokenValue using a value editor case VerbalChoiceToken.Type.variable: // Render tokenValue using a variable chooser case VerbalChoiceToken.Type.expression: // Render tokenValue using an expression editor case VerbalChoiceToken.Type.text: // Render as Text uiComponentMap.put(uiComponent, token); } } verbalRuleComponent.setValue(verbalChoice);

To set the value of a required parameter in the VerbalChoice VerbalChoiceToken token = uiComponentMap.get(uiComponent); token.setValue(uiComponent.getValue());

To Add an Expression in the VerbalChoice for the [in] operator verbalChoice.addExpression(value);

To Remove an Expression from the VerbalChoice for the [in] operator VerbalChoiceToken token = uiComponentMap.get(uiComponent); verbalChoice.removeExpression(token);

Author:
gopandey
  • Field Details

    • VERBAL_CHOICE_EXPR

      static final String VERBAL_CHOICE_EXPR
      Place holder translated property for expressions
      See Also:
    • VERBAL_CHOICE_TYPE

      static final String VERBAL_CHOICE_TYPE
      Place holder translated property for expressions
      See Also:
    • VERBAL_CHOICE_VAR

      static final String VERBAL_CHOICE_VAR
      Place holder translated property for variables
      See Also:
  • Method Details

    • getVerbalChoiceTokenizer

      VerbalChoiceTokenizer getVerbalChoiceTokenizer()
      Get a tokenizer to compute the display value of the VerbalChoice. Tokens can be used to identify expressions and variables and to set their values in the VerbalChoice.
      Returns:
      VerbalChoiceTokenizer
    • addExpression

      void addExpression(String value)
      Adds an Expression to the VerbalChoice if and only if canAddExpression() is true. Else, this is a no-op. Adding an Expression resets the VerbalChoice. To obtain the new display value for the VerbalChoice, MUST iterate through the VerbalChoiceTokenizer from the beginning
      Parameters:
      value - Expression Value
    • addExpression

      void addExpression(Choice value)
      Adds an Expression to the VerbalChoice if and only if canAddExpression() is true. Else, this is a no-op. Adding an Expression resets the VerbalChoice. To obtain the new display value for the VerbalChoice, MUST iterate through the VerbalChoiceTokenizer from the beginning
      Parameters:
      value - Choice representing the Expression Value
    • removeExpression

      void removeExpression(VerbalChoiceToken token)
      Removes an expression from the VerbalChoice if and only if canRemoveExpression(oracle.rules.sdk2.dictionary.VerbalChoiceToken) is true and there are more than two Expressions. Else, this is a no-op. Removing an Expression resets the VerbalChoice. To obtain the new display value for the VerbalChoice, MUST iterate through the VerbalChoiceTokenizer from the beginning
      Parameters:
      token - Token representing the Expression to be removed
    • canAddExpression

      boolean canAddExpression()
      Can be used to check if Expressions can be added to this VerbalChoice
      Returns:
      true if this VerbalChoice is for a SimpleTest and has the [in] operator, false otherwise
    • canRemoveExpression

      boolean canRemoveExpression(VerbalChoiceToken token)
      Can be used to check if Expressions can be removed from this VerbalChoice
      Parameters:
      token - Token representing the Expression to be removed
      Returns:
      true if this VerbalChoice is for a SimpleTest and has the [in] operator and has more than 2 expressions, false otherwise
    • hasParameters

      boolean hasParameters()
      Check if the VerbalChoice has any required parameters
      Returns:
      true if the VerbalChoice has any parameters, false otherwise
    • getSimilarChoices

      List<VerbalChoice> getSimilarChoices()
      A list of VerbalChoices that are similar to this choice. If the VerbalChoice is for a SimpleTest, the returned list would be the choices with the same left and right expressions, with different operators. If the VerbalChoice is for an Action, this may not be relevant.
      Returns:
      a list of similar VerbalChoices
    • isNewDefinition

      boolean isNewDefinition()
      Does this VerbalChoice represent a new Definition
      Returns:
      true if the VerbalChoice represents a new Definition, false otherwise