Rule Execution Server API

ilog.rules.bom.dynamic
Class IlrDynamicObjectModel

java.lang.Object
  extended by ilog.rules.bom.dynamic.IlrDynamicObjectModel
All Implemented Interfaces:
IlrObjectModel, IlrProperties, IlrTransientProperties, IlrMutableObjectModel, IlrVisitable, Serializable
Direct Known Subclasses:
IlrReflect

public class IlrDynamicObjectModel
extends Object
implements Serializable, IlrMutableObjectModel

An implementation of the IlrObjectModel and IlrMutableObjectModel interfaces.

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

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface ilog.rules.bom.IlrObjectModel
IlrObjectModel.Kind, IlrObjectModel.Platform, IlrObjectModel.Selector, IlrObjectModel.SelectorWrapper, IlrObjectModel.Visitor
 
Field Summary
protected  IlrModelFactory modelFactory
           
protected  boolean supportMissingReferences
           
 
Constructor Summary
IlrDynamicObjectModel()
          Deprecated. As of JRules 6.0, please use IlrDynamicObjectModel(ilog.rules.bom.IlrObjectModel.Kind)
IlrDynamicObjectModel(IlrObjectModel.Kind kind)
          Constructs an empty dynamic object model.
 
Method Summary
 void accept(IlrVisitor visitor)
          Defines a default visit path: here visit the default package.
protected  int addClass(IlrDynamicClass clazz)
           
 IlrDynamicClass addClass(String name)
          Adds an IlrDynamicClass to the default package of this object model.
 IlrDynamicEnum addEnum(String name)
          Adds an IlrDynamicEnum to the default package of this object model.
 IlrType addJavaClass(Class javaClass)
          Adds the description of the Java class named javaClass to the object model.
 IlrDynamicPackage addPackage(String name)
          Adds an IlrDynamicPackage to the default package of this object model.
 Iterator allClasses()
          Returns an iterator which iterates through all of the classes contained in this object model.
 Iterator allEnums()
          Returns an iterator which iterates through all of the enumerations contained in this object model.
 Iterator allPackages()
          Returns an iterator which iterates over all 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 having 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.
 IlrPackage getDefaultPackage()
          Returns the default package of the object model.
 IlrType getDoubleType()
          Returns the double primitive type.
 IlrDynamicPackage getDynamicDefaultPackage()
          Returns the default package of the object model.
 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.
 IlrModelFactory getModelFactory()
          Returns the model factory of this object model.
 IlrMutablePackage getMutableDefaultPackage()
          Returns the default package of the object model.
 IlrPackage getPackage(String fullyQualifiedName)
          Returns the package having the fully qualified name fullyQualifiedName.
 IlrObjectModel.Platform getPlatform()
          Returns the platform referenced by this object model
protected  IlrPrimitiveType getPrimitiveType(int tag)
           
 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 getVoidType()
          Returns the void primitive type.
 boolean isMappingComponentProperties()
          Returns true if the mapping of component properties is enabled.
static boolean isNumeric(int tag)
           
 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(className).
 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 the objectModel defined by the selector and the 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 setMappingComponentProperties(boolean flag)
          Enables or disables mapping of component properties.
 void setResources(IlrResources resources)
          Sets the resource bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ilog.rules.bom.IlrObjectModel
getClassReference, getClassReference, getClassReference, getTypeReference, getTypeReference, isDynamicallyLoadingClasses, setJavaClassLookupEnabled, visit
 
Methods inherited from interface ilog.rules.bom.IlrProperties
isPropertyPersistent, setPersistentProperty, setPersistentProperty
 
Methods inherited from interface ilog.rules.bom.IlrTransientProperties
getPropertyValue, getPropertyValue, propertyNames, removeProperty, setPropertyValue
 

Field Detail

supportMissingReferences

protected boolean supportMissingReferences

modelFactory

protected transient IlrModelFactory modelFactory
Constructor Detail

IlrDynamicObjectModel

public IlrDynamicObjectModel(IlrObjectModel.Kind kind)
Constructs an empty dynamic object model.

Since:
JRules 6.0
Parameters:
kind - The kind of object model. It cannot be null

IlrDynamicObjectModel

public IlrDynamicObjectModel()
Deprecated. As of JRules 6.0, please use IlrDynamicObjectModel(ilog.rules.bom.IlrObjectModel.Kind)

