UML and its equivalent Java Code [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I have drawn UML class diagram. Now, my task is to convert that UML class diagram to equivalent Java code.
I do not want to use any automated tool, which generates Java code from UML diagram.
Kindly provide some pointers (webLink, PDF file , other), which talks about UML and its equivalent Java Program.

This 11-page PDF describes a mapping from UML notation to Java conventions. For example, implementing cursors as Java Enumerations, reducing multiple inheritance to single, etc.
Here is a 4-part article on the same subject:
Part 1
Part 2
Part 3
Part 4

If you don't want to use an automated tool, the only alternative is to open a text editor or IDE and create each Java class's .java file by hand.
For every UML class, create a Java class. Add all the methods and data members you want in those classes.
If there's inheritance called for by the model, have your Java classes extend those classes or implement those interfaces.
Did I misread this question?

I do not want to use any automated tool, which generates Java code from UML diagram.
Then use Eclipse or vi :)

If you know how class diagrams work, then you should be able to write a Java program from the diagram.
A class diagram has attributes, functions and relationships. In a Java class, the attributes are variables and the methods are functions. The relationships in Java are either extends (for inheritance) or implements.
If there are other specific things that aren't obvious you could ask, but you should be able to translate to code from the design pretty easily.

Related

Is there a Java API that creates BPMN? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Is there a way to programmatically create BPMN 2.0 via a Java API?
I'm aware that I can use a graphical modeling tool or create the BPMN XML by hand but I'm looking for a way to create it dynamically at run-time.
In my case, the BPMN will be executed through jBPM. The jBPM docs say you can use their API to define processes but they don't recommend its use "to shield yourself from internal APIs". It would be great if there were an API that wasn't tied to a specific vendor.
EasyBPMN is one option. There is no "vendor neutral" way in that Java doesn't have a standard API for the concept (unlike, say generic XML manipulation), but this would be an option which would be more portable between workflow engines and modeling tools.
the whole idea about the BPMN2 spec is to be vendor neutral, inside jBPM5 you have the fluent API that in some way allow you to create BPMN2 models that you can export. I'm not sure if it's up-to-date with the latest features that are supported in the XML but I'm pretty sure that you can create your own processes with it.
Cheers
BPMN2 model is based on EMF model (org.eclipse.bpmn2 project, model folder, BPMN20.ecore file). You can use EMF Java Api to create, read or modify BPMN2 models.
You can use the library from activiti.
here there's a blog post of one of the people behind activiti.
I did a compiler that modifies a process based on this and it works.

