Java Source Code to UML Class Diagram

Can anyone tell me exactly which kinds of relationships may be identified for a UML CLass diagram, directly from 'static' source code..
Note that I am developing my own case tool which will convert from java to uml..
At the moment, I have only managed to get Inheritance and Association relationships..
Where Association is identified by looking at the types of all variables belonging to a class (excluding method variables etc) and if the type of the variable is non-primitive, than I have deduced it is an association relationship with that class.
Would this be the right approach?
Secondly I have noticed in JBuilder, it models dependency relationships by getting all the Imports at the top of the java source file, is this right?? also I have read that a dependency can be modelled by the variable types in operation arguments (paremeterS ?)..
I would also appreciate if someone could clarify the difference betweeen Composition and Aggregation for me and explain if it is possible to identify the two relationships directly from java source code..
Last but not least, what about multiplicity ? am I right in thinking that an instance variable is 0-1, an array declaration is seen as 0-n (fixed number) and a Vector/ data collection.. is seen as 0 - * (any number)..
Thanks for any help,
Regards
Tony.

although this post is way old it could do with a decent answer.
some guidance can be taken from JSR26: UML Mapping for EJB
find it a www.jcp.org
also this research paper on consistency of reverse engineering between uml tools
http://citeseer.nj.nec.com/545406.html
Where Association is identified by looking at the types of all variables belonging >to a class (excluding method variables etc) and if the type of the variable is >non-primitive, than I have deduced it is an association relationship with that >class.
Would this be the right approach?Yes. You could also say that if it is a java.* type then it would also be an attribute.
Secondly I have noticed in JBuilder, it models dependency relationships by getting >all the Imports at the top of the java source file, is this right?? also I have >read that a dependency can be modelled by the variable types in operation >arguments (paremeterS ?)..JBuilder would be consistent with JSR26, and that's how i intend to implement in ArgoUml.
I would also appreciate if someone could clarify the difference betweeen >Composition and Aggregation for me and explain if it is possible to identify the >two relationships directly from java source code..Composition is a stronger form of ownership. the composed class is owned only by 1 class. Its lifetime is strongly linked to its owner - ie. it is not created before its owner and it is destroyed before its owner is.
eg. leg of a table.
Agregation is weak ownership. the owned class may be owned by several classes.
eg. a company is owned by many shareholders.
Last but not least, what about multiplicity ? am I right in thinking that an >instance variable is 0-1, an array declaration is seen as 0-n (fixed number) and a >Vector/ data collection.. is seen as 0 - * (any number)..sound right.
Alex

