Rule Execution Server API

ilog.rules.bom
Interface IlrObjectModel

All Superinterfaces:
IlrProperties, IlrTransientProperties, IlrVisitable
All Known Subinterfaces:
IlrMutableObjectModel
All Known Implementing Classes:
IlrDynamicObjectModel, IlrReflect

public interface IlrObjectModel
extends IlrProperties, IlrVisitable

This interface represents an object model.

An object model is composed of a default package which is itself composed of other packages, of classes and of enumerations.

Note that the API changed slightly in JRules 5.0.

See Also:
IlrPackage, IlrType, IlrClass, IlrEnum, IlrPrimitiveType

Nested Class Summary
static class IlrObjectModel.Kind
          A kind of object model.
static class IlrObjectModel.Platform
           
static interface IlrObjectModel.Selector
          Deprecated. Use IlrSelector instead.
static class IlrObjectModel.SelectorWrapper
          Compatibility wrapper for selectors.
static interface IlrObjectModel.Visitor
          Deprecated. Use IlrVisitor instead
 
Method Summary
 IlrType addJavaClass(Class javaClass)
          Adds the description of the Java class named javaClass to the object model.
 Iterator allClasses()
          Returns an iterator that iterates over all classes contained in this object model.
 Iterator allEnums()
          Returns an iterator that iterates over all of the enumerations contained in this object model.
 Iterator allPackages()
          Returns an iterator that iterates over all of the packages contained in this object model.
 IlrType getBooleanType()
          Returns the boolean primitive type.
 IlrType getByteType()
          Returns the byte primitive type.
 IlrType getCharType()
          Returns the char primitive type.
 IlrClass getClass(String fullyQualifiedName)
          Returns the class which has the fully qualified name fullyQualifiedName.
 IlrClass getClass(String rawClassName, IlrType[] typeParameters)
          An instance of a generic class called rawClassName bound to the given type parameters.
 ClassLoader getClassLoader()
          Returns the class loader set by a call to setClassLoader.
 IlrClass getClassReference(Class javaClass)
          Returns the class corresponding to the Java class.
 IlrClass getClassReference(String fqn)
          Returns the class corresponding to the fqn.
 IlrClass getClassReference(String fqn, IlrType[] typeParameters)
          Returns the class corresponding to the fqn AND the type parameters.
 IlrPackage getDefaultPackage()
          Returns the default package of the object model.
 IlrType getDoubleType()
          Returns the double primitive type.
 IlrType getFloatType()
          Returns the float primitive type.
 IlrClass getGenericClass(String rawClassName, int numberOfTypeParameters)
           
 IlrType getIntType()
          Returns the int primitive type.
 IlrObjectModel.Kind getKind()
          Returns the kind of object model.
 IlrType getLongType()
          Returns the long primitive type.
 IlrPackage getPackage(String fullyQualifiedName)
          Returns the package which has the fully qualified name fullyQualifiedName.
 IlrObjectModel.Platform getPlatform()
          Returns the platform referenced by this object model
 IlrPrimitiveType getPrimitiveType(String name)
          Returns the primitive type named name.
 List getPrimitiveTypes()
          Returns a list of all the primitive types in this object model.
 IlrResources getResources()
          Returns the resource bundle.
 IlrType getShortType()
          Returns the short primitive type.
 IlrClass getStringClass()
          Returns the java.lang.String class.
 IlrType getType(String fullyQualifiedName)
          Returns the type having the fully qualified name fullyQualifiedName.
 IlrType getTypeReference(Class javaClass)
          Returns the type corresponding to the Java class.
 IlrType getTypeReference(String fqn)
          Returns the type corresponding to the fqn.
 IlrType getVoidType()
          Returns the void primitive type.
 boolean isDynamicallyLoadingClasses()
          Returns true if the Java class lookup is enabled.
 boolean isMappingComponentProperties()
          Returns true if the mapping of component properties is enabled.
 IlrClass mapJavaClass(Class javaClass)
          Calls mapJavaType(Class) and, if the returned type is an IlrClass, it is returned, otherwise null is returned.
 IlrClass mapJavaClass(String className)
          Calls mapJavaType(String) and, if the returned type is an IlrClass, it is returned, otherwise null is returned.
 IlrClass mapJavaClass(String rawClassName, IlrType... typeParameters)
          Creates an instance of a generic class called rawClassName bound to the given type parameters.
 IlrType mapJavaType(Class javaClass)
          Adds the description of the Java class javaClass to the object model.
 IlrType mapJavaType(String className)
          Adds the description of the Java class named className to the object model.
 boolean merge(IlrObjectModel objectModel)
          Merges objectModel into this object model.
 boolean merge(IlrObjectModel objectModel, IlrSelector selector)
          Merges the subset of objectModel defined by selector into this object model.
 boolean merge(IlrObjectModel objectModel, IlrSelector selector, Iterator initialTypes)
          Merges the subset of objectModel defined by selector and initialTypes into this object model.
 boolean remove(IlrSelector selector)
          Removes the subset of this object model defined by the selector argument.
 boolean removeClass(IlrClass aClass)
          Removes the class aClass from this object model.
 void setClassLoader(ClassLoader classLoader)
          Sets the class loader used by the mapJavaType(String) and mapJavaClass(String) methods.
 void setJavaClassLookupEnabled(boolean flag)
          Deprecated. As of JRules 6.0, use IlrObjectModel.Kind passed at creation time instead.
 void setMappingComponentProperties(boolean flag)
          Enables or disables mapping of component properties.
 boolean visit(IlrObjectModel.Visitor visitor)
          Deprecated. Use IlrVisitor instead.
 
