J and the metamodel

 

Overview

The metamodel defined for Objecteering/UML is accessible through the J language.  J uses metaclasses, meta-associations, meta-roles and meta-attributes to navigate within a model and access model information.

J can also transform the metamodel, for example, change attribute values, create or determine model elements or modify links).

As we have already seen, J is used to define methods at metaclass level.

 

Handling rules

 

Figure 1. Part of the metamodel (simplified)

 

In Figure 1-1, the names of all the attributes whose visibility is "public" ("printPublicAttributes()" J method) can be displayed.

 

Class:printPublicAttributes()

{

   PartAttribute

   {

      if (Visibility==Public)

         StdOut.write (Name, NL);

     

   }

}

 

·         "NL" indicates the return. 

·         "StdOut" is the standard output which will generally be the Objecteering output window.

·         "write" is a method of writing, which allows an unlimited number of parameters, which can be character strings or other basic types (integer, boolean, etc). 

·         "PartAttribute" is the concatenation of the "Part" role name, and the "Attribute" metaclass name.  For J, and from a "Class" instance perspective, it designates all attributes belonging to the current class.  "Name" is the attribute of the "Attribute" metaclass.