Rule Execution Server API

ilog.rules.engine
Class IlrPackage

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

public class IlrPackage
extends Object
implements 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
IlrPackage(ilog.rules.factory.IlrReflectClass contextClass, IlrRuleset ruleset, String name)
           
 
Method Summary
 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(String name, Class[] argumentTypes)
          Returns the function in the ruleset whose name is name and whose argument types are those passed as parameters.
 IlrFunction getFunction(String name, IlrType[] argumentTypes)
          Returns the function in the ruleset whose name is name and whose argument types are those passed as parameters.
 String getName()
          Returns the name of the package.
 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 package.
 int getRuleNumber()
          Returns the number of rules in this package.
 IlrRuleset getRuleset()
          Returns the ruleset that contains this package.
 IlrTask getTask(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlrPackage

public IlrPackage(ilog.rules.factory.IlrReflectClass contextClass,
                  IlrRuleset ruleset,
                  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 returns false.

getName

public String getName()
Returns the name of the package.

Returns:
The package's name.

getRuleset

public IlrRuleset getRuleset()
Returns the ruleset that contains this 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(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 package. The remove method of this iterator will throw an UnsupportedOperationException.

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 returns false.

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(String name,
                                     IlrType[] argumentTypes)
Returns the function in the ruleset whose name is name 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(String name,
                                     Class[] argumentTypes)
Returns the function in the ruleset whose name is name and whose argument types are those passed as parameters.

Parameters:
name - The name of the function.
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 package and whose name is the one passed as the parameter. It 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 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 of IlrRulesetParameter, each of them containing the type as an IlrClass 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 - An IlrRulesetFactory.
Returns:
The factory object of this package.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013