Code Generation: Java

Overview

This sample generates a basic Java source file for each Class of an UML input model. The sample generates:

Launch configuration

 
Ruleset com.sodius.mdw.samples.java.JavaGeneration
Rule main
Arguments a UML input model (e.g. models/product13.xmi)

Here is an example of a UML 1.3 based Java generation launch:

Features demonstrated

Feature Example Location Reference
Calling a text template from a rule $JavaSource(class) JavaGeneration.mqr template call
Including a text template from another text template [#include ClassJavadoc(class)] JavaSource.tgt include
Trimming to avoid blank lines ${class.importsDeclaration}[#rtrim] JavaSource.tgt trim
Filtering a list of instances based on a criterium self.parameter.reject("kind", RETURN_LITERAL) uml13_Operation.mqs MDWList
Specifying a default value self.returnType.javaType ? "void" uml13_Operation.mqs default value
Using protected sections to keep user code [#protectedStartTag] uml13_Operation.mqs protected tags