Methods inherited from interface ilog.rules.bom.IlrProperties
isPropertyPersistent, setPersistentProperty, setPersistentProperty
 
Methods inherited from interface ilog.rules.bom.IlrTransientProperties
getPropertyValue, getPropertyValue, propertyNames, removeProperty, setPropertyValue
 
Methods inherited from interface ilog.rules.util.IlrVisitable
accept
 

Method Detail

getClassLoader

ClassLoader getClassLoader()
Returns the class loader set by a call to setClassLoader.


setClassLoader

void setClassLoader(ClassLoader classLoader)
Sets the class loader used by the mapJavaType(String) and mapJavaClass(String) methods. If the class loader is null, then the Class.forName method is used to load the classes. If the class loader has to be set, do it just after creating the object model, before any classes are added to it.

Initially the class loader property is null.


getKind

IlrObjectModel.Kind getKind()
Returns the kind of object model.

Since:
JRules 6.0

getPlatform

IlrObjectModel.Platform getPlatform()
Returns the platform referenced by this object model

Since:
JRules 7.0

isDynamicallyLoadingClasses

boolean isDynamicallyLoadingClasses()
Returns true if the Java class lookup is enabled. When disabled the mapJavaType(String) method behaves the same as the getType(String) method. This also applies to the mapJavaClass(String) that behaves as the getClass(String) method.


setJavaClassLookupEnabled

void setJavaClassLookupEnabled(boolean flag)
Deprecated. As of JRules 6.0, use IlrObjectModel.Kind passed at creation time instead.

Enables or disables the Java class lookup.

If this property must be set, do it just after creating the object model, before any classes are added to it.

If the type of object model is IlrObjectModel.Kind.NONNATIVE, this property is initially false, otherwise it is true.

Throws:
UnsupportedOperationException - if the class lookup cannot be enabled/disabled.

setMappingComponentProperties

void setMappingComponentProperties(boolean flag)
Enables or disables mapping of component properties.

This property modifies the way Java classes are mapped to IlrClasses.

By default this property is true. Component properties are mapped as described here:

If the mappingComponentProperties property is false, then there is no special treatement of get and set methods. They are simply mapped as methods and no component property, indexed component property or attributes are created.

Since:
JRules 6.0

isMappingComponentProperties

boolean isMappingComponentProperties()
Returns true if the mapping of component properties is enabled.

Since:
JRules 6.0
See Also:
setMappingComponentProperties(boolean)

merge

boolean merge(IlrObjectModel objectModel)
Merges objectModel into this object model.

Throws:
RuntimeException - if the target object model is not mutable
Parameters:
objectModel - The source object model.
Returns:
true if successful.

merge

boolean merge(IlrObjectModel objectModel,
              IlrSelector selector)
Merges the subset of objectModel defined by selector into this object model.

For a model element to be merged it must be accepted by the selector along with all other model elements on which it depends.

If the given selector rejects a class (for example, C) but accepts an attribute of another class of type C, then the attribute will not be merged since its type has been rejected. The same goes for methods with respect to their parameter types, return type and exception types and also for classes with respect to their superclasses and superinterfaces.

Throws:
RuntimeException - if the target object model is not mutable
Parameters:
objectModel - A source object model.
selector - An object model subset selector. If null the object model is completely merged.
Returns:
true if successful.

merge

boolean merge(IlrObjectModel objectModel,
              IlrSelector selector,
              Iterator initialTypes)
Merges the subset of objectModel defined by selector and initialTypes into this object model.

