38 2.2 Class diagrams in Java I The static information of a class diagram can be translated directly into Java. I The code skeleton has no implemented methods. 2.2.1 Declaring Classes and Interfaces UML Java K K {abstract} abstract class K {...} << interface >> I interface I {...} class K {...}
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
382.2 Class diagrams in Java
I The static information of a class diagram can be translated directly intoJava.
I The code skeleton has no implemented methods.
2.2.1 Declaring Classes and Interfaces
UML Java
K
K{abstract}
abstract class K {...}
<< interface >>I
interface I {...}
class K {...}
39UML Java
A
B
<< interface >>I
K
class A {...}
interface I {...}
class K implements I {...}
class B extends A {...}
402.2.2 Declaring Attributes
UML Java
attribute:Type JavaType attribute;
The standard types of UML are translated as follows to Java.
UML Java
Boolean booleanInteger intReal float or doubleString String
Eingangsaktivität:Wird immer beim Eintrittin den Zustand ausgeführt;ist nicht unterbrechbar
interne Transition:Ereignis löst keinenZustandsübergang aus;entry/exit−Aktivitätenwerden nicht durchgeführt;Aktivität ist nicht unterbrechbar
Zustandsname
Ereignis/Aktivitätdo/Aktivitätexit/Aktivität
verzögertes Ereignis/defer
entry/Aktivität
do−Aktivität:Wird ausgeführt solangesich das Objekt in demangegebenen Zustandbefindet;
ist nicht unterbrechbar
Ausgangsaktivität:Wird immer beim Verlassendes Zustands ausgeführt;
ist unterbrechbar
57Example: Telephone
Bereit
Verbunden
after(1 min)
do/läuten
Klingelnd
einhängenabheben
Note:A (perhaps conditional) completion event arises if the do activity terminates onits own.
W V
X
[not B]
e
[B]do/activity
Z
58Delayed Event
Z
e/defer
An event e is stored and processed later in some state which can handle e, ifthe event e arises before in a state Z which has no outgoing e transitions.
Example: Bu↵er with one element
leer voll
put
get
get/defer put/defer
592.3.3 Hierarchical State Diagrams
A state can be refined into substates.
1. Sequential Substates
Leerlauf Rückwärts
Vorwärts
2. Gang1. Gang 3. Gangrunter
hoch
runter
hoch
vor
rück
leer
leer
I A transition in a superstate (Vorwarts) refers to a transition in the initialstate of the nested diagram (1. Gang)
I A transition from a superstate refers to a transition from a containedsubstate.
60Abstract representation of a complex state:
Leerlauf
Vorwärts
Rückwärts
vor leer
rück
leer
Remark
Complex states can be equipped with entry and exit points.
612. Parallel Substates
A B
C
E
D
Z
a
c
fail
V e
W2
W3
W1
w
I An object is in several states at the same time. Entering the superstatemeans therefore that the object is in the initial state of each region.
I The superstate will be exited if one reaches the final state in each singleregion, or there is a direct outgoing transition from a substate, or there isan outgoing transition from the superstate originating from an explicitevent.
622.3.4 Activity Diagrams
Can be used to describe the behaviour of
I business processes
I use cases
I operations and processes
An activity diagram is a directed graph which contains
Iactivity nodes: describe actions, control structures and data.