简体   繁体   English

如何解析Java代码以生成类图?

[英]How to parse Java code to generate class diagram?

I have to generate class diagrams from the java files such that the parser must be executable on the command line with the following format: 我必须从java文件生成类图,以便解析器必须在命令行上以以下格式可执行:

umlparser classpath output_file_name umlparser类路径output_file_name

umlparser is my .java file name umlparser是我的.java文件名

classpath is a folder name where all the .java source files will be classpath是所有.java源文件所在的文件夹名称

output file name is the name of the output image file you program will generate ( .jpg, .png or .pdf format) 输出文件名是您程序将生成的输出图像文件的名称(.jpg,.png或.pdf格式)

Tools for parsing Java Source and generating UML diagrams can be used. 可以使用用于解析Java Source和生成UML图的工具。

I was looking at http://yuml.me/diagram/class/draw and found that that is a good way to generate the class diagram. 我查看了http://yuml.me/diagram/class/draw ,发现这是生成类图的好方法。

However, I can't get the idea how can I get the code in the form of 但是,我不知道该如何获取以下形式的代码:

[Customer|forname:string;surname:string|doPost();doGet()]<>-orders*>[Order]
[Order]++-0..*>[LineItem]
[Order]-[note:Aggregate root{bg:wheat}]

Any insight on how to generate this code? 关于如何生成此代码的任何见解?

Any other suggestions are also welcomed. 也欢迎任何其他建议。

Maybe you need to take a look at doxygraph . 也许您需要看一下Doxygraph Its maintainers define the tool as follows: 其维护者对工具的定义如下:

It relies on Doxygen to parse your source code and create an intermediate XML representation of the information it collects, so it supports all the same programming languages that Doxygen supports: C, C++, C#, Objective C, Java, Python, PHP, Tcl, D, IDL, VHDL, and Fortran. 它依靠Doxygen来解析您的源代码并创建其所收集信息的中间XML表示形式,因此它支持Doxygen支持的所有相同编程语言:C,C ++,C#,Objective C,Java,Python,PHP,Tcl, D,IDL,VHDL和Fortran。

Reverse-engineering functionality is also present in IntelliJ IDEA and Visual Paradigm editors, but it is a paid feature as far as I can remember. IntelliJ IDEA和Visual Paradigm编辑器中也提供了逆向工程功能,但据我所知,它是一项付费功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM