javaumlmodelio

Generate java code in modelio


I created a UML class diagram im Modelio, now I need to implement this diagram in Java. Is there any possibility to generate Java code out of a class diagram? I just want to export the classes and prototypes of the methods. I have already tried tu use "java designer 3.1.00", but i could not figure out if/how i can generate class files with this extention.


Solution

  • Another way is write a macro using Modelio API. This is a very simple example for PHP (only for prepare class and methods):

    if (selectedElements.size() > 0):
        for c in selectedElements:
            print "<?php"
            print ""
            print "class " + c.getName()
            print "{"
    
            child = c.getCompositionChildren()       
            for a in child:
                if (a.getMClass().getName() == "Operation"):             
                    print " public function " + a.getName() + "()"
                    print " {"
                    print " }"
                    print ""                     
            print "}"
            print ""
    else:
        print "No element has been selected."
    

    APIs for macros is here. API also allows you to save your generated code to files (for example you can use package names as directories and class names as file names).