Constructs an empty non native dynamic object model. It does the same as IlrDynamicObjectModel(IlrObjectModel.Kind.NONNATIVE).

Method Detail

getClassLoader

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

Specified by:
getClassLoader in interface IlrObjectModel

setClassLoader

public 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.

Specified by:
setClassLoader in interface IlrObjectModel

getKind

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

Specified by:
getKind in interface IlrObjectModel
Since:
JRules 6.0
Returns:
The kind of object model.

getPlatform

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

Specified by:
getPlatform in interface IlrObjectModel
Since:
JRules 7.0

getModelFactory

public IlrModelFactory getModelFactory()
Returns the model factory of this object model.

Specified by:
getModelFactory in interface IlrMutableObjectModel
Returns:
The model factory to use to build new model elements.

setMappingComponentProperties

public 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.

Specified by:
setMappingComponentProperties in interface IlrObjectModel
Since:
JRules 6.0

isMappingComponentProperties

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

Specified by:
isMappingComponentProperties in interface IlrObjectModel
Since:
JRules 6.0
See Also:
setMappingComponentProperties(boolean)

merge

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

Specified by:
merge in interface IlrObjectModel
Throws:
RuntimeException - if the target object model is not mutable
Parameters:
objectModel - the source object model.
Returns:
true if successful.

merge

public 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 upon which it depends.

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

Specified by:
merge in interface IlrObjectModel
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

public boolean merge(IlrObjectModel objectModel,
                     IlrSelector selector,
                     Iterator initialTypes)
Merges the subset of the objectModel defined by the selector and the 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 other model elements upon which it depends.

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

Specified by:
merge in interface IlrObjectModel
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 through the classes that must be fully merged.
Returns:
true if successful.

addPackage

public IlrDynamicPackage addPackage(String name)
Adds an IlrDynamicPackage to the default package of this object model.

Note: No check is made that the given name has not already been used in the package.

Parameters:
name - The name of the package.
Returns:
The added package.

addClass

public IlrDynamicClass addClass(String name)
Adds an IlrDynamicClass to the default package of this object model.

Note: No check is made that the given name has not already been used in the package.

Parameters:
name - The name of the class.
Returns:
The class.

addEnum

public IlrDynamicEnum addEnum(String name)
Adds an IlrDynamicEnum to the default package of this object model.

Note: No check is made that the given name has not already been used in the package.

Parameters:
name - The name of the class.
Returns:
The enum.

addJavaClass

public 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 and its public attributes, constructors and methods. It also adds all 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 with 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.

Specified by:
addJavaClass in interface IlrObjectModel
Parameters:
javaClass - The source Java class.
Returns:
The added type. It is either an IlrClass or an IlrPrimitiveType.

mapJavaType

public 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.

Specified by:
mapJavaType in interface IlrObjectModel
Parameters:
javaClass - The source Java class.
Returns:
The added type. It is either an IlrClass or an IlrPrimitiveType.

mapJavaClass

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

Specified by:
mapJavaClass in interface IlrObjectModel
Parameters:
javaClass - The source Java class.
Returns:
The added type. It is either an IlrClass or an IlrPrimitiveType.

mapJavaClass

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

Specified by:
mapJavaClass in interface IlrObjectModel
Since:
JRules 6.0
Parameters:
rawClassName - An instance of a generic class.
typeParameters - The type parameters.

getGenericClass

public IlrClass getGenericClass(String rawClassName,
                                int numberOfTypeParameters)
Specified by:
getGenericClass in interface IlrObjectModel

mapJavaType

public IlrType mapJavaType(String className)
Adds the description of the Java class named className to the object model.

Note: 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 ilog.rules.bom.dynamic.IlrDynamicObjectModel.isDynamicallyLoadingClasses(). If the Java class lookup is not enabled, then this method returns null.

Specified by:
mapJavaType in interface IlrObjectModel
Since:
JRules 6.0 Support of generic class name
Parameters:
className - The source Java class name.
Returns:
The mapped class.

mapJavaClass

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

Specified by:
mapJavaClass in interface IlrObjectModel
Parameters:
className - The source Java class name.
Returns:
The mapped class.

remove

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

Specified by:
remove in interface IlrObjectModel
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

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

Specified by:
removeClass in interface IlrObjectModel
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

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

Specified by:
getDefaultPackage in interface IlrObjectModel

getDynamicDefaultPackage