Similar Messages

  • Hungarian Naming Contentions for UML Class Diagram

    UML class diagram should be generic for all the available object oriented language and should not be language dependent. If we follow pure java naming conventions in UML class diagram, which make the UML class diagram Java language dependent not generic.
    I am trying to combine Hungarian Naming Contentions with Java Naming Convention so variable name will follow x_y schema where x_ is according to Hungarian notation attached with class attribute, which is named according to java naming standard. This naming standard satisfies UML naming convention and will also help in java programming.
    For an example,
    i_userNumber Here 'i_' is a Hungarian notation representing type of variable attached with class attribute . This indicates that the attribute is an interger , which is named according to java naming standard.
    Feedback Please

    You're going to get a gozillion answers to this question, and all of them will be both right and wrong to some degree, so I will give you my thoroughly opinionated answer to go along with all the rest.
    I am not a fan of Hungarian notation for one fairly fundamental reason. Java is a strongly typed language, thus it doesn't need indicators of type. By putting a type indicator on a variable you create potential problems when you change a data type. Won't happen? I am currently sweeping through a major portion of the application I'm working on changing data types for masses of variables because the database guys took a whim to change the data type in the database. If I were using Hungarian notation, not only would I have to change the type, the parameter type and return type for the accessor mutator methods, I'd also have to change the name, the name of the accessor and mutator methods, and anywhere that the variable is modified directly.
    The name of a thing should speak for its self. It shouldn't need an indicator flag on the front to tell me what it is.
    But you're talking about UML not Java code. The same thoughts apply. The name should speak for the thing it represents without the need for additional clarification.
    Hungarian notation in my not so humble opinion adds complexity by requiring the development team to spend effort learning, understanding, thinking about, processing, manipulating, touching, dealing with what is essentially a thoroughly artificial naming scheme.
    Just my thoughts on the subject. Your milage may of course vary wildly.

  • Creating java code from a class diagram in JDeveloper

    I have created a class diagram in JDeveloper 11.1.1.3.0. When I generated java code from the class diagram by right clicking on the class diagram->transform->same diagram->UML to Java, a .java file is generated with attributes and getters/setters, and also a .uml_cla file is generated. What is this .uml_cla file exactly and what is it used for? Also I have a package.uml_pck file that was created 3 times. I have a package of com.xxx.xxxx, and it put this package.uml_pck file in "com", in "xxx", and in "xxxx". Do I need to retain all 3 of these files in my project?
    One more question related to this. When I change something in the java representation of the class diagram (i.e. a datatype), it updates the .java file that was generated from the class diagram, and it also works the other way...change the .java file and the java representation of the class diagram changes. However, the class diagram that the code was generated from does not change, nor does the mysterious .uml_cla file I asked about in the above paragraph.

    This did work for me, with an exception. I have put the .java files generated from the class diagram in a different package from the .class_diagram file, the package.uml_pck file, and the .uml_cla file to keep the actual source code separate. When I modified the .java file and transformed the class diagram from java to UML, it created the package.uml_pck file and the .uml_cla files again in the same package as the .java file, and they show the update. The package.uml_pck file, and the .uml_cla file that were originally created and are in the separate package from the .java files were untouched, thus the class diagram displayed does not reflect the change either. Does this mean I should not, or cannot, separate these files, and that they all must be left in the same package? (the purpose of separating it in the first place was for ease of deployment since we don't want to deploy any of the class diagram files) Thanks!

  • .java - UML Class Diagram

    Hello for my university exam, i developed an application, now i need to print the UML class diagram, so I was searching around for a tool to create the class diagram for my source code.
    I had tryed the software "borland together trial edition" for eclipse IDE, but i've two problems..
    1) it creates UML class diagram just for a package without expanding subpackages..
    2) it doesn't give an easy way to export the created UML class diagram, the only "good" format for printing it can export is a "buggy" SVG...
    Do you know better (and maybe free) software to create the UML class diagram from my sources? (or maybe you know a way to solve the two problem i said?
    thank yoU!!!

    There's a package on sourceforge call JReFactory which might do the job.

  • I can not drag java class onto uml class diagram - why??

    Hi
    1. I created a new java web project
    2. I created a new uml project.
    3. I created new classes in the java web project.
    4. I created a new "class diagram" in the uml project.
    PROBLEM:
    1. When I drag one of the classes onto the class diagram screen, nothing happens. That is, when I perform the "drop"...nothing happens.
    (NOTE: when I drag a "package" to the class diagram, a box representing the java package appears... I just cant get this to work for a class(s) )
    QUESTION:
    Should I be able to drag a class (or classes) from my web project src folder onto the UML project's class diagram and have UML representations of the classes appear?

    Hi Shay
    Unfortunately, I cannot view the suggested youtube stuff at work. (I'll try to view it when I get home)
    But, in the meantime, I did kind of get things working...
    After creating the java project and uml project (and initial class diagram), I had to
    1. drag the java packages (containing the classes I wanted diagrammed) onto the root node of the UML project (i.e., located on the left side "navigation" bar). Afterward, the package appeared under the UML project....Then,
    2. One by one I had to drag the individual java classes from the java project onto the root node of the UML project (i.e,. the classes then appeared under their respective packages under the UML project) . Then,
    3. Then, finally, I could drag the java classes (listed under their respective packages under the UML project) onto the class diagram panel, where the rendered properly.
    I dont know if this is supposed to be the way to "reverse engineer" java classes to be part of a UML class diagram... But, it was the only way I found that worked... thus far, anyway.
    Thanks again for reading my post and answering so promptly.... That was much appreciated!
    s

  • Converting class files into java source codes

    Dear Friends,
    It is true that conversion of class files to its java source codes is possible through some software. I want to know, is there any way to protect my java source codes from viewing or copying illegally by other persons ?
    If I create JAR file from java files, can it be also convertible back to source codes ?
    Avi

    You can use code obfuscators in order to protect your code. And yes a jar file can also be decompiled.
    http://www.retrologic.com/
    http://www.2lkit.com/products/2LKitObf/
    http://www.codingart.com/codeshield.html
    http://www.drjava.de/obfuscator/

  • Generate java source cod/ contect menu

    I am new to JDeveloper, so please excuse the ignorance. I am using JDeveloper 9.0.3.10.35 and UML modelers 9.0.3.9.4. I am going through the JDeveloper tutorial( Modeling Java Classes tutorial). I design a Class model and i try to generate java source code for some of the java interfaces in the design. The tutorial sates: Choose Generate|Java from the contect menu.
    Any idea where is this mysterious conext menu? There is a generate option under model but every thing is grayed out...Any help would be appriciated.

    Thanks Lisa. The problem really was with the poor instructions provided and a tired mind. There is no "context menu" ala right click on something BTW, right clicking on the main design page does not do any thing and right clicking a class only gives the properties. Anyway, what was meant, i think is to select Java from the main menu "model" and then select Generate/Java. Now since the code is "automatically generated", the Java option was grayed out and that threw me off.
    To descover all this i re-did the whole tutorial with only one class and viola, the code was there.

  • JBuilder and UML Class Diagrams?

    What version of JBuilder allows you to generate UML Class Diagrams from the Java code? I was thinking of downloading the free personal edition of JBuilder, but I'm not sure whether this functionality is included.

    What version of JBuilder allows you to generate UML
    Class Diagrams from the Java code? I was thinking of
    downloading the free personal edition of JBuilder, but
    I'm not sure whether this functionality is included.You need the enterprise version of JBuilder to get the UML diagram function.

  • Understanding Sun Idemtity Manager using UML Class Diagrams

    If you are a Sun IdM beginner and want to quickly and logically understand the relationships between various components in Sun IDM, then you should take a look at this:
    http://objectsource.com/blogs/2010/02/understanding-sun-idm-using-uml/
    You can also download all the UML diagrams from there.
    For those of you who understand UML, you definitely know a UML class diagram is a picture worth 1000 words.
    I never remembered all of these, so I used to carry a copy of these with me to custmer requirement and design discussions.
    Whenever customer asked details that I could not recall or was not sure, I'd pull these out as a cheatsheet to confirm and further elaborate on the design approach for the Sun IdM feature implementation.
    NOTE: I am the author of that blog as well. A little background on this post -
    I wrote the blog post a few months ago and totally forgot about it.
    A few days back, I installed wordpress site stats on my blog and I was amazed to see how many people look for Google terms "Understanding Sun IdM" and end up at my blog post.
    I thought - "Hey If it was so useful to these people, then I believe it will be useful for many more" (especially developers from Java background that have turned to Sun IdM professionals)
    Hence the post here.
    A few years back, I started using Sun IdM and was absolutely unsure where to start and what relationships exist between various components. I painfully started to understand them by going through the admin console and started drawing out these diagrams. They were sitting in my vault, but I set them free a few months back.
    Had I known what I know now, I would have released it much earlier.
    Regards,
    Srikanth Shenoy
    ObjectSource - Identity Management Professionals

    playAgain() : bool
    askBet() : int
    Payout(amt: void) : void
    takeBet(amt:void) : boolThese are methods of the "Game" class, and what is inside parentheses are called parameters.
    "void" and "bool" are return types.
    public boolean playAgain()
        }In this code you have specified boolean as a return type, so you need to return a value of type bool.
    As for the void part, you don't need to return anything.
    Code should look like:
    public boolean playAgain()
             return true; //Or return false
    public void Payout ()
             int amt;
        }You need to get :int amt" in the parameters, and since its voide nothing needs to be returned.
    public void Payout (int amt)
        }

  • How to read the Java source code (in Netbeans)

    I use OS X10.5.5, NetBeans 6.1 and JSE 6 on a 64 bit mac.
    When I downloaded NB6.1 it had JSE 5 as it's default (and only) java platform. I ran Software Update to get Java 6 from Apple, used the Java Prefrences utitlity to set JSE6 as default. In NB I added the JDK6 platform, registered the JDK6 javadocs and noticed that I also have the option of registering the Java source code.
    I have three questions:
    1) How do I make JDK6 the default in NetBeans. The JDK5 keeps being default after I did the steps above and I don't see anywhere to change that.
    2) How do I read the Java 6 source code? I can see sun provides [source code| http://download.java.net/jdk6/] for their supported platforms. I dont see Apple doing the same for its JDK port. What would I need to do to get to read the java SE6 sources? or is it actually hiding somewhere in the /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home hierarchy?
    3) Where does the JVM look for the binary code to run when I make a call to, say java.util.ArrayList or any other library. In my naivety I would have assumed it would be a .class file somewhere in the java Home folder, but I don't see anything like it.
    thanks in advance,
    chris

    This is taken from the help included with netbeans. In response to question 1.
    By default, the IDE uses the version of the Java SE platform (JDK) with which the IDE runs as the default Java platform
    for compilation, execution, and debugging. You can view your IDE's JDK version by choosing Help > About and clicking the
    Detail tab. The JDK version is listed in the Java field.
    You can run the IDE with a different JDK version by starting the IDE with the --jdkhome jdk-home-dir switch on the command line
    or in your IDE-HOME/etc/netbeans.conf file. For more information, see IDE Startup Parameters.
    In the IDE, you can register multiple Java platforms and attach Javadoc and source code to each platform. For example, if you
    want to work with the new features introduced in JDK 5.0, you would either run the IDE on JDK 5.0 or register JDK 5.0 as a
    platform and attach the source code and Javadoc to the platform.
    In  , you can switch the target JDK in the Project Properties dialog box. In  , you have to set the target JDK in the Ant script itself,
    then specify the source/binary format in the Project Properties dialog box.
    To register a new Java platform:
    Choose Tools > Java Platforms from the main window.
    Click New Platform and select the directory that contains the Java platform. Java platform directories are marked with a  
    in the file chooser.
    Use the Sources and Javadoc tabs to attach Javadoc documentation and source code for debugging to the platform.
    Click Close.
    To set the default Java platform for a standard project:
    Right-click the project's root node in the Projects window and choose Properties.
    In the Project Properties dialog box, select the Libraries node in the left pane.
    Choose the desired Java platform in the Java Platform combo box.
    Switching the target JDK for a standard project does the following:
    Offers the new target JDK's classes for code completion.
    If available, displays the target JDK's source code and Javadoc documentation.
    Uses the target JDK's executables (javac and java) to compile and execute your application.
    Compiles your source code against the target JDK's libraries.
    If you want to register additional Java platforms with the IDE, you can do so by clicking the Manage Platforms button.
    Then click the Add Platform button and navigate to the desired platform.
    To set the target Java platform for a free-form project:
    In your Ant script, set the target JDK as desired in the javac, java, and javadoc tasks.
    Right-click the project's root node in the Projects window and choose Properties.
    In the Sources panel, set the level of JDK you want your application to be run on in the Source/Binary Format combo box.
    When you access Javadoc or source code for JDK classes, the IDE searches the Java platforms registered in the
    Java Platform Manager for a platform with a matching version number. If no matching platform is found, the IDE's default platform is used instead.
    See Also
    Managing the Classpath
    Declaring the Classpath in a Free-Form Project
    Stepping Through Your Program
    Legal Notices

  • Error in compiling java source code in a package

    hi all...
    am having a problem in compiling a java source code:
    i have a class named 'Test' in the package 'packone'....
    i have another class named 'getTest' in the same package....
    in the class getTest i am taking a reference to Test class...
    on compiling i am getting the following error....
    cannot resolve symbol
    symbol : class Test
    The source code for the two classes are :
    package packone;
    public class Test{
    and
    package packone;
    public class getTest{
    public void me(){
         Test t = new Test();
    i have included the directory path in the classpath....
    still its not compiling .....
    please help
    thanks....

    Assume the current directory structure:
    C:\
    C:\packone...and that your classes are named Test & GetTest.
    My guess is that you're compiling within the directory C:\packone using the command "javac GetTest.java", which is wrong; You must use a path corresponding to the package-name.
    Move your command-line cursor to C:\ and type "javac packone\GetTest.java" and you'll be fine...
    Regards,
      /Håkan

  • Where to find java source code on tiger?

    I'm taking a class on java, and i need to open up some of the java source code for classes like Abstractcollections and Abstractlist to see how their implementations work. Does anyone know where the java folder is located and how to open up the source on a mac? I've seen it done on windows( applications-java-java-sdk - unzip, or something like that), but it is not in the same place place on mac.
    I've searched through the folders named java but could not figure out which folder to open and how.

    Hmmm, are you trying to view the Source Code for Abstractcollections and Abstractlist, or find it, or compile it, or what exactly?
    Source code can be viewed in any text editor, but BBEdit, TextWrangler, & jEdit are really good...
    http://www.barebones.com/products/bbedit/threeway.html
    http://www.barebones.com/products/textwrangler/index.html
    http://www.jedit.org/index.php?page=download

  • Issue of Security about Java Source Code

    At most time Java compiler compiles the *.java source code into *.class files and then pack them in *.jar files running in the Java VM or as applet running on web pages.
    Recently I find a tool named cavaj that can decompile *.class files into *.java files. I tried it to decompile my *.class files and unvealed that the decompiled *.java files are the same of my source code!
    How to protect the source code not to be pirated? This is a big problem about the mechanism of Java. Is there any tool to compile *.java to *.exe files? Or is there any tool that can decompile *.exe to *.java in the future?

    This is a common question. If you do a search you will find many answers/solutions.
    But can it affect the performance of the program? Your program mayload slight faster, but the runtime performance is the same. It may effect your performance as it takes some time to get the obsufaction right, especially if you are using reflection.

  • Access Java Proposals for a java source code programmatically

    Hi,
    Problem
    Programmatically get java proposals for a java source code (not byte code) via eclipse bundle
    Description
    I am developing one eclipse osgi bundle to correct java source code automatically. I am running osgi bundle inside eclipse itself [Version: Mars Release (4.5.0)]. I am able to get java project object and a class object inside it which I want to correct. Every time I try to collect java code proposals as I put one test file which can be corrected (like duplicate imports), I receive below error:
    Java code line
    JavaCorrectionProcessor.collectCorrections(context, new IProblemLocation[] { problem }, proposals);
    Error description
    !ENTRY org.eclipse.jdt.ui 4 2 2015-07-27 18:57:09.196
    !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui".
    !STACK 0
    java.lang.IllegalStateException: Workbench has not been created yet.
    at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:93)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.install(ASTProvider.java:236)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.<init>(ASTProvider.java:227)
    at org.eclipse.jdt.internal.ui.JavaPlugin.getASTProvider(JavaPlugin.java:741)
    at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128)
    at org.eclipse.jdt.internal.ui.text.correction.AssistContext.getASTRoot(AssistContext.java:119)
    at org.eclipse.jdt.internal.ui.text.correction.LocalCorrectionsSubProcessor.addUnusedMemberProposal(LocalCorrectionsSubProcessor.java:669)
    at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:530)
    at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections(QuickFixProcessor.java:316)
    at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(JavaCorrectionProcessor.java:378)
    at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.run(JavaCorrectionProcessor.java:339)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.process(JavaCorrectionProcessor.java:335)
    at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:468)

    Any code from org.eclipse.jdt.ui (or the non-API code in org.eclipse.jdt.internal.ui) is likely to require a running workbench. Only the code from org.eclipse.jdt.core is guaranteed to work headlessly.

  • Trouble with UML class diagram...

    i understand tha in a UML class diagram: + thing : int would translate to java like this: public int thing;but what would + thing(int,int) translate into?

    + thing : intmeans that 'thing' is a public instance variable with type int.
    + thing(int, int) : intmeans that 'thing()' is a public instance method that takes 2 int arguments and returns an int.

Maybe you are looking for

  • Collections in a function

    I have a funcpacka.func1 (a function in a package), funcpacka.collection ( a collection in a package) and procpackb.proc1 ( a procedure in a package) from sqlplus when i call procpackb.proc1 it tries to populate funcpacka.collection and later when i

  • Copy pasting web address into emails on iPad

    I use to be all to be looking at a web page and select all, copy, and then paste the URL in an email on my iPad. When I do it now when I paste nothing shows up. How can I copy and then paste URL in my email. Thanks Rick

  • Safari multiple windows on ipad

    When you have multiple windows/screens open in Safari they insist on refreshing when swapping between them. This can be both slow and data intensive. It also is not how Safari behaves on a normal computer. Any way to turn off?

  • Java on Its Way

    I've been learning Java for 3 months and I want it to be my whole new world. I'm trying to get a job in Indonesia EuronetWorld. They need Java Wireless programmer. I want to learn about it but where to start? I only got right now is JAVA 2 Weekend Cr

  • DTP Requests-Creating Mail Alert

    Hi Gurus, I want to trigger a mail alert for the requests in the particular infocube. Conditions should be, 1) Info Cube should contain only 4 requests. Among 4, 2 requests(long loads) were loaded once in a month and remaining 2 (short loads) were lo