com.ibm.rules.engine.runtime.EngineDefinition and its subinterfaces.public class IlrRuleset
extends java.lang.Object
implements java.io.Serializable
IlrRuleset represents an entity that manages a set of rules.
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.
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.IlrContext,
IlrBadContextException,
Serialized Form| Constructor and Description |
|---|
IlrRuleset()
Deprecated.
Constructs an
IlrRuleset using the type IlrContext. |
IlrRuleset(IlrReflect reflect)
Deprecated.
Constructs an
IlrRuleset using an IlrReflect. |
IlrRuleset(IlrRuleset ruleset)
Deprecated.
Constructs an
IlrRuleset from another IlrRuleset. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsRule(IlrRule rule)
Deprecated.
Tests whether the ruleset contains a rule, that means tests whether one package of the ruleset contains the rule.
|
java.util.Vector |
getAllContexts()
Deprecated.
Returns the contexts created (and therefore attached) using this ruleset.
|
IlrFunction[] |
getAllFunctions()
Deprecated.
Returns all the functions in the ruleset, that means all functions in all ruleset packages.
|
IlrRule[] |
getAllRules()
Deprecated.
Returns all the rules in the ruleset, that means all the rules in all ruleset packages.
|
IlrTask[] |
getAllTasks()
Deprecated.
Returns all the tasks in the ruleset, that means all the tasks of all ruleset packages.
|
boolean |
getBooleanProperty(java.lang.String propname,
boolean def)
Deprecated.
Gets the value of a boolean property.
|
java.lang.Class |
getContextClass()
Deprecated.
Returns the context class of this ruleset.
|
IlrPackage |
getDefaultPackage()
Deprecated.
Returns the default package of the ruleset.
|
double |
getDoubleProperty(java.lang.String propname,
double def)
Deprecated.
Gets the value of a float property.
|
IlrFunction |
getFunction(java.lang.String name,
java.lang.Class[] argumentTypes)
Deprecated.
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)
Deprecated.
Returns the function in the ruleset whose name is
name and whose arguments types are those passed as
parameter. |
java.util.Map |
getHierarchicalProperties()
Deprecated.
Returns the hierarchical properties attached to the ruleset.
|
IlrHierarchicalProperty |
getHierarchicalProperty(java.lang.String name)
Deprecated.
Returns the hierarchical property attached to the ruleset whose name is equals to the given parameter.
|
int |
getIntProperty(java.lang.String propname,
int def)
Deprecated.
Gets the value of an int property.
|
int |
getMessageNumber()
Deprecated.
Returns the number of errors detected during the last parsing operation.
|
java.io.PrintWriter |
getMessageWriter()
Deprecated.
Returns the
PrintWriter object to which error messages are printed. |
java.lang.String |
getName()
Deprecated.
Gets the name of the ruleset.
|
IlrPackage |
getPackage(java.lang.String name)
Deprecated.
Returns the specified package from the ruleset.
|
IlrPackage[] |
getPackages()
Deprecated.
Gets the packages of this ruleset.
|
IlrPropertyList |
getProperties()
Deprecated.
Gets the property list of this ruleset.
|
java.lang.Object |
getProperty(java.lang.String propname,
java.lang.Object def)
Deprecated.
Gets the value of a property as an object.
|
IlrReflect |
getReflect()
Deprecated.
Gets the reflect object of this ruleset.
|
IlrResources |
getResources()
Deprecated.
Gets the resource bundle of this ruleset.
|
IlrRule |
getRule(java.lang.String ruleName)
Deprecated.
Returns the rule whose name is given as the parameter.
|
java.util.Iterator |
getRuleIterator()
Deprecated.
Returns an iterator on the rules contained in the ruleset, that means on the rules contained in all ruleset
packages.
|
int |
getRuleNumber()
Deprecated.
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()
Deprecated.
|
IlrRulesetParameter[] |
getRulesetSignature()
Deprecated.
Returns the signature of the ruleset.
|
IlrRulesetParameter[] |
getRulesetVariables(int modifier)
Deprecated.
Returns the ruleset variables for a specific modifier.
|
java.lang.String |
getStringProperty(java.lang.String propname,
java.lang.String def)
Deprecated.
Gets the value of a string property.
|
IlrTask |
getTask(java.lang.String name)
Deprecated.
Returns the task defined in the ruleflow and whose name is the one passed as the parameter.
|
boolean |
isLocked()
Deprecated.
Returns
true if the ruleset is locked. |
IlrRulesetFactory |
makeFactory()
Deprecated.
Builds a factory object that represents this ruleset.
|
boolean |
optimize(IlrRulesetOptimConfig config)
Deprecated.
Optimizes the rules.
|
boolean |
parseFactory(IlrRulesetFactory factory)
Deprecated.
Parses the ruleset factory.
|
boolean |
parseReader(java.io.Reader reader)
Deprecated.
Parses the supplied
java.io.Reader. |
boolean |
parseStream(java.io.InputStream stream)
Deprecated.
Parses the stream provided as its argument.
|
void |
removeMetadata()
Deprecated.
Removes metadata from rules and from the Rete network.
|
void |
removeMetadata(boolean fromRules,
boolean fromRete)
Deprecated.
Removes metadata from rules and from the Rete network.
|
void |
removeRule(IlrRule rule)
Deprecated.
Removes a rule from the ruleset.
|
void |
removeRules(IlrRule[] rules)
Deprecated.
Removes rules from the packages that contain them.
|
void |
setAllowPackageDeclaration(boolean ng)
Deprecated.
Specifies whether the ruleset code may contain a package declaration.
|
void |
setMessageWriter(java.io.PrintWriter writer)
Deprecated.
Sets the error message writer of the ruleset.
|
void |
setName(java.lang.String name)
Deprecated.
Sets the name of the ruleset.
|
void |
setResources(IlrResources resources)
Deprecated.
Sets the resource bundle.
|
public IlrRuleset()
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.public IlrRuleset(IlrReflect reflect)
IlrRuleset using an IlrReflect. The context class of this ruleset is
IlrContext.class.reflect - The reflect object of this ruleset.public IlrRuleset(IlrRuleset ruleset)
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.ruleset - The ruleset constructor.public void setAllowPackageDeclaration(boolean ng)
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.public final IlrReflect getReflect()
public final java.lang.String getName()
public final void setName(java.lang.String name)
name - The name of the ruleset. The argument can be null.public final IlrPropertyList getProperties()
public final java.lang.Class getContextClass()
public final java.util.Vector getAllContexts()
IlrContext. Each context is attached to this ruleset. The length of the list can be
0.public java.util.Map getHierarchicalProperties()
null. In the returned hash table, the key is the hierarchical property name, the value is the
hierarchical property ilog.rules.factory.IlrHierarchicalPropertyitself.public IlrHierarchicalProperty getHierarchicalProperty(java.lang.String name)
name - The name of the hierarchical property we are looking for.null in case the
ruleset has no hierarchical property or in case no property is named as requested.public final IlrPackage getPackage(java.lang.String name)
name - The name of the package we are looking for.null in
case there is no such package.public final IlrPackage getDefaultPackage()
public final IlrPackage[] getPackages()
public final int getRuleNumber()
public final IlrRule getRule(java.lang.String ruleName)
ruleName - The name of the rule.IlrRule whose name is provided as the parameter, if this rule exists. Otherwise,
null is returned.public final java.util.Iterator getRuleIterator()
remove method of this iterator will throw an UnsupportedOperationException.IlrRule instances.protected java.util.List getRules()
public final boolean containsRule(IlrRule rule)
rule - A rule.true if the ruleset contains the rule. Otherwise, it returns false.public final IlrRule[] getAllRules()
IlrRule. The length of the array can be 0.public void removeRule(IlrRule rule)
rule - The rule to be removed.public void removeRules(IlrRule[] rules)
rules - The array of rules.removeRule(ilog.rules.engine.IlrRule)public final IlrFunction[] getAllFunctions()
IlrFunction[]. The length of the array can be 0.public final IlrFunction getFunction(java.lang.String name, java.lang.Class[] argumentTypes)
name and whose arguments types are those passed as
parameter.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.public final IlrFunction getFunction(java.lang.String name, IlrType[] argumentTypes)
name and whose arguments types are those passed as
parameter.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.public IlrTask getTask(java.lang.String name)
null if no such task exists.name - The name of a task to return.name.public final IlrTask[] getAllTasks()
IlrTask[]. The length of the array can be 0.public IlrRulesetParameter[] getRulesetSignature()
IlrRulesetParameter, each of them
containing the type, as an IlrClass and the name of the variable.IlrRulesetParameterpublic IlrRulesetParameter[] getRulesetVariables(int modifier)
modifier - A mask built from values defined in
ilog.rules.factory.IlrRulesetConstants. The modifier
for local variables is 0.IlrRulesetParameter objects. Each object
contains:
IlrClass instance representing the type of the object.IlrRulesetParameter,
IlrRulesetConstants.In,
IlrRulesetConstants.Outpublic final IlrResources getResources()
public final void setResources(IlrResources resources)
resources - A resource bundle. It cannot be null.public final boolean getBooleanProperty(java.lang.String propname,
boolean def)
propname - The name of the property.def - The default value to return if the property is not defined.public final java.lang.String getStringProperty(java.lang.String propname,
java.lang.String def)
propname - The name of the property.def - The default value to return if the property is not defined.public final int getIntProperty(java.lang.String propname,
int def)
propname - The name of the property.def - The default value to return if the property is not defined.public final double getDoubleProperty(java.lang.String propname,
double def)
propname - The name of the property.def - The default value to return if the property is not defined.public final java.lang.Object getProperty(java.lang.String propname,
java.lang.Object def)
propname - The name of the property.def - The default value to return if the property is not defined.public final java.io.PrintWriter getMessageWriter()
PrintWriter object to which error messages are printed. Initially, the error message writer
is System.out.public final void setMessageWriter(java.io.PrintWriter writer)
writer - the new writer to which error messages are printed.public final int getMessageNumber()
public IlrRulesetFactory makeFactory()
IlrTool methodpublic boolean parseStream(java.io.InputStream stream)
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.stream - The input unit.true if the parsing is successful, otherwise it returns false.IlrRulesetArchiveParser,
parseReader(java.io.Reader),
parseFactory(ilog.rules.factory.IlrRulesetFactory)public boolean parseReader(java.io.Reader reader)
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.reader - The reader of the input unit.true if the content of the reader is parsed successfully, otherwise it returns
false.IlrRulesetArchiveParser,
parseStream(java.io.InputStream),
parseFactory(ilog.rules.factory.IlrRulesetFactory)public boolean parseFactory(IlrRulesetFactory factory)
factory - The ruleset factory to be parsed.true if parsing is successful, otherwise it returns false.IlrRulesetArchiveParser,
parseStream(java.io.InputStream),
parseReader(java.io.Reader)public void removeMetadata(boolean fromRules,
boolean fromRete)
fromRules - Is true if metadata is to be removed from the rules.fromRete - Is true if metadata is to be removed from the Rete.public void removeMetadata()
removeMetadata(true,true).public boolean optimize(IlrRulesetOptimConfig config)
IllegalArgumentException is raised.config - The optimization configuration. This parameter may be null. In that case, an
OptimConfig instance is created internally with default values for attribute values.true if the optimization is valid.isLocked()public boolean isLocked()
true if the ruleset is locked.true if locked.optimize(IlrRulesetOptimConfig)© Copyright IBM Corp. 1987, 2017