This method merges the classes and enums given by the initialTypes iterator along with their members (attributes, methods and tags). Other types, not present in initialTypes but indirectly required (such as the types of attributes, and so forth) are also written, but their members are omitted.

Note: For a model element to be merged, it must also be accepted by the given selector along with all of the other model elements on which it depends.

It is recommended to use IlrSelectors.dynamicTypes(model) as the value of the initialTypes parameter so that classes bound to actual Java classes are not serialized.

Throws:
RuntimeException - if the target object model is not mutable
Parameters:
objectModel - A source object model.
selector - An object model subset selector.
initialTypes - An iterator which iterates over the classes that must be fully merged.
Returns:
true if successful.

addJavaClass

IlrType addJavaClass(Class javaClass)
Adds the description of the Java class named javaClass to the object model. The Java reflection API is used.

This method adds an IlrClass reflecting the given Java class along with its public attributes, constructors and methods. It also adds all of the other required classes (such as the types of public attributes, and so forth), but without their attributes and methods. None of the added classes are bound to their original Java classes (for example: the IlrType.getJavaClass method returns null).

If an IlrClass that has the same fully qualified name as the given Java class existed prior to the call to this method, then this IlrClass is updated to reflect the given Java class.

Parameters:
javaClass - The source Java class.
Returns:
The added type. It is either an IlrClass or an IlrPrimitiveType.

mapJavaType

IlrType mapJavaType(Class javaClass)
Adds the description of the Java class javaClass to the object model.

Note: If a type with the same name already exists, it is simply returned. Otherwise, if the name is already used by a package, null is returned. Otherwise, a new IlrType mapping the given javaClass is added to the object model and it is returned.

Note: Only the public members of the Java class are reflected through the mapped IlrClass object.

What happens when a Java class is mapped to an IlrType depends on the kind of object model.

Parameters:
javaClass - The source Java class.
Returns:
The added type. It is either an IlrClass or an IlrPrimitiveType.

mapJavaClass

IlrClass mapJavaClass(Class javaClass)
Calls mapJavaType(Class) and, if the returned type is an IlrClass, it is returned, otherwise null is returned.

Parameters:
javaClass - The source Java class.
Returns:
The added type. It is either an IlrClass or an IlrPrimitiveType.

mapJavaClass

IlrClass mapJavaClass(String rawClassName,
                      IlrType... typeParameters)
Creates an instance of a generic class called rawClassName bound to the given type parameters.

Since:
JRules 6.0
Parameters:
rawClassName -
typeParameters -

mapJavaType

IlrType mapJavaType(String className)
Adds the description of the Java class named className to the object model. Note that although the class loader defined in this object model is used to retrieve the Java class, the className parameter should be specified using the Java language convention instead of the java.lang.ClassLoader.loadClass convention (for example: int[] as "int[]" and not "[I").

Beware that if a type with the given qualified name exists in the object model prior to the call to this method, then that type is returned although it may be defined differently than the Java class with the same name.

The class name may be the name of an instance of a generic class. For example, this method may be called with "java.util.Collection<java.lang.String>" as parameter. If the current Java platform supports generics, an instance of IlrClass will be returned. In its generic information (IlrClass.getGenericInfo()), the type parameters (IlrGenericInfo.getTypeParameters()) will contain the IlrClass java.lang.String.

Note: This method is sensitive to the value returned by isDynamicallyLoadingClasses(). If the Java class lookup is not enabled, then this method returns null.

Since:
JRules 6.0 Support of generic class name
Parameters:
className - The source Java class name.
Returns:
The mapped class.

mapJavaClass

IlrClass mapJavaClass(String className)
Calls mapJavaType(String) and, if the returned type is an IlrClass, it is returned, otherwise null is returned.

Parameters:
className - The source Java class name.
Returns:
The mapped class.

remove

boolean remove(IlrSelector selector)
Removes the subset of this object model defined by the selector argument.

Since:
JRules 6.0, for the return of a result.
Parameters:
selector - The object model subset selector.
Returns:
true If at least one model element was removed.

removeClass

boolean removeClass(IlrClass aClass)
Removes the class aClass from this object model.

Since:
JRules 6.0 for the return of a result.
Parameters:
aClass - The class to be removed.
Returns:
true if the class was removed

getDefaultPackage

IlrPackage getDefaultPackage()
Returns the default package of the object model. This is the package that contains all of the top-level named packages (such as java, ilog, and so forth). The default package may also contain classes and enumerations.


getStringClass

IlrClass getStringClass()
Returns the java.lang.String class.


getPackage

