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 | // TODO: Auto-generated Javadoc |
---|
18 | /** |
---|
19 | * <p> |
---|
20 | * Default implementation for a task visitor performing a traversal of the task |
---|
21 | * </p>. |
---|
22 | * |
---|
23 | * @author Patrick Harms |
---|
24 | */ |
---|
25 | public class DefaultTaskTraversingVisitor implements ITaskVisitor { |
---|
26 | |
---|
27 | /* |
---|
28 | * (non-Javadoc) |
---|
29 | * |
---|
30 | * @see |
---|
31 | * de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(IEventTask) |
---|
32 | */ |
---|
33 | @Override |
---|
34 | public void visit(IEventTask eventTask) { |
---|
35 | // do nothing |
---|
36 | } |
---|
37 | |
---|
38 | /* |
---|
39 | * (non-Javadoc) |
---|
40 | * |
---|
41 | * @see |
---|
42 | * de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(IIteration) |
---|
43 | */ |
---|
44 | @Override |
---|
45 | public void visit(IIteration iteration) { |
---|
46 | visit((IMarkingTemporalRelationship) iteration); |
---|
47 | } |
---|
48 | |
---|
49 | /** |
---|
50 | * <p> |
---|
51 | * common implementation for traversing a marking temporal relationship |
---|
52 | * </p>. |
---|
53 | * |
---|
54 | * @param relationship 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 the structuring temporal relationship to be traversed |
---|
99 | */ |
---|
100 | public void visit(IStructuringTemporalRelationship relationship) { |
---|
101 | for (final ITask child : relationship.getChildren()) { |
---|
102 | child.accept(this); |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | /* |
---|
107 | * (non-Javadoc) |
---|
108 | * |
---|
109 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(ITask) |
---|
110 | */ |
---|
111 | @Override |
---|
112 | public void visit(ITask task) { |
---|
113 | if (task instanceof IEventTask) { |
---|
114 | visit((IEventTask) task); |
---|
115 | } else if (task instanceof IIteration) { |
---|
116 | visit((IIteration) task); |
---|
117 | } else if (task instanceof IOptional) { |
---|
118 | visit((IOptional) task); |
---|
119 | } else if (task instanceof ISelection) { |
---|
120 | visit((ISelection) task); |
---|
121 | } else if (task instanceof ISequence) { |
---|
122 | visit((ISequence) task); |
---|
123 | } |
---|
124 | } |
---|
125 | } |
---|