Skip to content

Commit 29d7a6b

Browse files
committed
Moved checkAllParents to Value. (OMG Issue FUML13-25)
1 parent 025aa64 commit 29d7a6b

4 files changed

Lines changed: 47 additions & 88 deletions

File tree

org.modeldriven.fuml/src/main/java/fUML/Semantics/Actions/BasicActions/ActionActivation.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Initial version copyright 2008 Lockheed Martin Corporation, except
44
* as stated in the file entitled Licensing-Information.
55
*
6-
* All modifications copyright 2009-2015 Data Access Technologies, Inc.
6+
* All modifications copyright 2009-2017 Data Access Technologies, Inc.
77
*
88
* Licensed under the Academic Free License version 3.0
99
* (http://www.opensource.org/licenses/afl-3.0.php), except as stated
@@ -424,25 +424,4 @@ public fUML.Semantics.Classes.Kernel.BooleanValue makeBooleanValue(
424424
.evaluate(booleanLiteral));
425425
} // makeBooleanValue
426426

427-
public boolean checkAllParents(fUML.Syntax.Classes.Kernel.Classifier type,
428-
fUML.Syntax.Classes.Kernel.Classifier classifier) {
429-
// Check if the given classifier matches any of the direct or indirect
430-
// ancestors of a given type.
431-
432-
ClassifierList directParents = type.general;
433-
boolean matched = false;
434-
int i = 1;
435-
while (!matched & i <= directParents.size()) {
436-
Classifier directParent = directParents.getValue(i - 1);
437-
if (directParent == classifier) {
438-
matched = true;
439-
} else {
440-
matched = this.checkAllParents(directParent, classifier);
441-
}
442-
i = i + 1;
443-
}
444-
445-
return matched;
446-
} // checkAllParents
447-
448427
} // ActionActivation

