Book a Demo

Author Topic: importing java class files to use for inheritance  (Read 5509 times)

brownale2k

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
importing java class files to use for inheritance
« on: March 07, 2006, 08:35:17 am »
I have been using 'Set Element Parent', typing in java.io.File to show that my class inherits from that Java class.  How can I configure EA so that I can import the real java classes and then have my class automatically inherit the java methods so that they are available in the 'operations' portion of the class?

Right now, I have to create a my own java.io.File class as a placeholder and add the operations that I need, but would like to somehow import real java classes to automatically get the required operations.  

a.  Can EA do this?

b.  If possible to automatically add Java classes to EA, is there a way to manually exclude the java namespace elements from the list of all classes when necessary? (Because Java has a ton of classes, it would be hard to find my classes if I always have to step through a list that contains both my operations and Java's operations.)

Appreciate any suggestions on how to get at java.lang classes operations without having to type them in myself.

thomaskilian

  • Guest
Re: importing java class files to use for inherita
« Reply #1 on: March 07, 2006, 12:43:45 pm »
I'm not a Java guy but remeber this has been posted here.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: importing java class files to use for inherita
« Reply #2 on: March 07, 2006, 01:18:27 pm »
a. EA can import the JDK from either source or jar files.  Once you've done that and generalize a class from the JDK you get access to all its members.

b. If you import the JDK into a different root package (See namespaces) from your source code then the Select Classifier dialog allows you to filter by namespace.

wdchilders

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: importing java class files to use for inherita
« Reply #3 on: March 07, 2006, 02:02:24 pm »
Because Java is so large, when you do the imports, break the language up into multiple groups (EA packages) and namespaces.  For example there are some core language packages everyone always uses like java.lang, java.io and java.util.  Others are associated with GUI or Java EE or other more specialized development.

By creating mulitple packages and exporting them, you can then import only the ones you need into your project.  That will greatly improve EA's performance especially at start up.  
Bill Childers

Very often, people confuse simple with simplistic. The nuance is lost on most.
-   Clement Mok

brownale2k

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: importing java class files to use for inherita
« Reply #4 on: March 14, 2006, 08:20:46 am »
Great ideas...I've imported subsets of java into EA and put them into an appropriate namespace so they don't mix in with my own EA objects.  

In the imported java code, the automatically-created diagrams show each interface and base class in the top right corner.  These are shown on class diagrams with the full package path (e.g., java.io.File) and all realized interfaces listed in the top right corner.  Cool!


Now to my questions.  I created my own class, and extended from java.io.File and implemented java.lang.Comparable.  I did this by right-clicking on the class and choosing Advanced Settings ...Element Parent and selected both classes.

Problem 1: Only the first one that I select shows up in my class diagram in the top right corner.  I would like all of the realized classes to show up in the right corner.  (I know this is possible because the auto import of the java classes shows parent and all implemented interfaces.)  Is there some setting I need to change to have EA show all realized interfaces in the top right corner and not just the first?

Problem 2:  How to get "File" to be "java.io.File"
-------------
After auto-importing the java.io class, I can now choose "File" from the list of classifiers that I want to inherit from.  On my diagram it only shows "File" instead of "java.io.File".  In the resultant generated code, it only imports  "io.File" instead of  "java.io.File".  Anyone know how to get full package path instead of just the last two when the code is generated?

Thanks for any ideas....

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: importing java class files to use for inherita
« Reply #5 on: March 14, 2006, 12:59:51 pm »
1. There is a different notation for realised interfaces that can't really be shown until the link is actually created.  To show them try right clicking on a class and selecting Add Embedded | Show Realized Interfaces.

Realized interfaces that don't have a link in the model do show up in the corner because EA can't show them in this style.  It looks like your classes haven't been linked correctly.

One possible reason is that your class was imported before java.io.File and used the full namespace path.  (As opposed to defining the import first.)  If you re-import your class the proper relationships should be created.

2. Namespace qualification doesn't show up on diagrams in this context, so I'd suggest making a feature request or accepting that display.

With regards to the code generation, it sounds like your 'java' package is set as a namespace root.  You need to clear that namespace and set the package above as a namespace root.  I would suggest re-reading the documentation of this at http://www.sparxsystems.com.au/EAUserGuide/index.html?namespaces.htm.

kimballjohnson

  • EA User
  • **
  • Posts: 42
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: importing java class files to use for inherita
« Reply #6 on: March 29, 2006, 11:47:16 pm »
Hello,

I was reading this series of posts and need some further explanation.

I would like to follow this same process with the .NET framework.

When you say 'import' the class and 'import' the java jar files are you speaking of reverse engineering?

When you say export and import the package are you speaking of XMI?

Your explanation of having to get the package above the java.io.file package in order to have the full namespace 'java.io.file' available indicates that the use of the word 'root' in EA means the 'dot' before the root-iest name. Is this consistent in EA?

Thanks,

Kimball

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: importing java class files to use for inherita
« Reply #7 on: March 30, 2006, 03:17:25 pm »
EA is able to import classes from java and .Net compiled code.  It is in essence a form of reverse engineering, but works differently from source code reverse engineering.  You can do this for the .Net framework by selecting Source Code Engineering | Import Binary Module from the Project menu.

Packages are transferred between models using XMI.

The 'namespace root', property of a package represents that it corresponds to the root level namespace.  It is the same namespace that contains the JDK 'java' package and the .Net 'System' package.  Any packages below a root package generate a namespace in code.  This is consistent across EA.