Rule Execution Server API

ilog.rules.factory
Class IlrFunctionFactory

java.lang.Object
  extended by ilog.rules.factory.IlrFunctionFactory
All Implemented Interfaces:
IlrFunctionElement, ilog.rules.factory.IlrRulesetElement, Serializable

public class IlrFunctionFactory
extends Object
implements Serializable, IlrFunctionElement

Function definition of the rule language.

Warning: Serialized objects of this class will not be compatible with future releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of IBM Decision Server.

See Also:
Serialized Form

Constructor Summary
IlrFunctionFactory(IlrReflect reflect, IlrPackageFactory pkg, String definitionName)
          Constructs a function factory using a function name.
IlrFunctionFactory(IlrReflect reflect, IlrPackageFactory pkg, String definitionName, Class returnType)
          Constructs a function factory using a function name and its return type.
IlrFunctionFactory(String definitionName, IlrPackageFactory pkg, IlrType returnType)
          Constructs a function factory using a function name and its return type.
 
Method Summary
 void addArgument(IlrVariable argument)
          Adds a formal argument to the function.
 void addStatement(IlrStatement statement)
          Adds an action to the function.
 Enumeration enumerateArguments()
          Gets an enumeration to visit all the arguments of the function.
 Enumeration enumerateStatements()
          Gets an enumeration to visit all the actions of the function.
static String formatIdentifier(String name, Class[] argtypes)
          Formats a function identifier from its name and its argument.
static String formatIdentifier(String name, IlrType[] argtypes)
          Formats a function identifier from its name and its arguments.
static String formatSignature(String name, Class[] argtypes, Class returnType)
          Formats a function signature using its name, its argument types, and the return type.
static String formatSignature(String name, IlrType[] argtypes, IlrType returnType)
          Formats a function signature using its name, its argument types, and the return type.
static String formatSignature(String name, String[] argtypes, String returnType)
          Formats a function signature using its name, its argument types, and the return type.
 int getArgumentCount()
          Gets the number of arguments in the function.
 IlrVariable[] getArguments()
          Gets the arguments of the function.
 String getFormalComment()
          Gets the formal comment of the function.
 String getIdentifier()
          Gets the identifier of the function.
 String getName()
          Gets the fully qualified name of the function.
 IlrPackageFactory getPackage()
          Returns the package in which the function is defined.
 String getShortName()
          Gets the short name of the function.
 String getSignature()
          Gets the signature of the function.
 int getStatementCount()
          Gets the number of actions.
 IlrStatement[] getStatements()
          Gets the actions of the function.
 IlrType getXOMReturnType()
          Gets the return type of the function.
 boolean hasArgument(String name)
          Checks to see if the argument is already defined.
 boolean isVoidFunction()
          Tests if the function returns void.
 boolean match(Class[] callTypes)
          Tests if the function accepts the types of arguments.
 boolean match(IlrValue[] arguments)
          Tests if the function accepts the values as arguments.
 void removeArgument(IlrVariable argument)
          Removes a formal argument from the rule.
 void removeStatement(IlrStatement statement)
          Removes a statement from the rule.
 void setArguments(IlrVariable[] arguments)
          Sets the arguments of the function.
 void setFormalComment(String formalComment)
          Sets the formal comment of the function.
 void setName(String name)
          Sets the fully qualified name of the function to the given parameter.
 void setStatements(IlrStatement[] statements)
          Sets the statements of the function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlrFunctionFactory

public IlrFunctionFactory(IlrReflect reflect,
                          IlrPackageFactory pkg,
                          String definitionName)
Constructs a function factory using a function name. The function package is the one specified. If null, the function is considered to belong to the default package. The argument list initially is empty. The function returns void.

Parameters:
reflect - A reflect.
pkg - The package to which the function belongs.
definitionName - The name of the function.

IlrFunctionFactory

public IlrFunctionFactory(IlrReflect reflect,
                          IlrPackageFactory pkg,
                          String definitionName,
                          Class returnType)
Constructs a function factory using a function name and its return type. The function package is the one specified. If null, the function is considered to belong to the default package. The argument list initially is empty.

Parameters:
reflect - A reflect.
pkg - The package to which the function belongs.
definitionName - The name of the function.
returnType - The return type of the function.

IlrFunctionFactory

public IlrFunctionFactory(String definitionName,
                          IlrPackageFactory pkg,
                          IlrType returnType)
Constructs a function factory using a function name and its return type. The function package is the one specified. If null, the function is considered to belong to the default package. The argument list initially is empty.

Parameters:
definitionName - The name of the function.
pkg - The package to which the function belongs.
returnType - The return type of the function.
Method Detail

getName

public String getName()
Gets the fully qualified name of the function.

