Interpretation of source code by Java-to-UML transformations

The UML elements that the transformation generates depend on the characteristics of the Java code that you specify as the source of the transformation. If the transformation cannot transform a Java element, it ignores the element.

Java classes

The following table lists how the transformation transforms Java classes into UML classes:
Properties of the Java class Transformation output
Package Class in a package with the same name as the Java package
Name Class with the same name
Visibility Same visibility as the source Java class
Specifies the final keyword Is Leaf property is set to true
Specifies the abstract keyword Is Abstract property is set to true
Extends a superclass Generalization relationship between the class and the superclass
Implements an interface Interface realization relationship between the class and the interface
Static import (J2SE 5.0) Usage relationship between the class and the imported element

Java interfaces

The following table lists how the transformation transforms Java interfaces into UML interfaces:
Properties of the Java interface Transformation output
Package Interface in a package with the same name as the Java package
Name Interface with the same name
Visibility Same visibility as the source Java interface
Specifies the abstract keyword Is Abstract property is set to true
Extends a superinterface Generalization relationship between the interface and the superinterface
Static import (J2SE 5.0) Usage relationship between the interface and the imported element

Java enumerations

The following table lists how the transformation transforms Java enumerations into UML enumerations:
Properties of the Java enumeration Transformation output
Package Enumeration in a package with the same name as the Java package
Name Enumeration with the same name
Visibility Same visibility as the source Java enumeration
Specifies the final keyword Is Leaf property is set to true
Specifies the abstract keyword Is Abstract property is set to true
Static import (J2SE 5.0) Usage relationship between the interface and the imported element

Java fields in Java classes or interfaces

The following table lists how the transformation transforms Java fields that are located in Java classes or interfaces:
Properties of the Java attribute Transformation output
Name Property with the same name
Visibility Same visibility as the source Java property
Specifies the static keyword Is Static property is set to true
Specifies the final keyword Is Leaf property is set to true
Specifies the abstract keyword Is Abstract property is set to true
Type (non-collection types) Type property is set to an existing primitive type, a UML element in the model, or a reference to the Java type
Type (collection types) Type property is null; the transformation sets the properties of the «JavaArray» or «JavaCollection» stereotype if it can identify that the code contains a collection or array, and its type
Generic type (J2SE 5.0) Type property is set to the type in the Java class or interface; the transformation sets the properties of the «JavaArray» or «JavaCollection» stereotype if it can identify that the code contains a collection or array, and its type

Java properties in Java enumerations

The transformation transforms a Java property in an enumeration into a UML enumeration literal that has the same name.

Java methods in Java classes and interfaces

The following table lists how the transformation transforms Java methods in classes and interfaces into UML operations:

Properties of the Java method Properties of the UML operation
Name Operation with the same name
Visibility Same visibility as the source Java method
Specifies the static keyword Is Static property is set to true
Specifies the final keyword Is Leaf property is set to true
Parameters Parameter with same properties as the Java parameter; the transformation generates the parameters in the same order as they appear in the Java method

If the Java method contains a return parameter, the transformation generates the return parameter of the operation before it generates the other parameters for the operation. See the Java method parameters table.

Specifies a throws statement and one or more throwable objects RaisedException property of the UML operation specifies the exception classes in the throws statement
Tip: To view the properties of the UML operation, in the Project Explorer view, right-click the UML operation; then click UML Properties.

Java method parameters

The following table lists how the transformation transforms Java method parameters:
Java parameter UML parameter
Variable (J2SE 5.0) Multiplicity set to *
Input Direction set to in
Return Direction set to return; the generated parameter is named ReturnParameter
The following table lists how the transformation generates the properties that are common to the types of parameters listed above:
Properties of the Java method parameter Properties of the UML parameter
Name Parameter with the same name
Type (non-collection types) Type property is set to an existing primitive type, a UML element in the model, or a reference to the Java type
Type (collection types) Type property is set to null; the transformation sets the properties of the «JavaArray» or «JavaCollection» stereotype if it can identify that the code contains a collection or array, and its type
Generic type (J2SE 5.0) Type property set to the type in the Java class or interface; the transformation sets the properties of the «JavaArray» or «JavaCollection» stereotype if it can identify that the code contains a collection or array, and its type

Java comments

The transformation copies the text between the following tags into the UML documentation property for the corresponding UML element.
/**
 *<!-- begin-UML-doc -->
 * This documentation is copied into the UML documentation property for the corresponding UML element.
 *<!-- end-UML-doc -->
 */

Transformation of Java collection properties

When you run the transformation, if it can identify Java collections or arrays in the code, and identify the type of the collections or arrays, the transformation applies the «JavaCollection» or the «JavaArray» stereotype to the generated UML element and populates the values of the stereotype properties. Otherwise, the transformation generates an adaptable reference and does not apply a stereotype to the generated UML element.

The following table lists the default values that the transformation sets for the properties of UML collection types, if the transformation applies the «JavaCollection» or the «JavaArray» stereotype to the generated UML element. These values might differ if you specify different collection types in the transformation configuration. For each generated UML element, you can view the values of these properties in the Properties view, on the Advanced tab. See the UML multiplicity for properties and parameters table for more information about how the transformation sets the UML multiplicity property in generated UML elements.
Java type Generated UML type Is Ordered property Is Unique property collectionType property
java.util.Collection Bag: An unordered collection that allows duplicate elements false false java.util.Collection
java.util.List Sequence: An ordered collection that allows duplicate elements true false java.util.List
java.util.Set Set: An unordered collection that does not allow duplicate elements false true java.util.Set
java.util.SortedSet Ordered set: An ordered collection that does not allow duplicate elements true true java.util.SortedSet

UML multiplicity for properties and parameters

The following table lists how the transformation sets the multiplicity property for Java properties and parameter types that it transforms:
Java type Example UML multiplicity
Attribute String x 0..1
Array with dimensions String[3] x N, where N>1
Array without dimensions String[] x 0..*
Java collection type that is specified in the transformation configuration java.util.Set *

Java constructs that the transformation does not transform

The transformation does not transform the following Java constructs:
  • Annotations

Feedback