1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
2 | // |
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
4 | // you may not use this file except in compliance with the License. |
---|
5 | // You may obtain a copy of the License at |
---|
6 | // |
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
8 | // |
---|
9 | // Unless required by applicable law or agreed to in writing, software |
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
12 | // See the License for the specific language governing permissions and |
---|
13 | // limitations under the License. |
---|
14 | |
---|
15 | package de.ugoe.cs.autoquest.tasktrees.treeifc; |
---|
16 | |
---|
17 | /** |
---|
18 | * <p> |
---|
19 | * Default implementation for a task visitor performing a traversal of the task |
---|
20 | * </p> |
---|
21 | * |
---|
22 | * @author Patrick Harms |
---|
23 | */ |
---|
24 | public class DefaultTaskTraversingVisitor implements ITaskVisitor { |
---|
25 | |
---|
26 | /* |
---|
27 | * (non-Javadoc) |
---|
28 | * |
---|
29 | * @see |
---|
30 | * de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(IEventTask) |
---|
31 | */ |
---|
32 | @Override |
---|
33 | public void visit(IEventTask eventTask) { |
---|
34 | // do nothing |
---|
35 | } |
---|
36 | |
---|
37 | /* |
---|
38 | * (non-Javadoc) |
---|
39 | * |
---|
40 | * @see |
---|
41 | * de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(IIteration) |
---|
42 | */ |
---|
43 | @Override |
---|
44 | public void visit(IIteration iteration) { |
---|
45 | visit((IMarkingTemporalRelationship) iteration); |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * <p> |
---|
50 | * common implementation for traversing a marking temporal relationship |
---|
51 | * </p> |
---|
52 | * |
---|
53 | * @param relationship |
---|
54 | * the marking temporal relationship to be traversed |
---|
55 | */ |
---|
56 | public void visit(IMarkingTemporalRelationship relationship) { |
---|
57 | if (relationship.getMarkedTask() != null) { |
---|
58 | relationship.getMarkedTask().accept(this); |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | /* |
---|
63 | * (non-Javadoc) |
---|
64 | * |
---|
65 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(IOptional) |
---|
66 | */ |
---|
67 | @Override |
---|
68 | public void visit(IOptional optional) { |
---|
69 | visit((IMarkingTemporalRelationship) optional); |
---|
70 | } |
---|
71 | |
---|
72 | /* |
---|
73 | * (non-Javadoc) |
---|
74 | * |
---|
75 | * @see |
---|
76 | * de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(ISelection) |
---|
77 | */ |
---|
78 | @Override |
---|
79 | public void visit(ISelection selection) { |
---|
80 | visit((IStructuringTemporalRelationship) selection); |
---|
81 | } |
---|
82 | |
---|
83 | /* |
---|
84 | * (non-Javadoc) |
---|
85 | * |
---|
86 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(ISequence) |
---|
87 | */ |
---|
88 | @Override |
---|
89 | public void visit(ISequence sequence) { |
---|
90 | visit((IStructuringTemporalRelationship) sequence); |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | * <p> |
---|
95 | * common implementation for traversing a structuring temporal relationship |
---|
96 | * </p> |
---|
97 | * |
---|
98 | * @param relationship |
---|
99 | * the structuring temporal relationship to be traversed |
---|
100 | */ |
---|
101 | public void visit(IStructuringTemporalRelationship relationship) { |
---|
102 | for (final ITask child : relationship.getChildren()) { |
---|
103 | child.accept(this); |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | /* |
---|
108 | * (non-Javadoc) |
---|
109 | * |
---|
110 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(ITask) |
---|
111 | */ |
---|
112 | @Override |
---|
113 | public void visit(ITask task) { |
---|
114 | if (task instanceof IEventTask) { |
---|
115 | visit((IEventTask) task); |
---|
116 | } else if (task instanceof IIteration) { |
---|
117 | visit((IIteration) task); |
---|
118 | } else if (task instanceof IOptional) { |
---|
119 | visit((IOptional) task); |
---|
120 | } else if (task instanceof ISelection) { |
---|
121 | visit((ISelection) task); |
---|
122 | } else if (task instanceof ISequence) { |
---|
123 | visit((ISequence) task); |
---|
124 | } |
---|
125 | } |
---|
126 | } |
---|