Newer
Older
/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
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
ludovic.apvrille AT enst.fr
This software is a computer program whose purpose is to allow the
edition of TURTLE analysis, design and deployment diagrams, to
allow the generation of RT-LOTOS or Java code from this diagram,
and at last to allow the analysis of formal validation traces
obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
from INRIA Rhone-Alpes.
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
/**
* Class AvatarSignal
* Signals in Avatar ...
* Creation: 08/04/2010
* @version 1.0 08/04/2010
* @author Ludovic APVRILLE
* @see
*/
public class AvatarSignal extends AvatarMethod {
public final static int IN = 0;
public final static int OUT = 1;
public boolean attachedToARelation;
public AvatarSignal(int _inout, String _id, String _types[], String _typeIds[]) {
super(_id, _types, _typeIds);
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
inout = _inout;
}
public static AvatarSignal isAValidSignal(String _content) {
String tmp = _content.trim();
if (!((_content.startsWith("in ")) || (_content.startsWith("out ")))) {
return null;
}
int tmpinout;
if (_content.startsWith("in ")) {
tmpinout = IN;
} else {
tmpinout = OUT;
}
return isAValidSignal(tmpinout, tmp.substring(3, tmp.length()).trim());
}
public static AvatarSignal isAValidSignal(int _inout, String _content) {
if (!((_inout == IN) || (_inout == OUT))) {
return null;
}
AvatarMethod am = isAValidMethod(_content);
if (am == null) {
TraceManager.addDev("invalid signal: " + _content);
return null;
}
AvatarSignal as = new AvatarSignal(_inout, am.getId(), am.getTypes(), am.getTypeIds());
return as;
}
public static boolean isAValidUseSignal(String _content) {
if (_content.indexOf("()") == -1) {
_content = Conversion.replaceAllString(_content, "(", "#int ");
_content = Conversion.replaceAllString(_content, "#", "(");
_content = Conversion.replaceAllString(_content, ",", "#int ");
_content = Conversion.replaceAllString(_content, "#", ",");
}
TraceManager.addDev("content:" + _content);
return (isAValidMethod(_content) != null);
}
public int getInOut() {
return inout;
}
public static String getStringInOut(int _inout) {
switch(_inout) {
case IN:
return "in";
case OUT:
default:
return "out";
}
public String toBasicString() {
return super.toString();
}
signal += super.toString();
return signal;
// Comparison on id only
public boolean equals(Object o) {
if (!(o instanceof AvatarSignal)) {
return false;
}
return getId().equals(as.getId());
// Comparison on all fields
/*public int compareTo(Object o){
if (!(o instanceof AvatarMethod)) {
return 1;
}
AvatarMethod am = (AvatarMethod)o;
if (!(getId().equals(am.getId()))) {
return 1;
}
return 0;
}*/
public AvatarSignal makeClone() {
return isAValidSignal(inout, super.toString());
}
Florian Lugou
committed
public boolean hasSamePrototype (AvatarSignal _as) {
String[] astypes = _as.getTypes();
if (astypes.length != types.length) {
return false;
}
for(int i=0; i<types.length; i++) {
if (!(types[i].compareTo(astypes[i]) == 0)) {
return false;
}
}
return true;
}
Florian Lugou
committed
public boolean isCompatibleWith(AvatarSignal _as) {
if (_as.getInOut() == getInOut()) {
return false;
}
return this.hasSamePrototype (_as);
}
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
public static String getSignalNameFromFullSignalString(String _signal) {
String signal = _signal.trim();
int index0 = signal.indexOf(" ");
if (index0 != -1) {
signal = signal.substring(index0+1, signal.length()).trim();
}
index0 = signal.indexOf("(");
if (index0 != -1) {
signal = signal.substring(0, index0).trim();
}
return signal;
}
public static int getNbOfValues(String _value) {
int index = _value.indexOf('(');
if (index == -1) {
return -1;
}
int index0 = _value.indexOf(')');
if (index0 == -1) {
return -1;
}
String val = _value.substring(index+1, index0).trim();
if (val.length() == 0) {
return 0;
}
int nbChar = Conversion.nbChar(_value, ',');
return nbChar+1;
}
public static String getValue(String _value, int _index) {
int nbOfValues = getNbOfValues(_value);
if (nbOfValues < 1) {
return null;
}
if (_index >= nbOfValues) {
return null;
}
int index0 = _value.indexOf('(');
int index1 = _value.indexOf(')');
String val = _value.substring(index0+1, index1).trim();
String [] vals = val.split(",");
return vals[_index].trim();
}
}