Sparx Systems Forum

Enterprise Architect => Uml Process => Topic started by: jeshaw2 on March 14, 2005, 12:39:08 pm

Title: Diagramming Nested Classes
Post by: jeshaw2 on March 14, 2005, 12:39:08 pm
Java allows Nested classes of various types.  This includes: static and inner.   Inner classes are further classified as member, local, and anonymmous.

I'm wondering how the nesting of these classes are modeled in UML 2.0 ala EA?

For the curious, here is sample code for a Member Class:

Code: [Select]

class top {
   int i = 33;

   class my NestedMember { //member inner class
            int k = i;
            int foo() {return this.k;}
   }

   void doCalclulations() {

           myNestedMember mn1 = new myNestedMember;
           myNestedMember mn2 = new myNestedMember;
           mn1.k = 654 * mn2.foo();
    }
}


thanks
Jim
Title: Re: Diagramming Nested Classes
Post by: thomaskilian on March 15, 2005, 04:17:03 am
Try reverse engineering ;)
Title: Re: Diagramming Nested Classes
Post by: jeshaw2 on March 15, 2005, 06:16:56 am
I'd love to try reverse engineering, but my product license does not include that feature.
Title: Re: Diagramming Nested Classes
Post by: thomaskilian on March 15, 2005, 08:30:34 am
Just tried and EA refuses to import that code (error on line 4)  :-[
If you omit the "my" it imports. I can send you the XMI by mail if you wish.
Title: Re: Diagramming Nested Classes
Post by: jeshaw2 on March 15, 2005, 08:54:08 am
My appologies for lousy keying skills.  I've successfully compiled this code:

Code: [Select]

class top {
   int i = 33;

  class myNestedMember { //member inner class
      int k = i;
      int foo() {return this.k;}
  }

  void doCalclulations() {

      myNestedMember mn1 = new myNestedMember();
      myNestedMember mn2 = new myNestedMember();
      mn1.k = 654 * mn2.foo();
  }
}



I'd appreciate whatever you can mail to me.
Title: Re: Diagramming Nested Classes
Post by: Eve on March 15, 2005, 01:11:11 pm
Hi,

EA will reverse engineer inner classes and put them under the outer class in the tree.  If you need a more visual representation then use the Nesting connector that is available on the diagram. (Or both)

Ultimately, if you can't use the code engineering you don't need to worry about the constraints of what code engineering expects.

Simon