public IlrDynamicPackage getDynamicDefaultPackage()
Returns the default package of the object model. This method is similar to IlrObjectModel.getDefaultPackage, although the return value has an IlrDynamicPackage type.


getMutableDefaultPackage

public IlrMutablePackage getMutableDefaultPackage()
Returns the default package of the object model. This method is similar to IlrObjectModel.getDefaultPackage although the return value has an IlrMutablePackage type.


getPackage

public IlrPackage getPackage(String fullyQualifiedName)
Returns the package having the fully qualified name fullyQualifiedName.

Specified by:
getPackage in interface IlrObjectModel
Parameters:
fullyQualifiedName - A fully qualified name.
Returns:
A package or null.

getType

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

Specified by:
getType in interface IlrObjectModel
Parameters:
fullyQualifiedName - A fully qualified name.
Returns:
A type or null.

getClass

public IlrClass getClass(String fullyQualifiedName)
Returns the class having the fully qualified name fullyQualifiedName.

Specified by:
getClass in interface IlrObjectModel
Parameters:
fullyQualifiedName - A fully qualified name.
Returns:
A class or null.

getClass

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

Specified by:
getClass in interface IlrObjectModel
Since:
JRules 6.0
Parameters:
rawClassName - An instance of a generic class.
typeParameters - The type parameters.
Returns:
A class, or null.

accept

public void accept(IlrVisitor visitor)
Defines a default visit path: here visit the default package.

Specified by:
accept in interface IlrVisitable
Parameters:
visitor - The visitor.

getStringClass

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

Specified by:
getStringClass in interface IlrObjectModel

getPrimitiveTypes

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

Specified by:
getPrimitiveTypes in interface IlrObjectModel
Returns:
A primitive type list.

getPrimitiveType

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

Specified by:
getPrimitiveType in interface IlrObjectModel
Returns:
A primitive type or null.

getPrimitiveType

protected IlrPrimitiveType getPrimitiveType(int tag)

getVoidType

public IlrType getVoidType()
Returns the void primitive type.

Specified by:
getVoidType in interface IlrObjectModel
Returns:
A primitive type.

getBooleanType

public IlrType getBooleanType()
Returns the boolean primitive type.

Specified by:
getBooleanType in interface IlrObjectModel
Returns:
A primitive type.

getByteType

public IlrType getByteType()
Returns the byte primitive type.

Specified by:
getByteType in interface IlrObjectModel
Returns:
A primitive type.

getCharType

public IlrType getCharType()
Returns the char primitive type.

Specified by:
getCharType in interface IlrObjectModel
Returns:
A primitive type.

getFloatType

public IlrType getFloatType()
Returns the float primitive type.

Specified by:
getFloatType in interface IlrObjectModel
Returns:
A primitive type.

getDoubleType

public IlrType getDoubleType()
Returns the double primitive type.

Specified by:
getDoubleType in interface IlrObjectModel
Returns:
A primitive type.

getShortType

public IlrType getShortType()
Returns the short primitive type.

Specified by:
getShortType in interface IlrObjectModel
Returns:
A primitive type.

getIntType

public IlrType getIntType()
Returns the int primitive type.

Specified by:
getIntType in interface IlrObjectModel
Returns:
A primitive type.

getLongType

public IlrType getLongType()
Returns the long primitive type.

Specified by:
getLongType in interface IlrObjectModel
Returns:
A primitive type.

allPackages

public Iterator allPackages()
Returns an iterator which iterates over all packages contained in this object model.

Specified by:
allPackages in interface IlrObjectModel
Returns:
A package iterator.

allEnums

public Iterator allEnums()
Returns an iterator which iterates through all of the enumerations contained in this object model.

Specified by:
allEnums in interface IlrObjectModel
Returns:
An enumeration iterator.

allClasses

public Iterator allClasses()
Returns an iterator which iterates through all of the classes contained in this object model.

Specified by:
allClasses in interface IlrObjectModel
Returns:
A class iterator.

getResources

public final IlrResources getResources()
Returns the resource bundle.

Specified by:
getResources in interface IlrObjectModel
Returns:
The resource bundle. It is never null.

setResources

public final void setResources(IlrResources resources)
Sets the resource bundle.

Parameters:
resources - A resource bundle. It cannot be null

addClass

protected int addClass(IlrDynamicClass clazz)

isNumeric

public static boolean isNumeric(int tag)

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013