ilog.rules.brl.translation

Class IlrTranslationHelper

  • java.lang.Object
    • ilog.rules.brl.translation.IlrTranslationHelper


  • public final class IlrTranslationHelper
    extends java.lang.Object
    IlrTranslationHelper contains shared helper methods used to translate business rule languages to IRL.
    • Field Detail

      • IRL_KEYWORDS

        public static java.lang.String[] IRL_KEYWORDS
    • Method Detail

      • getThisSyntaxNode

        public static IlrSyntaxTree.Node getThisSyntaxNode(IlrSyntaxTree.Node node,
                                           IlrVocabulary vocabulary)
        Returns the abstract syntax tree node that corresponds to the holder role in a phrase.
        Parameters:
        node - The node.
        vocabulary - The vocabulary.
        Returns:
        The abstract syntax tree node. If no node is found, null is returned.
      • isSentence

        public static boolean isSentence(IlrSyntaxTree.Node node)
        Tests if an object is a sentence node, that is, a node of type T-navigation-sentence or T-operator-sentence.
        Parameters:
        node - An abstract syntax tree node.
        Returns:
        If node is a sentence node, true is returned.
      • isOperator

        public static boolean isOperator(IlrSyntaxTree.Node node)
        Tests if an object is an operator sentence node, that is, a node of type T-operator-sentence.
        Parameters:
        node - An abstract syntax tree node.
        Returns:
        If node is an operator sentence node, true is returned.
      • isValue

        public static boolean isValue(IlrSyntaxTree.Node node)
        Tests if an object is a value node, that is, a node of type T-voc-value or T-operator-sentence.
        Parameters:
        node - An abstract syntax tree node.
        Returns:
        If node is a value node, true is returned.
      • isVariable

        public static boolean isVariable(IlrSyntaxTree.Node node)
        Tests if an object is a variable node, that is, a node of type T-voc-variable.
        Parameters:
        node - An abstract syntax tree node.
        Returns:
        If node is a variable node, true is returned.
      • isExpression

        public static boolean isExpression(IlrSyntaxTree.Node node)
        Tests if an object is an expression node, that is, a node of type T-expression.
        Parameters:
        node - The Abstract Syntax Tree node.
        Returns:
        If node is an expression node, true is returned.
      • isSubExpression

        public static boolean isSubExpression(IlrSyntaxTree.Node node)
        Tests if an object is a subexpression node.
        Parameters:
        node - An abstract syntax tree node.
        Returns:
        If node is a subexpression node, true is returned.
      • isCollection

        public static boolean isCollection(IlrSyntaxTree.Node node)
        Tests if an object is a collection node, that is, is of type T-collection.
        Parameters:
        node - An abstract syntax tree node.
        Returns:
        If node is a collection node, true is returned.
      • isConditionSeparator

        public static boolean isConditionSeparator(IlrSyntaxTree.Node sentenceNode,
                                   IlrVocabulary vocabulary)
        Tests if a node references a sentence that is marked as a condition separator.

        The "and"," or", and "not" operators are treates as condition separators.

        Parameters:
        sentenceNode - The node. This object must reference a sentence.
        vocabulary - The vocabulary.
        Returns:
        If sentenceNode references a sentence marked as a condition separator, true is returned.
      • getConcept

        public static IlrConcept getConcept(IlrSyntaxTree.Node conceptNode,
                            IlrVocabulary voc)
        Retrieves a concept from a target node.
        Parameters:
        conceptNode - The abstract syntax tree node.
        voc - The vocabulary.
        Returns:
        The concept found in the vocabulary. If no concept instance is found, null is returned.
      • getTypeInfo

        public static IlrTypeInfo getTypeInfo(IlrSyntaxTree.Node conceptNode,
                              IlrVocabulary voc)
        Returns the type information for a node.
        Parameters:
        conceptNode - The node of type T-voc-concept.
        voc - The vocabulary.
        Returns:
        The IlrTypeInfo corresponding to this concept node.
      • getConceptInstance

        public static IlrConceptInstance getConceptInstance(IlrSyntaxTree.Node valueNode,
                                            IlrVocabulary voc)
        Retrieves a concept instance from a T-voc-value abstract syntax tree node.
        Parameters:
        valueNode - A node of type T-voc-value.
        voc - The vocabulary.
        Returns:
        The concept instance found in the vocabulary. If no concept instance is found, null is returned.
      • isImplicitVariable

        public static boolean isImplicitVariable(IlrSyntaxTree.Node variableNode)
        Tests if a variable node is an implicit variable.
        Parameters:
        variableNode - A node of type T-voc-variable.
        Returns:
        If variableNode is marked as implicit, true is returned.
      • isBinding

        public static boolean isBinding(IlrSyntaxTree.Node node)
        Tests if the given syntactic node is a binding.
        Parameters:
        node - The node to test.
        Returns:
        If node is binding, true is returned.
      • getParameterName

        public static java.lang.String getParameterName(IlrSyntaxTree.Node variableNode)
        Returns the name of the parameter referenced by this variable node.
        Parameters:
        variableNode - A node of type T-voc-variable.
        Returns:
        The name of the parameter. If variableNode does not reference a parameter, null is returned.
      • containerQName

        public static java.lang.String containerQName(java.lang.String qualifiedName)
      • containerQName

        public static java.lang.String containerQName(java.lang.String qualifiedName,
                                      char separator)
      • shortName

        public static java.lang.String shortName(java.lang.String qualifiedName)
      • shortName

        public static java.lang.String shortName(java.lang.String qualifiedName,
                                 char separator)
      • isAutomaticVariable

        public static boolean isAutomaticVariable(IlrSyntaxTree.Node variableNode)
        Tests if a variable node is an automatic variable.
        Parameters:
        variableNode - A T-voc-variable node.
        Returns:
        If the variable is marked as automatic, true is returned.
      • getRoleNode

        public static IlrSyntaxTree.Node getRoleNode(IlrSyntaxTree.Node sentenceNode,
                                     int synRoleIndex)
        Returns the abstract syntax tree node that corresponds to a specific role in a sentence.
        Parameters:
        sentenceNode - The node that references the sentence.
        synRoleIndex - The index of the role (syntactic).
        Returns:
        The abstract syntax tree node that corresponds to the synRoleIndex role in the sentence referred to by sentenceNode.
      • makeIdentifier

        public static java.lang.String makeIdentifier(java.lang.String name)
        Makes a valid identifier from the specified name.
        Parameters:
        name - The name.
        Returns:
        A valid identifier to be used in generated text.
      • getVariableName

        public static java.lang.String getVariableName(IlrSyntaxTree.Node variableNode)
        Returns the name of the variable. If the XML_PI_EXE_VARNAME processing instruction has been set, the name specified is returned. If not, the name stored in the node is returned.
        Parameters:
        variableNode - The node whose name is to be returned.
        Returns:
        The variable name to be used in the translation.
      • isRulesetParameter

        public static boolean isRulesetParameter(IlrSyntaxTree.Node variableNode)
        Deprecated. use IlrSyntaxTreeHelper API
        Tests if the variable node is a ruleset parameter.
        Parameters:
        variableNode - The node of type T-voc-variable.
        Returns:
        true if the variable node is a parameter.
      • isRulesetVariable

        public static boolean isRulesetVariable(IlrSyntaxTree.Node variableNode)
        Deprecated. use IlrSyntaxTreeHelper API
        Tests if the variable node is a ruleset variable.
        Parameters:
        variableNode - The node of type T-voc-variable.
        Returns:
        true if the variable node is a ruleset variable.

© Copyright IBM Corp. 1987, 2017