IlrPackage getPackage(String fullyQualifiedName)
Returns the package which has the fully qualified name fullyQualifiedName.

Parameters:
fullyQualifiedName - A fully qualified name.
Returns:
A package or null.

getType

IlrType getType(String fullyQualifiedName)
Returns the type having the fully qualified name fullyQualifiedName.

Parameters:
fullyQualifiedName - A fully qualified name.
Returns:
A type or null.

getClass

IlrClass getClass(String fullyQualifiedName)
Returns the class which has the fully qualified name fullyQualifiedName.

Parameters:
fullyQualifiedName - A fully qualified name.
Returns:
A class or null.

getClass

IlrClass getClass(String rawClassName,
                  IlrType[] typeParameters)
An instance of a generic class called rawClassName bound to the given type parameters.

Since:
JRules 6.0
Parameters:
rawClassName - The instance of the rawClassName generic class.
typeParameters - The given type parameters.
Returns:
A class, or null.

getGenericClass

IlrClass getGenericClass(String rawClassName,
                         int numberOfTypeParameters)

getClassReference

IlrClass getClassReference(Class javaClass)
Returns the class corresponding to the Java class. For an execution model, it does the same as mapJavaClass(Class). For a business model, it returns a regular class if the Java class has already been mapped, otherwise it returns a missing reference (see IlrType.isMissingReference().

Since:
JRules 6.0

getTypeReference

IlrType getTypeReference(Class javaClass)
Returns the type corresponding to the Java class. For an execution model, it does the same as mapJavaType(Class). For a business model, it returns a regular type if the Java class has already been mapped, otherwise it returns a missing reference (see IlrType.isMissingReference().

Since:
JRules 6.0

getClassReference

IlrClass getClassReference(String fqn)
Returns the class corresponding to the fqn. It returns a regular class if the fqn is already the fqn of a class, null if it is the fqn of type (not a class), otherwise it returns a missing reference (see IlrType.isMissingReference().

Since:
JRules 6.0

getClassReference

IlrClass getClassReference(String fqn,
                           IlrType[] typeParameters)
Returns the class corresponding to the fqn AND the type parameters. It returns a regular class if the fqn is already the fqn of a class, null if it is the fqn of type (not a class), otherwise it returns a missing reference (see IlrType.isMissingReference().

Since:
JRules 6.0

getTypeReference

IlrType getTypeReference(String fqn)
Returns the type corresponding to the fqn. It returns a regular type if the fqn is already the fqn of a class, otherwise it returns an IlrType.isMissingReference().

Since:
JRules 6.0

visit

boolean visit(IlrObjectModel.Visitor visitor)
Deprecated. Use IlrVisitor instead.

Visits the model elements of this object model. This method calls the visitPackge method of the visitor applied to the default package of the object model.

Parameters:
visitor - A visitor.
Returns:
true if the visitor's visitPackage method returns true.

allPackages

Iterator allPackages()
Returns an iterator that iterates over all of the packages contained in this object model.

Returns:
A package iterator.

allEnums

Iterator allEnums()
Returns an iterator that iterates over all of the enumerations contained in this object model.

Returns:
An enumeration iterator.

allClasses

Iterator allClasses()
Returns an iterator that iterates over all classes contained in this object model.

Returns:
A class iterator.

getPrimitiveTypes

List getPrimitiveTypes()
Returns a list of all the primitive types in this object model.

Returns:
A primitive type list.

getPrimitiveType

IlrPrimitiveType getPrimitiveType(String name)
Returns the primitive type named name.

Returns:
A primitive type or null.

getVoidType

IlrType getVoidType()
Returns the void primitive type.

Returns:
A primitive type.

getBooleanType

IlrType getBooleanType()
Returns the boolean primitive type.

Returns:
A primitive type.

getByteType

IlrType getByteType()
Returns the byte primitive type.

Returns:
A primitive type.

getCharType

IlrType getCharType()
Returns the char primitive type.

Returns:
A primitive type.

getFloatType

IlrType getFloatType()
Returns the float primitive type.

Returns:
A primitive type.

getDoubleType

IlrType getDoubleType()
Returns the double primitive type.

Returns:
A primitive type.

getShortType

IlrType getShortType()
Returns the short primitive type.

Returns:
A primitive type.

getIntType

IlrType getIntType()
Returns the int primitive type.

Returns:
A primitive type.

getLongType

IlrType getLongType()
Returns the long primitive type.

Returns:
A primitive type.

getResources

IlrResources getResources()
Returns the resource bundle.

Returns:
The resource bundle. It is never null.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013