-
Notifications
You must be signed in to change notification settings - Fork 8
/
Behaviour.java
92 lines (76 loc) · 2.49 KB
/
Behaviour.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import java.io.*;
/* package: Class Diagram */
/******************************
* Copyright (c) 2003--2021 Kevin Lano
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
* *****************************/
public class Behaviour
{ Entity behaviouredClassifier = null;
BehaviouralFeature specification = null;
UseCase uc = null;
/* A behaviour is the activity for exactly one of these three kinds of model element */
Statement code;
public Behaviour(Entity ent, Statement cde)
{ behaviouredClassifier = ent;
code = cde;
}
public Behaviour(Entity owner, BehaviouralFeature bf, Statement cde)
{ behaviouredClassifier = owner;
specification = bf;
code = cde;
}
public Behaviour(UseCase u, Statement cde)
{ uc = u;
code = cde;
}
public String getName()
{ if (behaviouredClassifier != null)
{ return behaviouredClassifier.getName(); }
else if (specification != null)
{ return specification.getName(); }
else if (uc != null)
{ return uc.getName(); }
return "application";
}
public void setUseCase(UseCase ucase)
{ uc = ucase; }
public Entity getEntity()
{ return behaviouredClassifier; }
public BehaviouralFeature getOperation()
{ return specification; }
public void saveData(PrintWriter out)
{ String opname = "null";
if (specification != null)
{ opname = specification.getName(); }
out.println("Activity:");
if (behaviouredClassifier != null)
{ out.println(behaviouredClassifier.getName() + " " + opname); }
else if (uc != null)
{ out.println(uc.getName()); }
else
{ out.println("application"); }
out.println(code);
out.println("");
}
public static void saveUseCaseActivity(String nme, Statement stat, PrintWriter out)
{
out.println("Activity:");
out.println(nme);
out.println(stat);
out.println("");
}
public String toString()
{ String res = "Activity of ";
if (behaviouredClassifier != null)
{ res = res + " classifier " + behaviouredClassifier.getName(); }
if (uc != null)
{ res = res + " use case " + uc.getName(); }
if (specification != null)
{ res = res + " of operation " + specification.getName(); }
return res + " " + code;
}
}