public class IlrDynamicObjectModel extends java.lang.Object implements java.io.Serializable, IlrMutableObjectModel
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.
IlrObjectModel.Kind, IlrObjectModel.Platform, IlrObjectModel.Selector, IlrObjectModel.SelectorWrapper, IlrObjectModel.Visitor| Modifier and Type | Field and Description |
|---|---|
protected IlrModelFactory |
modelFactory |
protected boolean |
supportMissingReferences |
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(IlrVisitor visitor)
Defines a default visit path: here visit the default package.
|
protected int |
addClass(IlrDynamicClass clazz) |
IlrDynamicClass |
addClass(java.lang.String name)
Adds an
IlrDynamicClass to the
default package of this object model. |
IlrDynamicEnum |
addEnum(java.lang.String name)
Adds an
IlrDynamicEnum to the
default package of this object model. |
IlrType |
addJavaClass(java.lang.Class javaClass)
Adds the description of the Java class named
javaClass to
the object model. |
IlrDynamicPackage |
addPackage(java.lang.String name)
Adds an
IlrDynamicPackage to the default package of
this object model. |
java.util.Iterator |
allClasses()
Returns an iterator which iterates through all of the classes contained
in this object model.
|
java.util.Iterator |
allEnums()
Returns an iterator which iterates through all of the enumerations contained
in this object model.
|
java.util.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(java.lang.String fullyQualifiedName)
Returns the class having the fully qualified name
fullyQualifiedName. |
IlrClass |
getClass(java.lang.String rawClassName,
IlrType[] typeParameters)
An instance of a generic class called
rawClassName
bound to the given type parameters. |
java.lang.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(java.lang.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(java.lang.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(java.lang.String name)
Returns the primitive type named
name. |
java.util.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(java.lang.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(java.lang.Class javaClass)
Calls
mapJavaType(Class) and, if the returned type is an
IlrClass, it is returned, otherwise null
is returned. |
IlrClass |
mapJavaClass(java.lang.String className)
Calls
mapJavaType(className). |
IlrClass |
mapJavaClass(java.lang.String rawClassName,
IlrType... typeParameters)
Creates an instance of a generic class called
rawClassName
bound to the given type parameters. |
IlrType |
mapJavaType(java.lang.Class javaClass)
Adds the description of the Java class
javaClass to
the object model. |
IlrType |
mapJavaType(java.lang.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,
java.util.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(java.lang.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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetClassReference, getClassReference, getClassReference, getTypeReference, getTypeReference, isDynamicallyLoadingClasses, setJavaClassLookupEnabled, visitisPropertyPersistent, setPersistentProperty, setPersistentPropertygetPropertyValue, getPropertyValue, propertyNames, removeProperty, setPropertyValueprotected boolean supportMissingReferences
protected transient IlrModelFactory modelFactory
public IlrDynamicObjectModel(IlrObjectModel.Kind kind)
kind - The kind of object model. It cannot be nullpublic IlrDynamicObjectModel()
IlrDynamicObjectModel(ilog.rules.bom.IlrObjectModel.Kind)IlrDynamicObjectModel(IlrObjectModel.Kind.NONNATIVE).public java.lang.ClassLoader getClassLoader()
setClassLoader.getClassLoader in interface IlrObjectModelpublic void setClassLoader(java.lang.ClassLoader classLoader)
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.
setClassLoader in interface IlrObjectModelpublic IlrObjectModel.Kind getKind()
getKind in interface IlrObjectModelpublic IlrObjectModel.Platform getPlatform()
getPlatform in interface IlrObjectModelpublic IlrModelFactory getModelFactory()
getModelFactory in interface IlrMutableObjectModelpublic void setMappingComponentProperties(boolean flag)
This property modifies the way Java classes are mapped to IlrClasses.
By default this property is true. Component properties are mapped as described here:
IlrObjectModel.Kind.NATIVE object model, the
get and set methods are mapped to corresponding
IlrMethods and to IlrComponentProperty
or IlrIndexedComponentProperty, in accordance with the JavaBeans conventions.
IlrObjectModel.Kind.BUSINESS object model, the
get and set methods are linked to corresponding IlrAttributes
in accordance with the JavaBeans conventions.
setXXX method without a corresponding getXXX method will be mapped to a
read only attribute (see IlrAttribute.isReadonly()).
getXXX method without a corresponding setXXX method will be mapped to
a write only attribute (see IlrAttribute.isWriteonly()).
getXXX and setXXX methods will be mapped to one attribute.
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.setMappingComponentProperties in interface IlrObjectModelpublic boolean isMappingComponentProperties()
true if the mapping of component properties is enabled.isMappingComponentProperties in interface IlrObjectModelsetMappingComponentProperties(boolean)public boolean merge(IlrObjectModel objectModel)
objectModel into this object model.merge in interface IlrObjectModeljava.lang.RuntimeException - if the target object model is not mutableobjectModel - the source object model.true if successful.public boolean merge(IlrObjectModel objectModel, IlrSelector selector)
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.
merge in interface IlrObjectModeljava.lang.RuntimeException - if the target object model is not mutableobjectModel - A source object model.selector - An object model subset selector. If null
the object model is completely merged.true if successful.public boolean merge(IlrObjectModel objectModel, IlrSelector selector, java.util.Iterator initialTypes)
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.
merge in interface IlrObjectModeljava.lang.RuntimeException - if the target object model is not mutableobjectModel - A source object model.selector - An object model subset selector.initialTypes - An iterator which iterates through the classes that
must be fully merged.true if successful.public IlrDynamicPackage addPackage(java.lang.String name)
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.
name - The name of the package.public IlrDynamicClass addClass(java.lang.String name)
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.
name - The name of the class.public IlrDynamicEnum addEnum(java.lang.String name)
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.
name - The name of the class.public IlrType addJavaClass(java.lang.Class javaClass)
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.
addJavaClass in interface IlrObjectModeljavaClass - The source Java class.IlrClass
or an IlrPrimitiveType.public IlrType mapJavaType(java.lang.Class javaClass)
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.
IlrObjectModel.Kind.NATIVE object model, the returned type contains a reference
to the original Java class which can be retrieved by calling the
IlrType.getNativeClass() method. The IlrType element is
said to be bound to the Java class.
If a given IlrClass element is bound to a Java class,
and one of the following elements is requested :
mapJavaType(Class) method.
IlrObjectModel.Kind.BUSINESS object model, the returned type
does not contain a reference to the original Java class. All the Java class
members are mapped to IlrMember instances. If a type used in a member
or as a superclass was not previously present in the object model, then it is created as a
missing refence (see IlrType.isMissingReference().
mapJavaType in interface IlrObjectModeljavaClass - The source Java class.IlrClass
or an IlrPrimitiveType.public IlrClass mapJavaClass(java.lang.Class javaClass)
mapJavaType(Class) and, if the returned type is an
IlrClass, it is returned, otherwise null
is returned.mapJavaClass in interface IlrObjectModeljavaClass - The source Java class.IlrClass
or an IlrPrimitiveType.public IlrClass mapJavaClass(java.lang.String rawClassName, IlrType... typeParameters)
rawClassName
bound to the given type parameters.mapJavaClass in interface IlrObjectModelrawClassName - An instance of a generic class.typeParameters - The type parameters.public IlrClass getGenericClass(java.lang.String rawClassName, int numberOfTypeParameters)
getGenericClass in interface IlrObjectModelpublic IlrType mapJavaType(java.lang.String className)
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.
mapJavaType in interface IlrObjectModelclassName - The source Java class name.public IlrClass mapJavaClass(java.lang.String className)
mapJavaType(className). If the returned type is an
IlrClass, it is returned, otherwise null
is returned.mapJavaClass in interface IlrObjectModelclassName - The source Java class name.public boolean remove(IlrSelector selector)
selector argument.remove in interface IlrObjectModelselector - The object model subset selector.true if at least one model element was removed.public boolean removeClass(IlrClass aClass)
aClass from this object model.removeClass in interface IlrObjectModelaClass - The class to be removed.true if the class was removedpublic IlrPackage getDefaultPackage()
java,
ilog,and so forth. The default package may also contain classes and
enumerations.getDefaultPackage in interface IlrObjectModelpublic IlrDynamicPackage getDynamicDefaultPackage()
IlrObjectModel.getDefaultPackage,
although the return value has an IlrDynamicPackage type.public IlrMutablePackage getMutableDefaultPackage()
IlrObjectModel.getDefaultPackage
although the return value has an IlrMutablePackage type.public IlrPackage getPackage(java.lang.String fullyQualifiedName)
fullyQualifiedName.getPackage in interface IlrObjectModelfullyQualifiedName - A fully qualified name.public IlrType getType(java.lang.String fullyQualifiedName)
fullyQualifiedName.getType in interface IlrObjectModelfullyQualifiedName - A fully qualified name.public IlrClass getClass(java.lang.String fullyQualifiedName)
fullyQualifiedName.getClass in interface IlrObjectModelfullyQualifiedName - A fully qualified name.null.public IlrClass getClass(java.lang.String rawClassName, IlrType[] typeParameters)
rawClassName
bound to the given type parameters.getClass in interface IlrObjectModelrawClassName - An instance of a generic class.typeParameters - The type parameters.null.public void accept(IlrVisitor visitor)
accept in interface IlrVisitablevisitor - The visitor.public IlrClass getStringClass()
java.lang.String class.getStringClass in interface IlrObjectModelpublic java.util.List getPrimitiveTypes()
getPrimitiveTypes in interface IlrObjectModelpublic IlrPrimitiveType getPrimitiveType(java.lang.String name)
name.getPrimitiveType in interface IlrObjectModelnull.protected IlrPrimitiveType getPrimitiveType(int tag)
public IlrType getVoidType()
void primitive type.getVoidType in interface IlrObjectModelpublic IlrType getBooleanType()
boolean primitive type.getBooleanType in interface IlrObjectModelpublic IlrType getByteType()
byte primitive type.getByteType in interface IlrObjectModelpublic IlrType getCharType()
char primitive type.getCharType in interface IlrObjectModelpublic IlrType getFloatType()
float primitive type.getFloatType in interface IlrObjectModelpublic IlrType getDoubleType()
double primitive type.getDoubleType in interface IlrObjectModelpublic IlrType getShortType()
short primitive type.getShortType in interface IlrObjectModelpublic IlrType getIntType()
int primitive type.getIntType in interface IlrObjectModelpublic IlrType getLongType()
long primitive type.getLongType in interface IlrObjectModelpublic java.util.Iterator allPackages()
allPackages in interface IlrObjectModelpublic java.util.Iterator allEnums()
allEnums in interface IlrObjectModelpublic java.util.Iterator allClasses()
allClasses in interface IlrObjectModelpublic final IlrResources getResources()
getResources in interface IlrObjectModelnull.public final void setResources(IlrResources resources)
resources - A resource bundle. It cannot be nullprotected int addClass(IlrDynamicClass clazz)
public static boolean isNumeric(int tag)
© Copyright IBM Corp. 1987, 2017