ilog.rules.dt

Class IlrDTIRLTranslator

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public class IlrDTIRLTranslator
    extends IlrDTTranslator
    This class is the implementation of an IRL translator for DT. It transforms a decision table or a decision tree into IRL code. Subclasses can be created using the IlrDTIRLTranslatorFactory.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      class  IlrDTIRLTranslator.DTRowTranslatorInput
      This class is the implementation of TranslatorInput used to translate a row of the DT.
    • Constructor Summary

      Constructors 
      Constructor and Description
      IlrDTIRLTranslator(IlrDTController controller)
      This constructor creates a new DT translator for the DT represented by the given controller.
      IlrDTIRLTranslator(IlrDTController controller, boolean useInEditor)
      This constructor creates a new DT translator for the DT represented by the given controller.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      java.lang.String convertIntoCode(java.util.Collection errors)
      This method converts the DT associated to this translator into IRL.
      protected IlrBRLTranslator createTranslator()
      This method creates a BRL Translator to be used to translate DT rows in IRL code
      protected IlrTranslatorInput createTranslatorInput(IlrDTActionSet actionSet, java.lang.String balCode, int ruleIndex)
      This method creates a Translator Input to be used by the BRL translator to convert the given row.
      protected void generateBALComment(IlrDTActionSet as, java.lang.String balCode)
      This method generates the given balCode as a comment before the IRL translation of the rule represented by the given action set
      protected void generateBegin()
      This method generates a header before generating the 1st rule of the DT
      protected void generateEnd()
      This method generates a footer after generating the last rule of the DT
      boolean generateRule(IlrDTActionSet as, int ruleIndex)
      Deprecated.  
      protected void generateRuleBegin(IlrDTActionSet as, int ruleIndex)
      This method generates a header before generating the rule corresponding to the given action set.
      protected void generateRuleEnd(IlrDTActionSet as, int ruleIndex)
      This method generates a footer after having generated the rule corresponding to the given action set.
      protected java.lang.String getRuleName(IlrDTActionSet as, int ruleIndex)
      This method compute the name of the rule corresponding to the given action set
      IlrBRLTranslator getTranslator()
      This method returns the BRL translator used by this DT translator
      void useBAL(boolean useBAL, boolean generateComments)
      This method allows specifying if this translator should generate IRL code from the BAL representation of the rules and if the IRL code should contains comments with the BAL representation of the rules.
      boolean useInEditor()
      Deprecated. 
      this method was supposed to be used by the implementation only
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IlrDTIRLTranslator

        public IlrDTIRLTranslator(IlrDTController controller)
        This constructor creates a new DT translator for the DT represented by the given controller.
        Parameters:
        controller -
      • IlrDTIRLTranslator

        public IlrDTIRLTranslator(IlrDTController controller,
                          boolean useInEditor)
        This constructor creates a new DT translator for the DT represented by the given controller.
        Parameters:
        controller -
        useInEditor - if true, IRL representations of rules are cached to be re-used when regenerating the code using this translator. This cache is invalidated according to changes on the DT model.
    • Method Detail

      • getTranslator

        public IlrBRLTranslator getTranslator()
        This method returns the BRL translator used by this DT translator
        Returns:
        the BRL translator
      • useInEditor

        public boolean useInEditor()
        Deprecated. this method was supposed to be used by the implementation only
        When use in an editor, specific caching are applied
        Returns:
        whether this translator has been created to be used in an editor.
      • useBAL

        public void useBAL(boolean useBAL,
                  boolean generateComments)
        This method allows specifying if this translator should generate IRL code from the BAL representation of the rules and if the IRL code should contains comments with the BAL representation of the rules.
        Parameters:
        useBAL - specify if code generation should be deduced from BAL representation or not
        generateComments - true to generate comments in the IRL code
      • convertIntoCode

        public java.lang.String convertIntoCode(java.util.Collection errors)
        This method converts the DT associated to this translator into IRL. Any errors related to the generation of this DT are collected in the given errors collection. If no rules are generated and if the DT is in a package, an empty package declaration is generated. If the DT is not in a package an empty string is generated.
        Specified by:
        convertIntoCode in class IlrDTTranslator
        Parameters:
        errors - when not null, this collection is filled with code generation errors
        Returns:
        the IRL code of the DT or an empty string if no rules can be generated from this DT.
      • generateRule

        public boolean generateRule(IlrDTActionSet as,
                           int ruleIndex)
                             throws java.io.IOException
        Deprecated. 
        This method generate the code of the rule corresponding to the given ActionSet.
        Throws:
        java.io.IOException
        Parameters:
        as - the action set
        ruleIndex - the index of the rule in the generated DT
        Returns:
        true if some IRL code has been generated by this method and false otherwise
      • generateBALComment

        protected void generateBALComment(IlrDTActionSet as,
                              java.lang.String balCode)
        This method generates the given balCode as a comment before the IRL translation of the rule represented by the given action set
        Parameters:
        as -
        balCode -
      • generateBegin

        protected void generateBegin()
                              throws java.io.IOException
        This method generates a header before generating the 1st rule of the DT
        Throws:
        java.io.IOException
      • generateEnd

        protected void generateEnd()
                            throws java.io.IOException
        This method generates a footer after generating the last rule of the DT
        Throws:
        java.io.IOException
      • generateRuleBegin

        protected void generateRuleBegin(IlrDTActionSet as,
                             int ruleIndex)
                                  throws java.io.IOException
        This method generates a header before generating the rule corresponding to the given action set.
        Throws:
        java.io.IOException
        Parameters:
        as - the action set
        ruleIndex - the index of the rule in the generated DT
      • getRuleName

        protected java.lang.String getRuleName(IlrDTActionSet as,
                                   int ruleIndex)
        This method compute the name of the rule corresponding to the given action set
        Parameters:
        as - the action set
        ruleIndex - the index of the rule in the generated DT
        Returns:
        a business rule name. This name will be made IRL compliant by the caller.
      • generateRuleEnd

        protected void generateRuleEnd(IlrDTActionSet as,
                           int ruleIndex)
                                throws java.io.IOException
        This method generates a footer after having generated the rule corresponding to the given action set.
        Throws:
        java.io.IOException
        Parameters:
        as - the action set
        ruleIndex - the index of the rule in the generated DT
      • createTranslator

        protected IlrBRLTranslator createTranslator()
        This method creates a BRL Translator to be used to translate DT rows in IRL code
        Returns:
        a BRL translator
      • createTranslatorInput

        protected IlrTranslatorInput createTranslatorInput(IlrDTActionSet actionSet,
                                               java.lang.String balCode,
                                               int ruleIndex)
        This method creates a Translator Input to be used by the BRL translator to convert the given row. This method creates an instance of DTRowTranslatorInput.
        Parameters:
        actionSet - the action set representing the row that will be translated
        balCode - the BAL code corresponding to the translated row. May be null is translation is not based on BAL text.
        ruleIndex - the index of the row to be translated
        Returns:
        the created Translator Input.

© Copyright IBM Corp. 1987, 2017