Returns:
The fully qualified name of the function.

getShortName

public String getShortName()
Gets the short name of the function.

Returns:
The short name of the function.

setName

public void setName(String name)
Sets the fully qualified name of the function to the given parameter. The method computes the function short name by taking the identifier after the last '.' character.

Parameters:
name - The name of the function.

getFormalComment

public String getFormalComment()
Gets the formal comment of the function.

Returns:
The formal comment of the function.

setFormalComment

public void setFormalComment(String formalComment)
Sets the formal comment of the function.

Parameters:
formalComment - The formal comment of the function.

getXOMReturnType

public IlrType getXOMReturnType()
Gets the return type of the function.

Returns:
The type of the function.

getIdentifier

public String getIdentifier()
Gets the identifier of the function. It is computed by appending the function short name with the argument type, as follows: function-name(arg-type1, ..., arg-typen)

Returns:
The function identifier.

getSignature

public String getSignature()
Gets the signature of the function. The signature is formed by the return type name followed by the function signature.

Returns:
The function signature.

isVoidFunction

public boolean isVoidFunction()
Tests if the function returns void.

Returns:
true if the function return type is a void type.

match

public boolean match(IlrValue[] arguments)
Tests if the function accepts the values as arguments.

Parameters:
arguments - The arguments passed to the function.
Returns:
true if the function accepts the arguments.

match

public boolean match(Class[] callTypes)
Tests if the function accepts the types of arguments.

Parameters:
callTypes - The argument types passed to the function.
Returns:
true if the function accepts the argument types.

hasArgument

public final boolean hasArgument(String name)
Checks to see if the argument is already defined.

Parameters:
name - The argument to be checked.

addArgument

public final void addArgument(IlrVariable argument)
Adds a formal argument to the function. The argument passed as the argument becomes the last argument of the function.

Parameters:
argument - The argument to be added.

removeArgument

public final void removeArgument(IlrVariable argument)
Removes a formal argument from the rule.

Parameters:
argument - The argument to be removed.

getArgumentCount

public final int getArgumentCount()
Gets the number of arguments in the function.

Returns:
The number of arguments in the function.

getArguments

public final IlrVariable[] getArguments()
Gets the arguments of the function.

Returns:
An array of IlrVariable representing the arguments.

setArguments

public final void setArguments(IlrVariable[] arguments)
Sets the arguments of the function.

Parameters:
arguments - The arguments to be set.

enumerateArguments

public final Enumeration enumerateArguments()
Gets an enumeration to visit all the arguments of the function.

Returns:
An enumeration.

addStatement

public final void addStatement(IlrStatement statement)
Adds an action to the function. The action becomes the last action of the function.

Parameters:
statement - The action to be added.

removeStatement

public final void removeStatement(IlrStatement statement)
Removes a statement from the rule.

Parameters:
statement - The statement to be removed.

getStatementCount

public final int getStatementCount()
Gets the number of actions.

Returns:
The number of actions.

getStatements

public final IlrStatement[] getStatements()
Gets the actions of the function.

Returns:
The actions of the function.

setStatements

public final void setStatements(IlrStatement[] statements)
Sets the statements of the function.

Parameters:
statements - The statements to be set.

enumerateStatements

public final Enumeration enumerateStatements()
Gets an enumeration to visit all the actions of the function.

Returns:
An enumeration of the function actions.

formatIdentifier

public static String formatIdentifier(String name,
                                      IlrType[] argtypes)
Formats a function identifier from its name and its arguments.

Parameters:
name - The function name.
argtypes - The argument types.
Returns:
The identifier.

formatIdentifier

public static String formatIdentifier(String name,
                                      Class[] argtypes)
Formats a function identifier from its name and its argument.

Parameters:
name - The function name.
argtypes - The argument types.
Returns:
The identifier.

formatSignature

public static String formatSignature(String name,
                                     String[] argtypes,
                                     String returnType)
Formats a function signature using its name, its argument types, and the return type.

Parameters:
name - The function name.
argtypes - The argument types.
returnType - The return type.
Returns:
The identifier.

formatSignature

public static String formatSignature(String name,
                                     IlrType[] argtypes,
                                     IlrType returnType)
Formats a function signature using its name, its argument types, and the return type.

Parameters:
name - The function name.
argtypes - The argument types.
returnType - The return type.
Returns:
The identifier.

formatSignature

public static String formatSignature(String name,
                                     Class[] argtypes,
                                     Class returnType)
Formats a function signature using its name, its argument types, and the return type.

Parameters:
name - The function name.
argtypes - The argument types.
returnType - The return type.
Returns:
The identifier.

getPackage

public IlrPackageFactory getPackage()
Returns the package in which the function is defined.

Returns:
The package that contains the function.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013