Java source code parsers/generators [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I need tools to:
Conveniently parse Java source code and easily access given elements.
Easily generate source code files, to easily transform data structures into code
Any good tips, libraries, frameworks, tools? Thank you for help.
If you need to parse existing source code, use JavaParser. It gives you visitor-based access to the AST. You can write new code, but many things are a pain (e.g. referencing other classes)
If you need to generate source code use CodeModel. It lets you programmatically create classes, packages, methods etc, and it's very easy to use. However, I don't think it can import existing code.
Both are pretty awesome in their respective domains.
Since Java 6, the compiler has an API included in the JDK. Through it you can access the results of the Java parser through the javax.lang.model APIs. The same functionality was present with JDK5 in the form of the Mirror API. There's a good introductory article here.
The best code generation tool I've seen is CodeModel. It has a very simple API and can generate multiple Java source files at once.
Our DMS Software Reengineering Toolkit and its Java Front End can do this. They are designed to enable the construction of custom analyzers and code generators.
DMS provides generic parsing, abstract-syntax tree (with comments) and symbol table building, tree navigation/inspection/modification facilities, and the ability to regenerate the complete source code from the modified tree. Additional facilities includes source-to-source transformation rules ("if you see this syntax, replace it with that syntax"), and patterns (used to build or recognize subtree), attribute grammar evaluators, control and data flow analysis, and call-graph construction. The Java Front End specializes DMS to do all of this for Java 1.4-1.6 with 1.7 nearby.
(EDIT May 2016: Now handles Java 1.8)
DMS is also designed to handle scale: it is often used to process many compilation-units (source files) at the same time, enabling analysis and transformations that cross file boundaries. It can also handle multiple languages at the same time; DMS has front ends for a wide variety of languages.
Check out Antlr. One of its examples is a Java grammar.

Eclipse plugin for generating a class diagram [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
What is a good Eclipse plugin for generating a class diagram (for a project)?
This image right here is exactly what I'm talking about.
Assuming that you meant to state 'Class Diagram' instead of 'Project Hierarchy', I've used the following Eclipse plug-ins to generate Class Diagrams at various points in my professional career:
ObjectAid. My current preference.
EclipseUML from Omondo. Only commercial versions appear to be available right now. The class diagram in your question, is most likely generated by this plugin.
Obligatory links
The listed tools will not generate class diagrams from source code, or atleast when I used them quite a few years back. You can use them to handcraft class diagrams though.
UMLet. I used this several years back. Appears to be in use, going by the comments in the Eclipse marketplace.
Violet. This supports creation of other types of UML diagrams in addition to class diagrams.
Related questions on StackOverflow
Is there a free Eclipse plugin that creates a UML diagram out of Java classes / packages?
Except for ObjectAid and a few other mentions, most of the Eclipse plug-ins mentioned in the listed questions may no longer be available, or would work only against older versions of Eclipse.
Must it be an Eclipse plug-in? I use doxygen, just supply your code folder, it handles the rest.
Try Amateras. It is a very good plugin for generating UML diagrams including class diagram.
Try eUML2. its a single click generator no need to drag n drop.

Any tool can help refactor field into get/set pairs of method [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Wondering if there is tool to assist this kind of refactoring.
Eclipse is an awesome IDE!
... or...
In Netbeans...
Eclipse has the functionality of generate getters and setters.
Source > Generate setters and getters
Source: Generate Getters and Setters
eclipse provides this. You can use my plugin as well : https://stackoverflow.com/questions/2733311/copy-field-and-methods/2734647#2734647.
It's a standard feature of the eclipse IDE (and of other IDEs too, I suppose).
Shortcut: ALT+s -> r shows the getter/setter dialog (if a class with class members was selected)
BTW - autogenerating getter/setter stubs for class members is not a refactoring.
Code refactoring is "a disciplined way to restructure code", undertaken in order to improve some of the nonfunctional attributes of the software. (wikipedia)
Autogenerating those stubs does not restructure the (existing) code. It automatically adds method implementations. And, if we look at eclipse, we don't find the according action in the list of refactorings (additional hint).
Further Reading: Self Encapsulate Field
Depending on what IDE you use, this is a standard feature provided. For instance, in Netbeans - right click on your java class and choose Refactor -> Encapsulate Fields. You can additionally select the accessors visibility, order of appearance and insert point.

Which tools do you recommend for java round-trip-engineering? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I am especially interested in generating code from sequence diagrams and vice versa- ie., sequence diagrams from code. Ofcourse it would be nice if it was free and better if it was an eclipse plugin!
Altova UModel can generate sequence diagram from the code, but I don't see any point from the opposite direction.
Anyway, UModel has 30 days free trail and it is really a great tool so you should check it.
Here is the
link.
I've never seen a tool generating code from a sequence diagram in uml or doing opposite conversion. In particular, because sequence diagrams are supposed to provide high-level overview of logic flow.
You can reverse engineer sequence diagram from code to UML.
I don't know any tool creating a java code from a sequence diagram model !!
MagicDraw is a good tool. It is written in Java and if you purchase the right pluggins will do the round tripping for you.
Be wary of round tripping too much though - it kinda defeats the purpose of designing if you do too much of it. It implies that you are not really designing and then implementing the design, but rather hacking around inside a UML tool. The project leader at one company I worked for did not allow round tripping at all and did not let developers purchase the tools to do it. Having said that, it can be useful for generating diagrams from an existing code base that you did not write, to get a high level view of design and interactions.

Categories

Resources