Rule Execution Server API

ilog.rules.factory
Class IlrReflect

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

public class IlrReflect
extends IlrDynamicObjectModel
implements ilog.rules.factory.IlrDataAccessStrategy, Serializable

This class is the concrete implementation of the Execution Object Model (XOM). When rules are parsed, the rule parser finds class definitions in an instance of this class. While class construction and query APIs are inherited from its superclass, this class provides additional methods for handling the dynamic data binding feature.

Since:
JRules 3.5
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
 IlrFactory factory
           A factory builder.
 
Fields inherited from class ilog.rules.bom.dynamic.IlrDynamicObjectModel
modelFactory, supportMissingReferences
 
Constructor Summary
IlrReflect()
           Constructs a reflect object.
IlrReflect(IlrResources resources)
           Constructs a reflect object.
 
Method Summary
 IlrDynamicPackage addPackagePath(String pathname)
           Adds a package using a fully-qualified package name.
 Object get(Object object, IlrAttribute attribute)
           
 boolean getBoolean(Object obj, IlrAttribute field)
           
 byte getByte(Object obj, IlrAttribute field)
           
 char getChar(Object obj, IlrAttribute field)
           
 double getDouble(Object obj, IlrAttribute field)
           
 ArrayList getDynamicClasses()
           Gets a list of dynamic classes defined in this reflect.
 float getFloat(Object obj, IlrAttribute field)
           
 int getInt(Object obj, IlrAttribute field)
           
 long getLong(Object obj, IlrAttribute field)
           
 IlrModelFactory getModelFactory()
          Returns the model factory of this object model.
 short getShort(Object obj, IlrAttribute field)
           
 IlrClass getXOMClass(Object object)
           Gets the XOM class of an object.
 Object invoke(Object object, IlrMethod meth, Object... arguments)
           
 ilog.rules.factory.IlrReflectClass ioFacilityClass()
           
 boolean isInstance(IlrClass clazz, Object object)
           
static void linkClassLoader(ObjectInputStream str, ClassLoader loader)
          Associates an input stream with a class loader.
 Object newArrayInstance(IlrType componentType, int length)
          Creates an array of type componentType and of length length.
 Object newArrayInstance(IlrType componentType, int[] dimensions)
          Creates a multi-dimensional array of type componentType.
 Object newInstance(IlrClass c)
           
 Object newInstance(IlrConstructor cons, Object... args)
           
 void registerDriver(IlrClassDriver driver)
           
 void set(Object object, IlrAttribute attribute, Object value)
           
 void setBoolean(Object obj, IlrAttribute field, boolean value)
           
 void setByte(Object obj, IlrAttribute field, byte value)
           
 void setChar(Object obj, IlrAttribute field, char value)
           
 void setDouble(Object obj, IlrAttribute field, double value)
           
 void setFloat(Object obj, IlrAttribute field, float value)
           
 void setInt(Object obj, IlrAttribute field, int value)
           
 void setLong(Object obj, IlrAttribute field, long value)
           
 void setShort(Object obj, IlrAttribute field, short value)
           
 void writeModel(Writer writer)
           Writes the dynamic classes defined in this reflect object to a writer, using the BOM syntax.
 
Methods inherited from class ilog.rules.bom.dynamic.IlrDynamicObjectModel
accept, addClass, addClass, addEnum, addJavaClass, addPackage, allClasses, allEnums, allPackages, getBooleanType, getByteType, getCharType, getClass, getClass, getClassLoader, getDefaultPackage, getDoubleType, getDynamicDefaultPackage, getFloatType, getGenericClass, getIntType, getKind, getLongType, getMutableDefaultPackage, getPackage, getPlatform, getPrimitiveType, getPrimitiveType, getPrimitiveTypes, getResources, getShortType, getStringClass, getType, getVoidType, isMappingComponentProperties, isNumeric, mapJavaClass, mapJavaClass, mapJavaClass, mapJavaType, mapJavaType, merge, merge, merge, remove, removeClass, setClassLoader, setMappingComponentProperties, setResources
 
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

factory

public transient IlrFactory factory

A factory builder. The role of this object is to build factory objects attached to a specific reflect object. When the reflect object is created, it automatically initializes this field.

Constructor Detail

IlrReflect

public IlrReflect()

Constructs a reflect object. Initially, the reflect object does not contain any classes. The resource bundle used to configure the engine is created using new IlrResources().


IlrReflect

public IlrReflect(IlrResources resources)

Constructs a reflect object. Initially, the reflect object does not contain any classes. The resource bundle used to configure the engine is passed as an argument.

Parameters:
resources - The engine configuration resource bundle.
Method Detail

getModelFactory

public IlrModelFactory getModelFactory()
Description copied from class: IlrDynamicObjectModel
Returns the model factory of this object model.

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

writeModel

public void writeModel(Writer writer)
                throws IOException

Writes the dynamic classes defined in this reflect object to a writer, using the BOM syntax.

Throws:
IOException - if any I/O exceptions have been caused by the passed writer itself.
Parameters:
writer - The writer to which the model is written.

linkClassLoader

public static void linkClassLoader(ObjectInputStream str,
                                   ClassLoader loader)
Associates an input stream with a class loader. If the passed loader happens to be the same as the loader of ObjectInputStream (very unlikely, because ObjectInputStream is a system class and should have no loader), then it is ignored.


ioFacilityClass

public ilog.rules.factory.IlrReflectClass ioFacilityClass()

getDynamicClasses

public ArrayList getDynamicClasses()

Gets a list of dynamic classes defined in this reflect. A dynamic class is one which has been defined explicitly, and which is not mapped to a Java class.

