public interface IlrObjectModel extends IlrProperties, IlrVisitable
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.
Ilr<className>.List and Ilr<className>.Iterator have been
replaced by List and Iterator respectively. The methods from
the removed classes that work using the model element's name are in
IlrModelUtilities.IlrObjectModel.Visitor is deprecated. It is now replaced by
IlrVisitor which supports the new kinds of
model elements and permits to select easily the classes to visit. For example,
if you want to count the number of members, except methods:
public static class MemberCounter extends IlrVisitor { // The class has to be static and public!
public int counter;
public void inspect(IlrMember member) { // The accepts methods have to be public
counter++;
}
public void inspect(IlrMethod method) {
// do nothing
}
}
IlrObjectModel.Selector is deprecated. It is now replaced by
IlrSelector, which supports the new kinds of
model elements and permits to select easily the classes to be tested. For example,
if you want to accept all public members, except methods:
public static class MemberSelector extends IlrSelector { // The class has to be static and public!
public boolean accepts(IlrMember member) { // The inspect methods have to be public
return true;
}
public boolean accepts(IlrMethod method) {
return false;
}
}
The methods that previously had an IlrObjectModel.Selector as a parameter now have
an IlrSelector. You can wrap your implementations of IlrObjectModel.Selector
by using the IlrObjectModel.SelectorWrapper class.
IlrPackage,
IlrType,
IlrClass,
IlrEnum,
IlrPrimitiveType| Modifier and Type | Interface and Description |
|---|---|
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 |
| Modifier and Type | Method and Description |
|---|---|
IlrType |
addJavaClass(java.lang.Class javaClass)
Adds the description of the Java class named
javaClass to
the object model. |
java.util.Iterator |
allClasses()
Returns an iterator that iterates over all classes contained
in this object model.
|
java.util.Iterator |
allEnums()
Returns an iterator that iterates over all of the enumerations contained
in this object model.
|
java.util.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(java.lang.String fullyQualifiedName)
Returns the class which has 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. |
IlrClass |
getClassReference(java.lang.Class javaClass)
Returns the class corresponding to the Java class.
|
IlrClass |
getClassReference(java.lang.String fqn)
Returns the class corresponding to the fqn.
|
IlrClass |
getClassReference(java.lang.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(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. |
IlrPackage |
getPackage(java.lang.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(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 |
getTypeReference(java.lang.Class javaClass)
Returns the type corresponding to the Java class.
|
IlrType |
getTypeReference(java.lang.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(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(String) and, if the returned type is an
IlrClass, it is returned, otherwise null
is returned. |
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
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(java.lang.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. |
isPropertyPersistent, setPersistentProperty, setPersistentPropertygetPropertyValue, getPropertyValue, propertyNames, removeProperty, setPropertyValueacceptjava.lang.ClassLoader getClassLoader()
setClassLoader.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.
IlrObjectModel.Kind getKind()
IlrObjectModel.Platform getPlatform()
boolean isDynamicallyLoadingClasses()
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.void setJavaClassLookupEnabled(boolean flag)
IlrObjectModel.Kind passed at creation time instead.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.
java.lang.UnsupportedOperationException - if the class lookup cannot be enabled/disabled.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.boolean isMappingComponentProperties()
true if the mapping of component properties is enabled.setMappingComponentProperties(boolean)boolean merge(IlrObjectModel objectModel)
objectModel into this object model.java.lang.RuntimeException - if the target object model is not mutableobjectModel - The source object model.true if successful.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 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.
java.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.boolean merge(IlrObjectModel objectModel, IlrSelector selector, java.util.Iterator initialTypes)
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.
java.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 over the classes that
must be fully merged.true if successful.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 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.
javaClass - The source Java class.IlrClass
or an IlrPrimitiveType.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().
javaClass - The source Java class.IlrClass
or an IlrPrimitiveType.IlrClass mapJavaClass(java.lang.Class javaClass)
mapJavaType(Class) and, if the returned type is an
IlrClass, it is returned, otherwise null
is returned.javaClass - The source Java class.IlrClass
or an IlrPrimitiveType.IlrClass mapJavaClass(java.lang.String rawClassName, IlrType... typeParameters)
rawClassName
bound to the given type parameters.rawClassName - typeParameters - IlrType mapJavaType(java.lang.String className)
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.
className - The source Java class name.IlrClass mapJavaClass(java.lang.String className)
mapJavaType(String) and, if the returned type is an
IlrClass, it is returned, otherwise null
is returned.className - The source Java class name.boolean remove(IlrSelector selector)
selector argument.selector - The object model subset selector.boolean removeClass(IlrClass aClass)
aClass from this object model.aClass - The class to be removed.IlrPackage getDefaultPackage()
java,
ilog, and so forth). The default package may also contain classes and
enumerations.IlrClass getStringClass()
java.lang.String class.IlrPackage getPackage(java.lang.String fullyQualifiedName)
fullyQualifiedName.fullyQualifiedName - A fully qualified name.IlrType getType(java.lang.String fullyQualifiedName)
fullyQualifiedName.fullyQualifiedName - A fully qualified name.IlrClass getClass(java.lang.String fullyQualifiedName)
fullyQualifiedName.fullyQualifiedName - A fully qualified name.IlrClass getClass(java.lang.String rawClassName, IlrType[] typeParameters)
rawClassName
bound to the given type parameters.rawClassName - The instance of the rawClassName generic class.typeParameters - The given type parameters.IlrClass getGenericClass(java.lang.String rawClassName, int numberOfTypeParameters)
IlrClass getClassReference(java.lang.Class javaClass)
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().IlrType getTypeReference(java.lang.Class javaClass)
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().IlrClass getClassReference(java.lang.String fqn)
IlrType.isMissingReference().IlrClass getClassReference(java.lang.String fqn, IlrType[] typeParameters)
IlrType.isMissingReference().IlrType getTypeReference(java.lang.String fqn)
IlrType.isMissingReference().boolean visit(IlrObjectModel.Visitor visitor)
IlrVisitor instead.visitPackge method of the visitor
applied to the default package of the object model.visitor - A visitor.true if the visitor's visitPackage method
returns true.java.util.Iterator allPackages()
java.util.Iterator allEnums()
java.util.Iterator allClasses()
java.util.List getPrimitiveTypes()
IlrPrimitiveType getPrimitiveType(java.lang.String name)
name.IlrType getVoidType()
void primitive type.IlrType getBooleanType()
boolean primitive type.IlrType getByteType()
byte primitive type.IlrType getCharType()
char primitive type.IlrType getFloatType()
float primitive type.IlrType getDoubleType()
double primitive type.IlrType getShortType()
short primitive type.IlrType getIntType()
int primitive type.IlrType getLongType()
long primitive type.IlrResources getResources()
null.© Copyright IBM Corp. 1987, 2017