source: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/utils/DebuggingHelper.java @ 1852

Last change on this file since 1852 was 1852, checked in by pharms, 10 years ago
  • added for debugging purposes --> may be removed later
File size: 2.8 KB
Line 
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
15package de.ugoe.cs.autoquest.tasktrees.temporalrelation.utils;
16
17import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;
18import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance;
19import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
20import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional;
21import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;
22import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
23import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
24
25/**
26 * <p>
27 * TODO comment
28 * </p>
29 *
30 * @author Patrick Harms
31 */
32public class DebuggingHelper {
33
34    /**
35     *
36     */
37    public static String toPlainStr(ITask task) {
38        StringBuffer result = new StringBuffer();
39        toPlainStr(task, result);
40        return result.toString();
41    }
42
43    /**
44     *
45     */
46    public static void toPlainStr(ITask task, StringBuffer result) {
47        if (task instanceof IEventTask) {
48            IEventTaskInstance eventTaskInstance =
49                (IEventTaskInstance) task.getInstances().iterator().next();
50            result.append(eventTaskInstance.getEvent().getType().getName());
51            result.append(" on ");
52            result.append(eventTaskInstance.getEvent().getTarget());
53        }
54        else if (task instanceof ISequence) {
55            result.append("sequence (");
56
57            for (ITask child : ((ISequence) task).getChildren()) {
58                toPlainStr(child, result);
59                result.append(", ");
60            }
61
62            result.append(")");
63        }
64        else if (task instanceof ISelection) {
65            result.append("selection (");
66
67            for (ITask child : ((ISelection) task).getChildren()) {
68                toPlainStr(child, result);
69                result.append(", ");
70            }
71
72            result.append(")");
73        }
74        else if (task instanceof IIteration) {
75            result.append("iteration (");
76            toPlainStr(((IIteration) task).getMarkedTask(), result);
77            result.append(")");
78        }
79        else if (task instanceof IOptional) {
80            result.append("optional (");
81            toPlainStr(((IOptional) task).getMarkedTask(), result);
82            result.append(")");
83        }
84    }
85}
Note: See TracBrowser for help on using the repository browser.