|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ilog.rules.bom.dynamic.IlrDynamicObjectModel
public class IlrDynamicObjectModel
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.
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 |
---|
protected boolean supportMissingReferences
protected transient IlrModelFactory modelFactory
Constructor Detail |
---|
public IlrDynamicObjectModel(IlrObjectModel.Kind kind)
kind
- The kind of object model. It cannot be null
public IlrDynamicObjectModel()
IlrDynamicObjectModel(ilog.rules.bom.IlrObjectModel.Kind)
IlrDynamicObjectModel(IlrObjectModel.Kind.NONNATIVE)
.
Method Detail |
---|
public ClassLoader getClassLoader()
setClassLoader
.
getClassLoader
in interface IlrObjectModel
public void setClassLoader(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 IlrObjectModel
public IlrObjectModel.Kind getKind()
getKind
in interface IlrObjectModel
public IlrObjectModel.Platform getPlatform()
getPlatform
in interface IlrObjectModel
public IlrModelFactory getModelFactory()
getModelFactory
in interface IlrMutableObjectModel
public void setMappingComponentProperties(boolean flag)
This property modifies the way Java classes are mapped to IlrClass
es.
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
IlrMethod
s 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 IlrAttribute
s
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 IlrObjectModel
public boolean isMappingComponentProperties()
true
if the mapping of component properties is enabled.
isMappingComponentProperties
in interface IlrObjectModel
setMappingComponentProperties(boolean)
public boolean merge(IlrObjectModel objectModel)
objectModel
into this object model.
merge
in interface IlrObjectModel
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 IlrObjectModel
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, 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 IlrObjectModel
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(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(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(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(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 IlrObjectModel
javaClass
- The source Java class.
IlrClass
or an IlrPrimitiveType
.public IlrType mapJavaType(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 IlrObjectModel
javaClass
- The source Java class.
IlrClass
or an IlrPrimitiveType
.public IlrClass mapJavaClass(Class javaClass)
mapJavaType(Class)
and, if the returned type is an
IlrClass
, it is returned, otherwise null
is returned.
mapJavaClass
in interface IlrObjectModel
javaClass
- The source Java class.
IlrClass
or an IlrPrimitiveType
.public IlrClass mapJavaClass(String rawClassName, IlrType... typeParameters)
rawClassName
bound to the given type parameters.
mapJavaClass
in interface IlrObjectModel
rawClassName
- An instance of a generic class.typeParameters
- The type parameters.public IlrClass getGenericClass(String rawClassName, int numberOfTypeParameters)
getGenericClass
in interface IlrObjectModel
public IlrType mapJavaType(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 IlrObjectModel
className
- The source Java class name.
public IlrClass mapJavaClass(String className)
mapJavaType(className)
. If the returned type is an
IlrClass
, it is returned, otherwise null
is returned.
mapJavaClass
in interface IlrObjectModel
className
- The source Java class name.
public boolean remove(IlrSelector selector)
selector
argument.
remove
in interface IlrObjectModel
selector
- 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 IlrObjectModel
aClass
- 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 IlrObjectModel
public 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(String fullyQualifiedName)
fullyQualifiedName
.
getPackage
in interface IlrObjectModel
fullyQualifiedName
- A fully qualified name.
public IlrType getType(String fullyQualifiedName)
fullyQualifiedName
.
getType
in interface IlrObjectModel
fullyQualifiedName
- A fully qualified name.
public IlrClass getClass(String fullyQualifiedName)
fullyQualifiedName
.
getClass
in interface IlrObjectModel
fullyQualifiedName
- A fully qualified name.
null
.public IlrClass getClass(String rawClassName, IlrType[] typeParameters)
rawClassName
bound to the given type parameters.
getClass
in interface IlrObjectModel
rawClassName
- An instance of a generic class.typeParameters
- The type parameters.
null
.public void accept(IlrVisitor visitor)
accept
in interface IlrVisitable
visitor
- The visitor.public IlrClass getStringClass()
java.lang.String
class.
getStringClass
in interface IlrObjectModel
public List getPrimitiveTypes()
getPrimitiveTypes
in interface IlrObjectModel
public IlrPrimitiveType getPrimitiveType(String name)
name
.
getPrimitiveType
in interface IlrObjectModel
null
.protected IlrPrimitiveType getPrimitiveType(int tag)
public IlrType getVoidType()
void
primitive type.
getVoidType
in interface IlrObjectModel
public IlrType getBooleanType()
boolean
primitive type.
getBooleanType
in interface IlrObjectModel
public IlrType getByteType()
byte
primitive type.
getByteType
in interface IlrObjectModel
public IlrType getCharType()
char
primitive type.
getCharType
in interface IlrObjectModel
public IlrType getFloatType()
float
primitive type.
getFloatType
in interface IlrObjectModel
public IlrType getDoubleType()
double
primitive type.
getDoubleType
in interface IlrObjectModel
public IlrType getShortType()
short
primitive type.
getShortType
in interface IlrObjectModel
public IlrType getIntType()
int
primitive type.
getIntType
in interface IlrObjectModel
public IlrType getLongType()
long
primitive type.
getLongType
in interface IlrObjectModel
public Iterator allPackages()
allPackages
in interface IlrObjectModel
public Iterator allEnums()
allEnums
in interface IlrObjectModel
public Iterator allClasses()
allClasses
in interface IlrObjectModel
public final IlrResources getResources()
getResources
in interface IlrObjectModel
null
.public final void setResources(IlrResources resources)
resources
- A resource bundle. It cannot be null
protected int addClass(IlrDynamicClass clazz)
public static boolean isNumeric(int tag)
|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |