[1409] | 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 | /* (non-Javadoc) |
---|
| 27 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(IEventTask) |
---|
| 28 | */ |
---|
| 29 | @Override |
---|
| 30 | public void visit(IEventTask eventTask) { |
---|
| 31 | // do nothing |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | /* (non-Javadoc) |
---|
| 35 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(IIteration) |
---|
| 36 | */ |
---|
| 37 | @Override |
---|
| 38 | public void visit(IIteration iteration) { |
---|
| 39 | visit((IMarkingTemporalRelationship) iteration); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | /* (non-Javadoc) |
---|
| 43 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(IOptional) |
---|
| 44 | */ |
---|
| 45 | @Override |
---|
| 46 | public void visit(IOptional optional) { |
---|
| 47 | visit((IMarkingTemporalRelationship) optional); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | /* (non-Javadoc) |
---|
| 51 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(ISelection) |
---|
| 52 | */ |
---|
| 53 | @Override |
---|
| 54 | public void visit(ISelection selection) { |
---|
| 55 | visit((IStructuringTemporalRelationship) selection); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | /* (non-Javadoc) |
---|
| 59 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(ISequence) |
---|
| 60 | */ |
---|
| 61 | @Override |
---|
| 62 | public void visit(ISequence sequence) { |
---|
| 63 | visit((IStructuringTemporalRelationship) sequence); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /* (non-Javadoc) |
---|
| 67 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor#visit(ITask) |
---|
| 68 | */ |
---|
| 69 | @Override |
---|
| 70 | public void visit(ITask task) { |
---|
| 71 | if (task instanceof IEventTask) { |
---|
| 72 | visit((IEventTask) task); |
---|
| 73 | } |
---|
| 74 | else if (task instanceof IIteration) { |
---|
| 75 | visit((IIteration) task); |
---|
| 76 | } |
---|
| 77 | else if (task instanceof IOptional) { |
---|
| 78 | visit((IOptional) task); |
---|
| 79 | } |
---|
| 80 | else if (task instanceof ISelection) { |
---|
| 81 | visit((ISelection) task); |
---|
| 82 | } |
---|
| 83 | else if (task instanceof ISequence) { |
---|
| 84 | visit((ISequence) task); |
---|
| 85 | } |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | /** |
---|
| 89 | * <p> |
---|
| 90 | * common implementation for traversing a structuring temporal relationship |
---|
| 91 | * </p> |
---|
| 92 | * |
---|
| 93 | * @param relationship the structuring temporal relationship to be traversed |
---|
| 94 | */ |
---|
| 95 | public void visit(IStructuringTemporalRelationship relationship) { |
---|
| 96 | for (ITask child : relationship.getChildren()) { |
---|
| 97 | child.accept(this); |
---|
| 98 | } |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | /** |
---|
| 102 | * <p> |
---|
| 103 | * common implementation for traversing a marking temporal relationship |
---|
| 104 | * </p> |
---|
| 105 | * |
---|
| 106 | * @param relationship the marking temporal relationship to be traversed |
---|
| 107 | */ |
---|
| 108 | public void visit(IMarkingTemporalRelationship relationship) { |
---|
| 109 | if (relationship.getMarkedTask() != null) { |
---|
| 110 | relationship.getMarkedTask().accept(this); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | } |
---|