Returns:
a list of dynamic classes of this reflect.

addPackagePath

public IlrDynamicPackage addPackagePath(String pathname)

Adds a package using a fully-qualified package name. This method breaks the passed package name at the location of the . (dot) character. And for each name composing the package, checks whether the package of that name exists in the enclosing package before proceeding to the creation of the subpackage.

Parameters:
pathname - The path name.
Returns:
a dynamic package.

registerDriver

public void registerDriver(IlrClassDriver driver)

isInstance

public boolean isInstance(IlrClass clazz,
                          Object object)
Specified by:
isInstance in interface ilog.rules.factory.IlrDataAccessStrategy

getXOMClass

public IlrClass getXOMClass(Object object)

Gets the XOM class of an object. If the object is an instance of some class defined in this reflect object, this method will return the instantiation type.

Specified by:
getXOMClass in interface ilog.rules.factory.IlrDataAccessStrategy
Parameters:
object - An object.
Returns:
the object's XOM class.

get

public Object get(Object object,
                  IlrAttribute attribute)
           throws IllegalArgumentException,
                  IllegalAccessException
Specified by:
get in interface ilog.rules.factory.IlrDataAccessStrategy
Throws:
IllegalArgumentException
IllegalAccessException

getBoolean

public boolean getBoolean(Object obj,
                          IlrAttribute field)
                   throws IllegalArgumentException,
                          IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

getChar

public char getChar(Object obj,
                    IlrAttribute field)
             throws IllegalArgumentException,
                    IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

getByte

public byte getByte(Object obj,
                    IlrAttribute field)
             throws IllegalArgumentException,
                    IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

getShort

public short getShort(Object obj,
                      IlrAttribute field)
               throws IllegalArgumentException,
                      IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

getInt

public int getInt(Object obj,
                  IlrAttribute field)
           throws IllegalArgumentException,
                  IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

getLong

public long getLong(Object obj,
                    IlrAttribute field)
             throws IllegalArgumentException,
                    IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

getFloat

public float getFloat(Object obj,
                      IlrAttribute field)
               throws IllegalArgumentException,
                      IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

getDouble

public double getDouble(Object obj,
                        IlrAttribute field)
                 throws IllegalArgumentException,
                        IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

set

public void set(Object object,
                IlrAttribute attribute,
                Object value)
         throws IllegalArgumentException,
                IllegalAccessException
Specified by:
set in interface ilog.rules.factory.IlrDataAccessStrategy
Throws:
IllegalArgumentException
IllegalAccessException

setBoolean

public void setBoolean(Object obj,
                       IlrAttribute field,
                       boolean value)
                throws IllegalArgumentException,
                       IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

setChar

public void setChar(Object obj,
                    IlrAttribute field,
                    char value)
             throws IllegalArgumentException,
                    IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

setByte

public void setByte(Object obj,
                    IlrAttribute field,
                    byte value)
             throws IllegalArgumentException,
                    IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

setShort

public void setShort(Object obj,
                     IlrAttribute field,
                     short value)
              throws IllegalArgumentException,
                     IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

setInt

public void setInt(Object obj,
                   IlrAttribute field,
                   int value)
            throws IllegalArgumentException,
                   IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

setLong

public void setLong(Object obj,
                    IlrAttribute field,
                    long value)
             throws IllegalArgumentException,
                    IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

setFloat

public void setFloat(Object obj,
                     IlrAttribute field,
                     float value)
              throws IllegalArgumentException,
                     IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

setDouble

public void setDouble(Object obj,
                      IlrAttribute field,
                      double value)
               throws IllegalArgumentException,
                      IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

invoke

public Object invoke(Object object,
                     IlrMethod meth,
                     Object... arguments)
              throws IllegalArgumentException,
                     IllegalAccessException,
                     InvocationTargetException
Specified by:
invoke in interface ilog.rules.factory.IlrDataAccessStrategy
Throws:
IllegalArgumentException
IllegalAccessException
InvocationTargetException

newInstance

public Object newInstance(IlrClass c)
                   throws InstantiationException,
                          IllegalAccessException
Specified by:
newInstance in interface ilog.rules.factory.IlrDataAccessStrategy
Throws:
InstantiationException
IllegalAccessException

newInstance

public Object newInstance(IlrConstructor cons,
                          Object... args)
                   throws InstantiationException,
                          IllegalAccessException,
                          InvocationTargetException
Specified by:
newInstance in interface ilog.rules.factory.IlrDataAccessStrategy
Throws:
InstantiationException
IllegalAccessException
InvocationTargetException

newArrayInstance

public Object newArrayInstance(IlrType componentType,
                               int length)
                        throws NegativeArraySizeException
Creates an array of type componentType and of length length.

Specified by:
newArrayInstance in interface ilog.rules.factory.IlrDataAccessStrategy
Since:
JRules 6.5
Throws:
NegativeArraySizeException - If the passed length is negative.
Parameters:
componentType - The component type.
length - The array length.
Returns:
An array object.

newArrayInstance

public Object newArrayInstance(IlrType componentType,
                               int[] dimensions)
                        throws IllegalArgumentException,
                               NegativeArraySizeException
Creates a multi-dimensional array of type componentType.

Specified by:
newArrayInstance in interface ilog.rules.factory.IlrDataAccessStrategy
Since:
JRules 6.5
Throws:
NegativeArraySizeException - If the passed length is negative.
IllegalArgumentException
Parameters:
componentType - The component type.
dimensions - The dimensions of the array.
Returns:
An array object.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013