org.modeldriven.fuml/src/main/java/fUML/Semantics/Actions/CompleteActions/ReadIsClassifiedObjectActionActivation.java

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Initial version copyright 2008 Lockheed Martin Corporation, except
44
* as stated in the file entitled Licensing-Information.
55
*
6-
* All modifications copyright 2009-2015 Data Access Technologies, Inc.
6+
* All modifications copyright 2009-2017 Data Access Technologies, Inc.
77
*
88
* Licensed under the Academic Free License version 3.0
99
* (http://www.opensource.org/licenses/afl-3.0.php), except as stated
@@ -12,25 +12,9 @@
1212

1313
package fUML.Semantics.Actions.CompleteActions;
1414

15-
import fUML.Debug;
16-
import UMLPrimitiveTypes.*;
17-
18-
import fUML.Syntax.*;
19-
import fUML.Syntax.Classes.Kernel.*;
20-
import fUML.Syntax.CommonBehaviors.BasicBehaviors.*;
21-
import fUML.Syntax.CommonBehaviors.Communications.*;
22-
import fUML.Syntax.Activities.IntermediateActivities.*;
23-
import fUML.Syntax.Actions.BasicActions.*;
24-
import fUML.Syntax.Actions.IntermediateActions.*;
2515
import fUML.Syntax.Actions.CompleteActions.*;
2616

27-
import fUML.Semantics.*;
2817
import fUML.Semantics.Classes.Kernel.*;
29-
import fUML.Semantics.CommonBehaviors.BasicBehaviors.*;
30-
import fUML.Semantics.Activities.IntermediateActivities.*;
31-
import fUML.Semantics.Actions.BasicActions.*;
32-
import fUML.Semantics.Actions.IntermediateActions.*;
33-
import fUML.Semantics.Loci.*;
3418

3519
public class ReadIsClassifiedObjectActionActivation extends
3620
fUML.Semantics.Actions.BasicActions.ActionActivation {
@@ -49,20 +33,12 @@ public void doAction() {
4933
ReadIsClassifiedObjectAction action = (ReadIsClassifiedObjectAction) (this.node);
5034

5135
Value input = this.takeTokens(action.object).getValue(0);
52-
ClassifierList types = input.getTypes();
53-
54-
boolean result = false;
55-
int i = 1;
56-
while (!result & i <= types.size()) {
57-
Classifier type = types.getValue(i - 1);
58-
59-
if (type == action.classifier) {
60-
result = true;
61-
} else if (!action.isDirect) {
62-
result = this.checkAllParents(type, action.classifier);
63-
}
6436

65-
i = i + 1;
37+
boolean result = false;
38+
if (action.isDirect) {
39+
result = input.hasType(action.classifier);
40+
} else {
41+
result = input.isInstanceOf(action.classifier);
6642
}
6743

6844
ValueList values = new ValueList();

org.modeldriven.fuml/src/main/java/fUML/Semantics/Classes/Kernel/Value.java

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Initial version copyright 2008 Lockheed Martin Corporation, except
44
* as stated in the file entitled Licensing-Information.
55
*
6-
* All modifications copyright 2009-2012 Data Access Technologies, Inc.
6+
* All modifications copyright 2009-2017 Data Access Technologies, Inc.
77
*
88
* Licensed under the Academic Free License version 3.0
99
* (http://www.opensource.org/licenses/afl-3.0.php), except as stated
@@ -12,15 +12,8 @@
1212

1313
package fUML.Semantics.Classes.Kernel;
1414

15-
import fUML.Debug;
16-
import UMLPrimitiveTypes.*;
17-
18-
import fUML.Syntax.*;
1915
import fUML.Syntax.Classes.Kernel.*;
2016

21-
import fUML.Semantics.*;
22-
import fUML.Semantics.Loci.*;
23-
2417
public abstract class Value extends fUML.Semantics.Loci.LociL1.SemanticVisitor {
2518

2619
public abstract fUML.Syntax.Classes.Kernel.ValueSpecification specify();
@@ -97,7 +90,45 @@ public boolean hasType(fUML.Syntax.Classes.Kernel.Classifier type) {
9790

9891
return found;
9992
} // hasType
93+
94+
public boolean isInstanceOf(fUML.Syntax.Classes.Kernel.Classifier classifier) {
95+
// Check if this value has the given classifier as its type
96+
// or as an ancestor of one of its types.
97+
98+
ClassifierList types = this.getTypes();
99+
100+
boolean isInstance = this.hasType(classifier);
101+
int i = 1;
102+
while (!isInstance & i <= types.size()) {
103+
isInstance = this.checkAllParents(types.getValue(i-1), classifier);
104+
i = i + 1;
105+
}
106+
107+
return isInstance;
108+
}
109+
110+
public boolean checkAllParents(fUML.Syntax.Classes.Kernel.Classifier type,
111+
fUML.Syntax.Classes.Kernel.Classifier classifier) {
112+
// Check if the given classifier matches any of the direct or indirect
113+
// ancestors of a given type.
114+
115+
ClassifierList directParents = type.general;
116+
boolean matched = false;
117+
int i = 1;
118+
while (!matched & i <= directParents.size()) {
119+
Classifier directParent = directParents.getValue(i - 1);
120+
if (directParent == classifier) {
121+
matched = true;
122+
} else {
123+
matched = this.checkAllParents(directParent, classifier);
124+
}
125+
i = i + 1;
126+
}
127+
128+
return matched;
100129

130+
}
131+
101132
public abstract String toString();
102133

103134
} // Value

org.modeldriven.fuml/src/main/java/fUML/Semantics/CommonBehaviors/Communications/SignalEventOccurrence.java

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import fUML.Semantics.Classes.Kernel.FeatureValueList;
1313
import fUML.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
1414
import fUML.Semantics.CommonBehaviors.BasicBehaviors.ParameterValueList;
15-
import fUML.Syntax.Classes.Kernel.Classifier;
16-
import fUML.Syntax.Classes.Kernel.ClassifierList;
1715
import fUML.Syntax.CommonBehaviors.Communications.SignalEvent;
1816

1917
public class SignalEventOccurrence extends EventOccurrence {
@@ -28,36 +26,11 @@ public boolean match(fUML.Syntax.CommonBehaviors.Communications.Trigger trigger)
2826
boolean matches = false;
2927
if(trigger.event instanceof SignalEvent){
3028
SignalEvent event = (SignalEvent) trigger.event;
31-
if(event.signal == this.signalInstance.type) {
32-
matches = true;
33-
} else {
34-
matches = this.checkAllParents(this.signalInstance.type, event.signal);
35-
}
29+
matches = this.signalInstance.isInstanceOf(event.signal);
3630
}
3731
return matches;
3832
}
3933

40-
public boolean checkAllParents(fUML.Syntax.Classes.Kernel.Classifier type,
41-
fUML.Syntax.Classes.Kernel.Classifier classifier) {
42-
// Check if the given classifier matches any of the direct or indirect
43-
// ancestors of a given type.
44-
45-
ClassifierList directParents = type.general;
46-
boolean matched = false;
47-
int i = 1;
48-
while (!matched & i <= directParents.size()) {
49-
Classifier directParent = directParents.getValue(i - 1);
50-
if (directParent == classifier) {
51-
matched = true;
52-
} else {
53-
matched = this.checkAllParents(directParent, classifier);
54-
}
55-
i = i + 1;
56-
}
57-
58-
return matched;
59-
}
60-
6134
@Override
6235
public fUML.Semantics.CommonBehaviors.BasicBehaviors.ParameterValueList getParameterValues() {
6336
// Return parameter values for feature of the signal instance, in order.

0 commit comments

Comments
 (0)