|
Tracing Constraints
[Previous]  [Next] 
|
![]() |
User Manual [Previous]  [Next] Tracing Constraints
Constraints can be imposed upon the traced UML entity to limit the scope of tracing to when a certain condition is true. MOTL provides a set of constraints that can be classified into a prefix and postfix constraints.
Conditions and Number of Occurences
@SuppressWarnings("deprecation")
class Student
{
name;
Integer id;
// trace code is injected in attribute setter
// with specified precondition
trace name where [name == "john"];
// trace code is injected in attribute setter
// with specified postcondition
trace id giving [id > 9000];
// this example traces attribute name whenever
// its value is changed for 5 times
trace name for 5;
}
@SuppressWarnings("deprecation")
class Professor {
name;
1 -- * Student supervisor;
// trace code is injected in attribute setter
// with role name cardinality condition
trace name where [ supervisor cardinality > 10];
}
Load the above code into UmpleOnline Record Clause
@SuppressWarnings("deprecation")
class Student
{
name;
Integer id;
// trace attribute id and record provided string
// message as part of the trace output
trace id record "i am tracing attribute id";
status {
s1 { e1 -> s2; }
s2 {}
}
// trace whenever we enter/exit state "s1" and
// record attribute name
trace s1 record name;
}
Load the above code into UmpleOnline Life Timeline
@SuppressWarnings("deprecation")
class Student
{
name;
Integer id;
// tracing of attribute name starts and doesn't
// stop until condition becomes true
trace name until [name == "john"];
// tracing of attribute id until condition
// becomes true and then always continue tracing
trace id after [id == 234];
}
Load the above code into UmpleOnline Syntax// A constraint is an expression optionally be surrounded in round brackets or negated constraint- : [[constraintBody]] [[linkingOp]]? | [[constraintExpr]] [[linkingOp]]? traceCondition : [=conditionType:where|until|after|giving]? [ [[constraintToken]] ] traceFor- : for [traceFor] |