ilog.rules.bom.dynamic

Class IlrDynamicObjectModel

  • java.lang.Object
    • ilog.rules.bom.dynamic.IlrDynamicObjectModel
    • Field Detail

      • supportMissingReferences

        protected boolean supportMissingReferences
    • 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
    • Method Detail

      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Returns the class loader set by a call to setClassLoader.
        Specified by:
        getClassLoader in interface IlrObjectModel
      • setClassLoader

        public void setClassLoader(java.lang.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
      • 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
      • merge

        public boolean merge(IlrObjectModel objectModel)
        Merges objectModel into this object model.
        Specified by:
        merge in interface IlrObjectModel
        Throws:
        java.lang.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:
        java.lang.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,
                    java.util.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:
        java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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.

        • In the case of a 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 :

          • the types of its attributes
          • the return type of its methods
          • the types of its parameters
          • the exceptions thrown
          and if any of these types were not previously present in the object model, then they are lazily added by calls to the mapJavaType(Class) method.
        • In the case of a 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().
        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(java.lang.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(java.lang.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.
      • mapJavaType

        public IlrType mapJavaType(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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.
      • getPrimitiveTypes

        public java.util.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.
      • getIntType

        public IlrType getIntType()
        Returns the int primitive type.
        Specified by:
        getIntType in interface IlrObjectModel
        Returns:
        A primitive type.
      • allPackages

        public java.util.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 java.util.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 java.util.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
      • isNumeric

        public static boolean isNumeric(int tag)

© Copyright IBM Corp. 1987, 2017