Adding User Classes at Run Time

Your user applications can add user classes at run time. Although these user‑defined classes are visible in the JADE development environment, they are not considered as part of the JADE model, you cannot reference them in JADE methods, they are not extracted, reorganized, and so on.

You can only define runtime dynamic properties on user classes. You can create instances of a user class of any lifetime (that is, persistent, transient, and shared‑transient lifetimes).

The following table summarizes the classes and methods that enable you to maintain user classes.

Class Method Description

Schema

addUserCollectionSubclass

Creates a user collection class as a subclass of the specified superclass in the receiving schema
Schema addUserSubclass Creates a user class as a subclass of the specified superclass in the receiving schema
Schema deleteUserSubclass Deletes a user class from the specified superclass in the receiving schema
JadeUserCollClass addExternalKey Adds an external key definition to a user class at run time
JadeUserCollClass addMemberKey Adds a member key definition to a user class at run time
JadeUserCollClass clearKeys Clears existing key definitions
JadeUserCollClass endKeys Indicates the end of a single or multiple key definition
JadeUserCollClass setLength Sets or changes the element length for an array
JadeUserCollClass setMembership Sets or changes the membership of a user class at run time

The following example shows a runtime dynamic property being added to a user class.

vars
    userClass1 : Class;
    cluster : JadeDynamicPropertyCluster;
    c1 : C1;
begin
    beginTransaction;
    userClass1 := currentSchema.addUserSubclass(C1, "UserClass1", "MapFileName");
    cluster := userClass1.addDynamicPropertyCluster("Cluster");
    cluster.addDynamicProperty("dynamicInteger", Integer, 0, 0.Byte);
    commitTransaction;
    create c1 as userClass1 transient;
    c1.integer := 123;                            // static property
    c1.setPropertyValue("dynamicInteger", 456);   // runtime dynamic property
    c1.inspectModal();
    delete c1;
end;