Java Roundtrip Engineering

  SourceForge Logo




Here is the design and development information presented. If you want to comment anything on this page, or contribute any ideas, please do this in the JavaRE Open Forum at SourceForge.

  • Associations and Attributes
  • Modeling arrays
  • CVS
  • MagicDraw
  • Modeling Arrays

    Below I will describe how I will solve the reverse engineering of (multidimensional) arrays. In UML, it is possible to describe one dimensional multiplicies. A one dimensional array in Java will be modeled like this:

      ---------                ----------
      |   A   |        names m | String |
      |       |--------------->|        |
      |       | 1              |        |
      ---------                ----------
      class A {
        String[] names;

    The problem arrives when we are going to model multidimensional arrays. A two dimensional array will be modeled like this:

      ---------            ------------            ----------
      |   A   |    names m | String[] |    parts n | String |
      |       |----------->|          |----------->|        |
      |       | 1          |          | 1          |        |
      ---------            ------------            ----------
      class A {
        String[][] names;

    A new DataType/Class will have to be constructed to be able to model a multidimensional array.

    It is not possible to know how many elements the array will contain at runtime, that is why the multiplicity is modeled as m or n. If the designer knows how many elements there is, he can model this as e.g. 2 if there is two elements in the array. The code generated will still be the same. It is not ok to model the multiplicity of an array as 0..*, since this will be generated as a Vector by the code generator.



    Further work postponed. See introduction page.