ilog.rules.engine

Class IlrRuleset

  • java.lang.Object
    • ilog.rules.engine.IlrRuleset
    • Constructor Summary

      Constructors 
      Constructor and Description
      IlrRuleset()
      Constructs an IlrRuleset using the type IlrContext.
      IlrRuleset(java.lang.Class contextClass)
      Deprecated. 
      Context subclassing is deprecated; use ruleset variables to hold execution data.
      IlrRuleset(IlrClass contextClass)
      Deprecated. 
      Context subclassing is deprecated; use ruleset variables to hold execution data.
      IlrRuleset(IlrReflect reflect)
      Constructs an IlrRuleset using an IlrReflect.
      IlrRuleset(IlrRuleset ruleset)
      Constructs an IlrRuleset from another IlrRuleset.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addRule(IlrRule rule)
      Deprecated. 
      As of JRules 6.5 this method has been deprecated, considering the severe restrictions on its usage. For a consistent add operation use incremental parsing on a single ruleset instead of relying on this method.
      void addRules(IlrRule[] rules)
      Deprecated. 
      As of JRules 6.5 this method has been deprecated, considering the severe restrictions on its usage. For a consistent add operation use incremental parsing on a single ruleset instead of relying on this method.
      boolean containsRule(IlrRule rule)
      Tests whether the ruleset contains a rule, that means tests whether one package of the ruleset contains the rule.
      java.util.Vector getAllContexts()
      Returns the contexts created (and therefore attached) using this ruleset.
      IlrFunction[] getAllFunctions()
      Returns all the functions in the ruleset, that means all functions in all ruleset packages.
      IlrRule[] getAllRules()
      Returns all the rules in the ruleset, that means all the rules in all ruleset packages.
      IlrTask[] getAllTasks()
      Returns all the tasks in the ruleset, that means all the tasks of all ruleset packages.
      boolean getBooleanProperty(java.lang.String propname, boolean def)
      Gets the value of a boolean property.
      java.lang.Class getContextClass()
      Returns the context class of this ruleset.
      IlrPackage getDefaultPackage()
      Returns the default package of the ruleset.
      double getDoubleProperty(java.lang.String propname, double def)
      Gets the value of a float property.
      IlrFunction getFunction(java.lang.String name, java.lang.Class[] argumentTypes)
      Returns the function in the ruleset whose name is name and whose arguments types are those passed as parameter.
      IlrFunction getFunction(java.lang.String name, IlrType[] argumentTypes)
      Returns the function in the ruleset whose name is name and whose arguments types are those passed as parameter.
      java.util.Map getHierarchicalProperties()
      Returns the hierarchical properties attached to the ruleset.
      IlrHierarchicalProperty getHierarchicalProperty(java.lang.String name)
      Returns the hierarchical property attached to the ruleset whose name is equals to the given parameter.
      int getIntProperty(java.lang.String propname, int def)
      Gets the value of an int property.
      int getMessageNumber()
      Returns the number of errors detected during the last parsing operation.
      java.io.PrintWriter getMessageWriter()
      Returns the PrintWriter object to which error messages are printed.
      java.lang.String getName()
      Gets the name of the ruleset.
      IlrPackage getPackage(java.lang.String name)
      Returns the specified package from the ruleset.
      IlrPackage[] getPackages()
      Gets the packages of this ruleset.
      IlrRule[] getPacketRules(java.lang.String packetName)
      Deprecated.  
      IlrPropertyList getProperties()
      Gets the property list of this ruleset.
      java.lang.Object getProperty(java.lang.String propname, java.lang.Object def)
      Gets the value of a property as an object.
      IlrReflect getReflect()
      Gets the reflect object of this ruleset.
      IlrResources getResources()
      Gets the resource bundle of this ruleset.
      IlrRule getRule(java.lang.String ruleName)
      Returns the rule whose name is given as the parameter.
      java.util.Iterator getRuleIterator()
      Returns an iterator on the rules contained in the ruleset, that means on the rules contained in all ruleset packages.
      int getRuleNumber()
      Returns the number of rules in this ruleset, that is the total of rules contained in all packages of this ruleset.
      protected java.util.List getRules() 
      IlrRulesetParameter[] getRulesetSignature()
      Returns the signature of the ruleset.
      IlrRulesetParameter[] getRulesetVariables(int modifier)
      Returns the ruleset variables for a specific modifier.
      IlrRulesetParameter[] getSignature()
      Deprecated.  
      java.lang.String getStringProperty(java.lang.String propname, java.lang.String def)
      Gets the value of a string property.
      IlrTask getTask(java.lang.String name)
      Returns the task defined in the ruleflow and whose name is the one passed as the parameter.
      boolean isLocked()
      Returns true if the ruleset is locked.
      IlrRulesetFactory makeFactory()
      Builds a factory object that represents this ruleset.
      void mergeRules(IlrRuleset ruleset)
      Deprecated. 
      As of JRules 6.5 this method has been deprecated, considering the severe restrictions on its usage. For a consistent merge operation use incremental parsing on a single ruleset instead of relying on this method.
      boolean optimize(IlrRulesetOptimConfig config)
      Optimizes the rules.
      boolean parseFactory(IlrRulesetFactory factory)
      Parses the ruleset factory.
      boolean parseFile(java.io.File file)
      Deprecated. 
      The preferred method for loading rulesets generated by ILOG rule authoring tools is via ruleset archives. If it is necessary to load rules directly from IRL text, see parseStream(java.io.InputStream) or parseReader(java.io.Reader)
      boolean parseFileName(java.lang.String fileName)
      Deprecated. 
      The preferred method for loading rulesets generated by ILOG rule authoring tools is via ruleset archives. If it is necessary to load rules directly from IRL text, see parseStream(java.io.InputStream) or parseReader(java.io.Reader)
      boolean parseReader(java.io.Reader reader)
      Parses the supplied java.io.Reader.
      boolean parseStream(java.io.InputStream stream)
      Parses the stream provided as its argument.
      boolean parseString(java.lang.String source)
      Deprecated. 
      The preferred method for loading rulesets generated by ILOG rule authoring tools is via ruleset archives. If it is necessary to load rules directly from IRL text, see parseStream(java.io.InputStream) or parseReader(java.io.Reader)
      boolean parseURL(java.net.URL url)
      Deprecated. 
      The preferred method for loading rulesets generated by ILOG rule authoring tools is via ruleset archives. If it is necessary to load rules directly from IRL text, see parseStream(java.io.InputStream) or parseReader(java.io.Reader)
      void removeMetadata()
      Removes metadata from rules and from the Rete network.
      void removeMetadata(boolean fromRules, boolean fromRete)
      Removes metadata from rules and from the Rete network.
      void removeRule(IlrRule rule)
      Removes a rule from the ruleset.
      void removeRules(IlrRule[] rules)
      Removes rules from the packages that contain them.
      void replaceRule(IlrRule newRule)
      Deprecated. 
      As of JRules 6.5 this method has been deprecated, considering the severe restrictions on its usage. For a consistent replace operation use incremental parsing on a single ruleset instead of relying on this method.
      void setAllowPackageDeclaration(boolean ng)
      Specifies whether the ruleset code may contain a package declaration.
      void setApplication(java.lang.String application)
      Deprecated. 
      As of JRules 7.0, this method has no effect.
      void setMessageWriter(java.io.PrintWriter writer)
      Sets the error message writer of the ruleset.
      void setName(java.lang.String name)
      Sets the name of the ruleset.
      void setResources(IlrResources resources)
      Sets the resource bundle.
      • Methods inherited from class java.lang.Object

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

      • IlrRuleset

        public IlrRuleset()
        Constructs an IlrRuleset using the type IlrContext. The rules in the ruleset will have access only to the fields and methods defined in IlrContext. Initially, the ruleset contains no rules. This constructor creates a new IlrReflect.
      • IlrRuleset

        public IlrRuleset(IlrReflect reflect)
        Constructs an IlrRuleset using an IlrReflect. The context class of this ruleset is IlrContext.class.
        Parameters:
        reflect - The reflect object of this ruleset.
      • IlrRuleset

        public IlrRuleset(java.lang.Class contextClass)
        Deprecated. Context subclassing is deprecated; use ruleset variables to hold execution data.
        Constructs an IlrRuleset using a specific context class. The context class must be a subclass of IlrContext. The context class can be obtained using the construct MyDerivedContextClassName.class or by the static method Class.forName.

        The constructor throws an IlrBadContextException if the given class is not a subclass of IlrContext.

        The scope of the rules in the ruleset will be the context class. These rules will have access to the fields and methods defined in the subclass. Initially, the ruleset contains no rules. This constructor creates a new IlrReflect.

        Parameters:
        contextClass - A derived class of IlrContext.
      • IlrRuleset

        public IlrRuleset(IlrClass contextClass)
        Deprecated. Context subclassing is deprecated; use ruleset variables to hold execution data.
        Constructs an IlrRuleset using a specific context class. The context class must be a subclass of IlrContext.

        The constructor throws an IlrBadContextException if the given class is not a subclass of IlrContext.

        The reflect object of this ruleset is the object model of the class descriptor passed as the argument.

        Parameters:
        contextClass - A derived class of IlrContext.
      • IlrRuleset

        public IlrRuleset(IlrRuleset ruleset)
        Constructs an IlrRuleset from another IlrRuleset. The new ruleset will have the same context class and the same error output writer as the specified ruleset. It will contain no rules (the rules of the supplied ruleset are not duplicated) and will have no context attached to it.
        Parameters:
        ruleset - The ruleset constructor.
    • Method Detail

      • setAllowPackageDeclaration

        public void setAllowPackageDeclaration(boolean ng)
        Specifies whether the ruleset code may contain a package declaration. The default value is true. In this case, a package declaration is allowed, and the definition of an artifact (such as a rule, function, or task) with a name containing a '.' (period) character is not allowed.

        To migrate IRL from JRules versions prior to JRules 6, this method needs to be called with the Boolean parameter set to false. In this case, a package declaration is not allowed, and artifact definitions whose names contain a '.' character are allowed. For example, when an artifact named a.b is encountered, a package named a is created and contains an artifact named b.

      • getReflect

        public final IlrReflect getReflect()
        Gets the reflect object of this ruleset.
        Returns:
        the reflect object of this ruleset.
      • getName

        public final java.lang.String getName()
        Gets the name of the ruleset. The name is a simple string used to identify the ruleset. Initially, the name of a ruleset is the name of its context class.
        Returns:
        the name of the ruleset.
      • setName

        public final void setName(java.lang.String name)
        Sets the name of the ruleset.
        Parameters:
        name - The name of the ruleset. The argument can be null.
      • getProperties

        public final IlrPropertyList getProperties()
        Gets the property list of this ruleset.
        Returns:
        a property list.
      • getContextClass

        public final java.lang.Class getContextClass()
        Returns the context class of this ruleset.
        Returns:
        the context class of this ruleset.
      • getAllContexts

        public final java.util.Vector getAllContexts()
        Returns the contexts created (and therefore attached) using this ruleset.
        Returns:
        A list of IlrContext. Each context is attached to this ruleset. The length of the list can be 0.
      • getHierarchicalProperties

        public java.util.Map getHierarchicalProperties()
        Returns the hierarchical properties attached to the ruleset. In case there is no such properties, the returned value is null. In the returned hash table, the key is the hierarchical property name, the value is the hierarchical property ilog.rules.factory.IlrHierarchicalPropertyitself.
        Returns:
        A map containing the ruleset hierarchical properties.
      • getHierarchicalProperty

        public IlrHierarchicalProperty getHierarchicalProperty(java.lang.String name)
        Returns the hierarchical property attached to the ruleset whose name is equals to the given parameter.
        Parameters:
        name - The name of the hierarchical property we are looking for.
        Returns:
        A hierarchical property, named as requested, attached to the ruleset. Returns null in case the ruleset has no hierarchical property or in case no property is named as requested.
      • getPackage

        public final IlrPackage getPackage(java.lang.String name)
        Returns the specified package from the ruleset.
        Parameters:
        name - The name of the package we are looking for.
        Returns:
        The package defined in the ruleset whose name matches the specified parameter. Returns null in case there is no such package.
      • getDefaultPackage

        public final IlrPackage getDefaultPackage()
        Returns the default package of the ruleset. The default package is the one whose name is the empty string.
        Returns:
        The default package contained by the ruleset.
      • getPackages

        public final IlrPackage[] getPackages()
        Gets the packages of this ruleset.
        Returns:
        The packages of this ruleset.
      • getRuleNumber

        public final int getRuleNumber()
        Returns the number of rules in this ruleset, that is the total of rules contained in all packages of this ruleset.
        Returns:
        the number of rules in this ruleset.
      • getRule

        public final IlrRule getRule(java.lang.String ruleName)
        Returns the rule whose name is given as the parameter.
        Parameters:
        ruleName - The name of the rule.
        Returns:
        the IlrRule whose name is provided as the parameter, if this rule exists. Otherwise, null is returned.
      • getRuleIterator

        public final java.util.Iterator getRuleIterator()
        Returns an iterator on the rules contained in the ruleset, that means on the rules contained in all ruleset packages. The remove method of this iterator will throw an UnsupportedOperationException.
        Since:
        JRules 6.0
        Returns:
        An iterator on IlrRule instances.
      • getRules

        protected java.util.List getRules()
      • containsRule

        public final boolean containsRule(IlrRule rule)
        Tests whether the ruleset contains a rule, that means tests whether one package of the ruleset contains the rule.
        Parameters:
        rule - A rule.
        Returns:
        true if the ruleset contains the rule. Otherwise, it returns false.
      • getAllRules

        public final IlrRule[] getAllRules()
        Returns all the rules in the ruleset, that means all the rules in all ruleset packages.
        Returns:
        an array of IlrRule. The length of the array can be 0.
      • addRule

        public void addRule(IlrRule rule)
        Deprecated. As of JRules 6.5 this method has been deprecated, considering the severe restrictions on its usage. For a consistent add operation use incremental parsing on a single ruleset instead of relying on this method.
        Adds a rule to the default package if the rule does not specify its package; otherwise the rule is added to its package. If the context class of the supplied rule does not match the context class of the ruleset or if the ruleset already contains the rule, the rule is not added. If the rule is added, all the contexts attached to the ruleset are notified and updated accordingly.

        The usage of this method is strictly limited to the case of a new rule which does not make use of other elements from its declaring ruleset such as ruleset parameters, functions, and so on. The reason is that this method will only perform a shallow copy of the new rule to the recipient one without considering the replacement or the addition of all the ruleset elements on which the new rule may depend.

        Parameters:
        rule - The rule to be added.
        See Also:
        IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseReader(java.io.Reader), parseFactory(ilog.rules.factory.IlrRulesetFactory)
      • addRules

        public void addRules(IlrRule[] rules)
        Deprecated. As of JRules 6.5 this method has been deprecated, considering the severe restrictions on its usage. For a consistent add operation use incremental parsing on a single ruleset instead of relying on this method.
        Adds rules to the ruleset. If the context class of the supplied rules does not correspond to the context class of the ruleset or if the ruleset already contains the rules, the rules are not added. Each time a rule is added, all the contexts attached to the ruleset are notified and updated accordingly.

        The usage of this method is strictly limited to the case of new rules which do not make use of other elements from their declaring ruleset such as ruleset parameters, functions, and so on. The reason is that this method will only perform a shallow copy of the new rules to the recipient one without also considering the replacement or the addition of all the ruleset elements on which the new rules may depend.

        Parameters:
        rules - The array of rules.
        See Also:
        IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseReader(java.io.Reader), parseFactory(ilog.rules.factory.IlrRulesetFactory)
      • removeRule

        public void removeRule(IlrRule rule)
        Removes a rule from the ruleset. This method does nothing if the ruleset does not contain the supplied rule. If the rule is removed, all of the contexts attached to the ruleset are notified and updated accordingly.

        Note that the ruleset elements of which the rule may be the unique user, such as ruleset parameters, functions, and so on, are not automatically removed when the rule is removed.

        Parameters:
        rule - The rule to be removed.
      • removeRules

        public void removeRules(IlrRule[] rules)
        Removes rules from the packages that contain them. Each time a rule is removed, all the contexts attached to the ruleset are notified and updated.
        Parameters:
        rules - The array of rules.
        See Also:
        removeRule(ilog.rules.engine.IlrRule)
      • replaceRule

        public void replaceRule(IlrRule newRule)
        Deprecated. As of JRules 6.5 this method has been deprecated, considering the severe restrictions on its usage. For a consistent replace operation use incremental parsing on a single ruleset instead of relying on this method.
        Replaces a rule with the rule provided as its argument if both have the same name. If there is no rule with the same name as the one supplied, the rule is simply added. The specified rule must have the same context class as the ruleset. All the contexts attached to the ruleset are notified and updated accordingly.

        The usage of this method is strictly limited to the case of a new rule which does not make use of other elements from its declaring ruleset such as ruleset parameters, functions, and so on. The reason is that this method will only perform a shallow replacement of the new rule in the recipient one without also considering the replacement or the addition of all the ruleset elements on which the new rule may depend.**

        Parameters:
        newRule - The rule to be added. It will replace a rule with the same name.
        See Also:
        IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseReader(java.io.Reader), parseFactory(ilog.rules.factory.IlrRulesetFactory)
      • mergeRules

        public void mergeRules(IlrRuleset ruleset)
        Deprecated. As of JRules 6.5 this method has been deprecated, considering the severe restrictions on its usage. For a consistent merge operation use incremental parsing on a single ruleset instead of relying on this method.
        Merges the rules in the ruleset with the rules in the ruleset passed as an argument. The provided ruleset must have the same context class. If rules in the supplied ruleset have the same name as existing rules, these are replaced with the new rules. Otherwise, new rules are simply added. If the provided ruleset contains Initial Actions, they replace the existing Initial Actions. All the contexts attached to the ruleset are notified and updated accordingly.

        The usage of this method is strictly limited to the case of an argument ruleset which contains only rules or an initial action. This method should not be used once the rules or the initial action from the argument ruleset make use of other elements which are also declared in the argument ruleset such as ruleset parameters, functions, and so on. The reason is that this method will only perform a shallow merge of the rules from the argument ruleset to the recipient ruleset without also considering the merge of the other ruleset elements on which those rules may depend.

        Parameters:
        ruleset - The ruleset that is merged with the current ruleset.
        See Also:
        IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseReader(java.io.Reader), parseFactory(ilog.rules.factory.IlrRulesetFactory)
      • getAllFunctions

        public final IlrFunction[] getAllFunctions()
        Returns all the functions in the ruleset, that means all functions in all ruleset packages.
        Returns:
        an array of IlrFunction[]. The length of the array can be 0.
      • getFunction

        public final IlrFunction getFunction(java.lang.String name,
                              java.lang.Class[] argumentTypes)
        Returns the function in the ruleset whose name is name and whose arguments types are those passed as parameter.
        Parameters:
        name - The name of the function we are looking for.
        argumentTypes - The array of argument types, as Class, that correspond to the signature of the function we are looking for.
        Returns:
        a function defined in the ruleset with the name and signature specified in the arguments.
      • getFunction

        public final IlrFunction getFunction(java.lang.String name,
                              IlrType[] argumentTypes)
        Returns the function in the ruleset whose name is name and whose arguments types are those passed as parameter.
        Parameters:
        name - The name of the function we are looking for.
        argumentTypes - The array of argument types, as Class, that correspond to the signature of the function we are looking for.
        Returns:
        a function defined in the ruleset with the name and signature specified in the arguments.
      • getTask

        public IlrTask getTask(java.lang.String name)
        Returns the task defined in the ruleflow and whose name is the one passed as the parameter. Returns null if no such task exists.
        Parameters:
        name - The name of a task to return.
        Returns:
        the task name of name.
      • getAllTasks

        public final IlrTask[] getAllTasks()
        Returns all the tasks in the ruleset, that means all the tasks of all ruleset packages.
        Returns:
        an array of IlrTask[]. The length of the array can be 0.
      • getSignature

        public IlrRulesetParameter[] getSignature()
        Deprecated. 
        Returns the signature of the ruleset. The signature is composed with the variables tagged either "in" or "inout". The signature is an array of IlrRulesetParameter, each of them containing the type, as an IlrClass and the name of the variable.
        Returns:
        The ruleset's signature, that is the set of variables tagged either "in" or "inout".
        See Also:
        IlrRulesetParameter
      • getRulesetSignature

        public IlrRulesetParameter[] getRulesetSignature()
        Returns the signature of the ruleset. The signature is composed with the variables tagged either "in" "inout" or "out". The signature is an array of IlrRulesetParameter, each of them containing the type, as an IlrClass and the name of the variable.
        Returns:
        The ruleset's signature, that is the set of variables tagged either "in" or "inout".
        See Also:
        IlrRulesetParameter
      • getRulesetVariables

        public IlrRulesetParameter[] getRulesetVariables(int modifier)
        Returns the ruleset variables for a specific modifier.
        Parameters:
        modifier - A mask built from values defined in ilog.rules.factory.IlrRulesetConstants. The modifier for local variables is 0.
        Returns:
        An array of IlrRulesetParameter objects. Each object contains:
        • An IlrClass instance representing the type of the object.
        • The name of the variable.
        See Also:
        IlrRulesetParameter, IlrRulesetConstants.In, IlrRulesetConstants.Out
      • getResources

        public final IlrResources getResources()
        Gets the resource bundle of this ruleset.
        Returns:
        The resource bundle of this ruleset.
      • setResources

        public final void setResources(IlrResources resources)
        Sets the resource bundle.
        Parameters:
        resources - A resource bundle. It cannot be null.
      • getBooleanProperty

        public final boolean getBooleanProperty(java.lang.String propname,
                                 boolean def)
        Gets the value of a boolean property. The property value is searched, respectively, in the ruleset header in the IRL file, then in the resource bundle of the ruleset, then in the resource bundle of the reflect object, and finally as a system property.
        Parameters:
        propname - The name of the property.
        def - The default value to return if the property is not defined.
      • getStringProperty

        public final java.lang.String getStringProperty(java.lang.String propname,
                                         java.lang.String def)
        Gets the value of a string property. The property value is searched, respectively, in the ruleset header in the IRL file, then in the resource bundle of the ruleset, then in the resource bundle of the reflect object, and finally as a system property.
        Parameters:
        propname - The name of the property.
        def - The default value to return if the property is not defined.
      • getIntProperty

        public final int getIntProperty(java.lang.String propname,
                         int def)
        Gets the value of an int property. The property value is searched, respectively, in the ruleset header in the IRL file, then in the resource bundle of the ruleset, then in the resource bundle of the reflect object, and finally as a system property.
        Parameters:
        propname - The name of the property.
        def - The default value to return if the property is not defined.
      • getDoubleProperty

        public final double getDoubleProperty(java.lang.String propname,
                               double def)
        Gets the value of a float property. The property value is searched, respectively, in the ruleset header in the IRL file, then in the resource bundle of the ruleset, then in the resource bundle of the reflect object, and finally as a system property.
        Parameters:
        propname - The name of the property.
        def - The default value to return if the property is not defined.
      • getProperty

        public final java.lang.Object getProperty(java.lang.String propname,
                                   java.lang.Object def)
        Gets the value of a property as an object. The property value is searched, respectively, in the ruleset header in the IRL file, then in the resource bundle of the ruleset, then in the resource bundle of the reflect object, and finally as a system property.
        Parameters:
        propname - The name of the property.
        def - The default value to return if the property is not defined.
      • getMessageWriter

        public final java.io.PrintWriter getMessageWriter()
        Returns the PrintWriter object to which error messages are printed. Initially, the error message writer is System.out.
        Returns:
        the error message writer of the ruleset.
      • setMessageWriter

        public final void setMessageWriter(java.io.PrintWriter writer)
        Sets the error message writer of the ruleset.
        Parameters:
        writer - the new writer to which error messages are printed.
      • getMessageNumber

        public final int getMessageNumber()
        Returns the number of errors detected during the last parsing operation.
        Returns:
        the number of errors from the last parsing operation.
      • getPacketRules

        public final IlrRule[] getPacketRules(java.lang.String packetName)
        Deprecated. 
        Returns all the rules in the ruleset that belong to the provided packetName.
        Parameters:
        packetName - the name of the packet.
        Returns:
        an array of IlrRule. The length of the array can be 0.
      • makeFactory

        public IlrRulesetFactory makeFactory()
        Builds a factory object that represents this ruleset. Do not call this method when the ruleset of this ruleset is executed inside:
        • a rule action
        • an IlrTool method
        Returns:
        The factory object that represents this ruleset.
      • parseStream

        public boolean parseStream(java.io.InputStream stream)
        Parses the stream provided as its argument. This is the most generic parsing method. The stream must comply with the structure and syntax of the RulesetDefinition grammar rule.

        This method can be used to load dynamically generated rulesets in IRL text format into the engine. The preferred method for loading rulesets generated by ILOG rule authoring tools is via ruleset archives; this method is provided for cases where rules are generated as IRL text by other (non-ILOG) tools.

        If errors are detected during parsing, then they are printed to the error message stream and the method returns false to indicate that the parsing failed. Otherwise, no message is printed and the method returns true.

        If the returned value is false, all the definitions of the input unit are ignored including those that are correct. The ruleset behaves as if the parsing operation had never happened.

        If the returned value is true, all the definitions are added to the ruleset. If there is an Initial Action, the new definition overrides the old one (if one exists). For the rule definitions, the new rules are added by means of the method mergeRules: existing rules that have the same name are overridden. New rules are simply added.

        When new definitions are added to a ruleset, all the contexts attached to this ruleset are notified accordingly. Upon notification, each context uses the new rule definitions and updates its data structure accordingly. Rule instances may be added to or removed from the agenda as a consequence of these updates.

        Note that this method creates a java.io.Reader using the current encoding provided by the resources of the IlrReflect object.

        Parameters:
        stream - The input unit.
        Returns:
        true if the parsing is successful, otherwise it returns false.
        See Also:
        IlrRulesetArchiveParser, parseReader(java.io.Reader), parseFactory(ilog.rules.factory.IlrRulesetFactory)
      • parseReader

        public boolean parseReader(java.io.Reader reader)
        Parses the supplied java.io.Reader. See the method parseStream for more details about the rule parsing process.

        This method can be used to load dynamically generated rulesets in IRL text format into the engine. The preferred method for loading rulesets generated by ILOG rule authoring tools is via ruleset archives; this method is provided for cases where rules are generated as IRL text by other (non-ILOG) tools.

        Parameters:
        reader - The reader of the input unit.
        Returns:
        true if the content of the reader is parsed successfully, otherwise it returns false.
        See Also:
        IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseFactory(ilog.rules.factory.IlrRulesetFactory)
      • parseFactory

        public boolean parseFactory(IlrRulesetFactory factory)
        Parses the ruleset factory.

        This method can be used to load dynamically generated rulesets in syntax tree format into the engine. The preferred method for loading rulesets generated by ILOG rule authoring tools is via ruleset archives; this method is provided for cases where rules are generated as tree objects by other (non-ILOG) tools.

        Parameters:
        factory - The ruleset factory to be parsed.
        Returns:
        true if parsing is successful, otherwise it returns false.
        See Also:
        IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseReader(java.io.Reader)
      • removeMetadata

        public void removeMetadata(boolean fromRules,
                          boolean fromRete)
        Removes metadata from rules and from the Rete network. If the first argument is true, metadata is removed from all the rules. If the second argument is true, the metadata is removed from the Rete. A Rete without metadata is not serializable.
        Parameters:
        fromRules - Is true if metadata is to be removed from the rules.
        fromRete - Is true if metadata is to be removed from the Rete.
      • removeMetadata

        public void removeMetadata()
        Removes metadata from rules and from the Rete network. This method call is equivalent to the call removeMetadata(true,true).
      • optimize

        public boolean optimize(IlrRulesetOptimConfig config)
        Optimizes the rules. After the optimization is finished, the ruleset is locked in such a way that an exception is raised when a modification method of the ruleset is called.

        The optimization triggers internal mechanisms so as to improve the performance of rule execution. In particular, some improvements are possible when the priorities applied to the rules are known at compile-time (static priorities).

        The ruleset must not be attached to any context before optimization starts. Otherwise, an IllegalArgumentException is raised.

        Parameters:
        config - The optimization configuration. This parameter may be null. In that case, an OptimConfig instance is created internally with default values for attribute values.
        Returns:
        true if the optimization is valid.
        See Also:
        isLocked()
      • setApplication

        public void setApplication(java.lang.String application)
        Deprecated. As of JRules 7.0, this method has no effect.
        This method has no effect.
        Parameters:
        application - The SAM application name of the application.

© Copyright IBM Corp. 1987, 2020