Two special variables are available in a Java script contents:
| self | This variable is the instance the script is evaluated on (instance of the script's metatype). |
| context | This variable is an instance of the com.sodius.mdw.core.eval.EvaluationContext interface.
It provides services that helps to build model transformators/generators.
For example it enables to call text templates and rules from Java code.
|
Example:
package com.mycompany.example;
import com.sodius.mdw.metamodel.uml21.scripts.ClassScriptContainer;
public class uml21_Class extends ClassScriptContainer {
public String qualifiedName() {
return self.getNamespace().toString("qualifiedName") + "." + self.getName();
}
public String generateJava() {
context.generate("com.mycompany.example.GenerateJava", asList(self));
}
}