ilog.rules.engine
Class IlrPackage
- java.lang.Object
-
- ilog.rules.engine.IlrPackage
-
- All Implemented Interfaces:
- java.io.Serializable
public class IlrPackage extends java.lang.Object implements java.io.Serializable
This class models the packages in the IRL language. The ruleset contains packages. Each package may contain rules, functions, tasks and variables. Each ruleset contains at least one package, the default package, whose name is the empty string.- Since:
- JRules6.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description IlrPackage(ilog.rules.factory.IlrReflectClass contextClass, IlrRuleset ruleset, java.lang.String name)
-
Method Summary
Methods Modifier and Type Method and Description boolean
containsRule(IlrRule rule)
Tests whether the package contains a rule.IlrFunction[]
getAllFunctions()
Returns all the functions in the package.IlrRule[]
getAllRules()
Returns all the rules in the package.IlrTask[]
getAllTasks()
Returns all the tasks in the package.IlrFunction
getFunction(java.lang.String name, java.lang.Class[] argumentTypes)
Returns the function in the ruleset whose name isname
and whose argument types are those passed as parameters.IlrFunction
getFunction(java.lang.String name, IlrType[] argumentTypes)
Returns the function in the ruleset whose name isname
and whose argument types are those passed as parameters.java.lang.String
getName()
Returns the name of the package.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 package.int
getRuleNumber()
Returns the number of rules in this package.IlrRuleset
getRuleset()
Returns the ruleset that containsthis
package.IlrTask
getTask(java.lang.String name)
Returns the task defined in the package and whose name is the one passed as the parameter.IlrRulesetParameter[]
getVariables()
Returns the variables defined in this package.boolean
isDefaultPackage()
Returns a boolean telling whether the package is the default package or not.IlrPackageFactory
makeFactory()
Builds a factory object to represent this package.IlrPackageFactory
makeFactory(IlrRulesetFactory rulesetF)
Builds a factory object to represent this package.
-
-
-
Constructor Detail
-
IlrPackage
public IlrPackage(ilog.rules.factory.IlrReflectClass contextClass, IlrRuleset ruleset, java.lang.String name)
-
-
Method Detail
-
isDefaultPackage
public boolean isDefaultPackage()
Returns a boolean telling whether the package is the default package or not. The default package is the package whose name is the empty string.- Returns:
true
if the package is the default package, else returnsfalse
.
-
getName
public java.lang.String getName()
Returns the name of the package.- Returns:
- The package's name.
-
getRuleset
public IlrRuleset getRuleset()
Returns the ruleset that containsthis
package.- Returns:
- The ruleset in which the package is defined.
-
getRuleNumber
public final int getRuleNumber()
Returns the number of rules in this package.- Returns:
- The number of rules in this package.
-
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 package. Theremove
method of this iterator will throw anUnsupportedOperationException
.- Since:
- JRules 6.0
- Returns:
- An iterator on
IlrRule
instances.
-
containsRule
public final boolean containsRule(IlrRule rule)
Tests whether the package contains a rule.- Parameters:
rule
- A rule.- Returns:
true
if the package contains the rule. Otherwise, it returnsfalse
.
-
getAllRules
public final IlrRule[] getAllRules()
Returns all the rules in the package.- Returns:
- An array of
IlrRule
. The length of the array can be 0.
-
getAllFunctions
public final IlrFunction[] getAllFunctions()
Returns all the functions in the package.- Returns:
- An array of
IlrFunction[]
. The length of the array can be 0.
-
getFunction
public final IlrFunction getFunction(java.lang.String name, IlrType[] argumentTypes)
Returns the function in the ruleset whose name isname
and whose argument types are those passed as parameters.- Parameters:
name
- The name of the function.argumentTypes
- The array of argument types 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, java.lang.Class[] argumentTypes)
Returns the function in the ruleset whose name isname
and whose argument types are those passed as parameters.- Parameters:
name
- The name of the function.argumentTypes
- The array of argument types, asClass
, 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 package and whose name is the one passed as the parameter. It returnsnull
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 package.- Returns:
- An array of
IlrTask[]
. The length of the array can be 0.
-
getVariables
public IlrRulesetParameter[] getVariables()
Returns the variables defined in this package. The result is an array ofIlrRulesetParameter
, each of them containing the type as anIlrClass
and the name of the variable.- Returns:
- An array containing the ruleset variables with the specified modifier.
- See Also:
IlrRulesetParameter
-
makeFactory
public final IlrPackageFactory makeFactory()
Builds a factory object to represent this package.- Returns:
- The factory object of this package.
-
makeFactory
public final IlrPackageFactory makeFactory(IlrRulesetFactory rulesetF)
Builds a factory object to represent this package.- Parameters:
rulesetF
- AnIlrRulesetFactory
.- Returns:
- The factory object of this package.
-
-