4.1 Importing and exporting with MSE
The preferred way to load a model in Moose is via an MSE file. To load an MSE file, all you have to do is to press the “Import from MSE” button in the Moose Panel and indicate the file to load. This creates a model, populates it with the entities from the file and adds the model to the repository. Visually, the model appears in the list of models from the Moose Panel.
But what exactly is MSE? MSE is the default file format supported by Moose. It is a generic file format and can describe any model. It is similar to XML, the main difference being that instead of using verbose tags, it makes use of parentheses to denote the beginning and ending of an element.
The following snippet provides an example of a small model:
( (FAMIX.Namespace (id: 1) (name 'aNamespace')) (FAMIX.Package (id: 201) (name 'aPackage')) (FAMIX.Package (id: 202) (name 'anotherPackage') (parentPackage (ref: 201))) (FAMIX.Class (id: 2) (name 'ClassA') (container (ref: 1)) (parentPackage (ref: 201))) (FAMIX.Method (name 'methodA1') (signature 'methodA1()') (parentType (ref: 2)) (LOC 2)) (FAMIX.Attribute (name 'attributeA1') (parentType (ref: 2))) (FAMIX.Class (id: 3) (name 'ClassB') (container (ref: 1)) (parentPackage (ref: 202))) (FAMIX.Inheritance (subclass (ref: 3)) (superclass (ref: 2))))
The file defines 8 entities: 1 Namespace, 2 Packages, 2 Classes, 1 Method, 1 Attribute and 1 Inheritance. For each of these entities it provides a unique identifier (e.g., (id: 1)
) and it defines properties. In general, properties can be either primitive, like (name ’aNamespace’)
, or they can point to another entity, like in the case of (container (ref: 1))
which denotes that the container property of ClassA points to the instance of Namespace named aNamespace.
The overall object graph can be seen graphically below.
A more complex MSE example is available for download as described in Chapter 3.
Once a model is loaded, it can be easily exported as an MSE file. This can be done via the contextual menu of the model. By choosing the “Export to MSE” menu item you will be prompted to indicate the desired file name and location, and the result is an MSE file saved on the disk containing the entities in the model.