Interpretation of source code by Java-to-UML transformations

The UML elements that the transformation generates depends 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 Properties of the UML class
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 isLeaf property set to true
Specifies the abstract keyword isAbstract property set to true
Extends a superclass Generalization relationship between the class and the superclass
Implements an interface InterfaceRealization 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 Properties of the UML interface
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 isAbstract property 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 Properties of the UML enumeration
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 isLeaf property set to true
Specifies the abstract keyword isAbstract property set to true
Static import (J2SE 5.0) Usage relationship between the interface and the imported element

Java attributes in Java classes or interfaces

The following table lists how the transformation transforms Java attributes located in Java classes or interfaces.
Properties of the Java attribute Properties of the UML attribute
Name Property with the same name
Visibility Same visibility as the source Java property
Specifies the static keyword isStatic property set to true
Specifies the final keyword isLeaf property set to true
Specifies the abstract keyword isAbstract property set to true
Type (non-collection types) Type property set to an existing primitive type, existing UML element in the model, or a reference to the Java type
Type (collection types) Type property is null; set the collection properties according to the Transformation of Java collection properties table
Generic type (J2SE 5.0) Type property set to the type in the Java class or interface; set the collection properties according to the Transformation of Java collection properties table

Java properties in Java enumerations

The transformation transforms a Java property in an enumeration into a UML EnumerationLiteral 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 isStatic property set to true
Specifies the final keyword isLeaf property set to true
Parameters Parameter with same properties as the Java parameter; the transformation generates the parameters in the same order that 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 set to an existing primitive type, or an element in the model, or to a reference to a Java type
Type (collection types) Type property set to null; collection properties set according to the Transformation of Java collection properties table
Generic type (J2SE 5.0) Type property set to the type in the Java class or interface; set the collection properties according to the Transformation of Java collection properties table

UML multiplicity for properties and parameters

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

Transformation of Java collection properties

If a Java property or parameter is one of the Java types listed in the table below, the transformation generates a UML collection type with properties set to the values listed in the following table.

Default Java type Value of the isOrdered property Value of the isUnique property UML Collection type
java.util.SortedSet true true Ordered Set
java.util.List true false Sequence
java.util.Set false true Set
java.util.Collection false false Bag

Feedback