Rule Execution Server API

ilog.rules.engine
Class IlrRuleset

java.lang.Object
  extended by ilog.rules.engine.IlrRuleset
All Implemented Interfaces:
Serializable

public class IlrRuleset
extends Object
implements Serializable

IlrRuleset represents an entity that manages a set of rules.

Overview

Rules in the ruleset come from a ruleset archive. This archive is parsed using an IlrRulesetArchiveParser instance. The ruleset then exhibits the rule objects it contains.

This class together with IlrContext constitute the main classes of the ilog.rules.engine package. In IBM Decision Server, the rule engine is an instance of IlrContext, the rule engine is simply a Java object.

An IlrContext is an execution context that initially contains all the rules of the ruleset. A context is created using a ruleset, to which it is said to be attached. The ruleset owns a list of contexts.

Instances of IlrContext can be created from a ruleset.

An IlrContext can be derived to include additional fields and methods. These methods and fields can be used in the rules. To create a ruleset, the class of the execution context must be supplied. The class of the execution context defines the set of methods and fields to which the rules have access.

Deprecations and restrictions

Since ILOG JRules 5.0, the derivation of IlrContext has been deprecated. You should use ruleset variables to add new fields to the execution context.

Since ILOG JRules 6.5, the parsing of the IRL text format is restricted to expert users. Most of the IRL text parsing methods have been deprecated. Only the most generic ones have not been deprecated in order to support the use case where the rules are generated dynamically as IRL text or factory tree objects.

Warning: IlrRuleset uses Java serialization. An object can only be deserialized with the same version of Java used to serialize it. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Java.

See Also:
IlrContext, IlrBadContextException, Serialized Form

Constructor Summary
IlrRuleset()
          Constructs an IlrRuleset using the type IlrContext.
IlrRuleset(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
 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.
 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(String propname, boolean def)
          Gets the value of a boolean property.
 Class getContextClass()
          Returns the context class of this ruleset.
 IlrPackage getDefaultPackage()
          Returns the default package of the ruleset.
 double getDoubleProperty(String propname, double def)
          Gets the value of a float property.
 IlrFunction getFunction(String name, Class[] argumentTypes)
          Returns the function in the ruleset whose name is name and whose arguments types are those passed as parameter.
 IlrFunction getFunction(String name, IlrType[] argumentTypes)
          Returns the function in the ruleset whose name is name and whose arguments types are those passed as parameter.
 Map getHierarchicalProperties()
          Returns the hierarchical properties attached to the ruleset.
 IlrHierarchicalProperty getHierarchicalProperty(String name)
          Returns the hierarchical property attached to the ruleset whose name is equals to the given parameter.
 int getIntProperty(String propname, int def)
          Gets the value of an int property.
 int getMessageNumber()
          Returns the number of errors detected during the last parsing operation.
 PrintWriter getMessageWriter()
          Returns the PrintWriter object to which error messages are printed.
 String getName()
          Gets the name of the ruleset.
 IlrPackage getPackage(String name)
          Returns the specified package from the ruleset.
 IlrPackage[] getPackages()
          Gets the packages of this ruleset.
 IlrRule[] getPacketRules(String packetName)
          Deprecated.  
 IlrPropertyList getProperties()
          Gets the property list of this ruleset.
 Object getProperty(String propname, 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(String ruleName)
          Returns the rule whose name is given as the parameter.
 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  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.  
 String getStringProperty(String propname, String def)
          Gets the value of a string property.
 IlrTask getTask(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(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(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(Reader reader)
          Parses the supplied java.io.Reader.
 boolean parseStream(InputStream stream)
          Parses the stream provided as its argument.
 boolean parseString(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(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(String application)
          Deprecated. As of JRules 7.0, this method has no effect.
 void setMessageWriter(PrintWriter writer)
          Sets the error message writer of the ruleset.
 void setName(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(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 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(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 Class getContextClass()
Returns the context class of this ruleset.

Returns:
the context class of this ruleset.

getAllContexts

public final 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 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(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(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(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 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 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(String name,
                                     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(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(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(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 String getStringProperty(String propname,
                                      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(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(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 Object getProperty(String propname,
                                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 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(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(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:

Returns:
The factory object that represents this ruleset.

parseStream

public boolean parseStream(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)

parseURL

public boolean parseURL(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)

Parses the supplied java.net.URL. The URL must be valid and accessible. This method opens a stream from the URL and then calls the method parseStream.

Parameters:
url - The URL of the input unit.
Returns:
true if the URL is accessible and parsing is successful, otherwise it returns false.
See Also:
IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseReader(java.io.Reader), parseFactory(ilog.rules.factory.IlrRulesetFactory), parseFileName(java.lang.String), parseFile(java.io.File), parseString(java.lang.String)

parseReader

public boolean parseReader(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)

parseFileName

public boolean parseFileName(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)

Parses the supplied file name. The file must be valid and accessible. See the method parseStream for more details. This method creates a java.io.Reader using the current encoding provided by the resources of the IlrReflect object.

Parameters:
fileName - The file name of the input unit.
Returns:
true if the file is accessible and parsing is successful, otherwise it returns false.
See Also:
IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseReader(java.io.Reader), parseFactory(ilog.rules.factory.IlrRulesetFactory), parseURL(java.net.URL), parseFile(java.io.File), parseString(java.lang.String)

parseFile

public boolean parseFile(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)

Parses the supplied file. The file must be valid and accessible. See the method parseStream for more details. This method creates a java.io.Reader using the current encoding provided by the resources of the IlrReflect object.

Parameters:
file - The file of the input unit.
Returns:
true if the file is accessible and parsing is successful, otherwise it returns false.
See Also:
IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseReader(java.io.Reader), parseFactory(ilog.rules.factory.IlrRulesetFactory), parseURL(java.net.URL), parseFileName(java.lang.String), parseString(java.lang.String)

parseString

public boolean parseString(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)

Parses the supplied source. See the method parseStream for more details.

Parameters:
source - The string to be parsed.
Returns:
true if parsing is successful, otherwise it returns false.
See Also:
IlrRulesetArchiveParser, parseStream(java.io.InputStream), parseReader(java.io.Reader), parseFactory(ilog.rules.factory.IlrRulesetFactory), parseURL(java.net.URL), parseFile(java.io.File), parseFileName(java.lang.String)

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()

isLocked

public boolean isLocked()
Returns true if the ruleset is locked.

Returns:
true if locked.
See Also:
optimize(IlrRulesetOptimConfig)

setApplication

public void setApplication(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.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013