source: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java @ 1146

Last change on this file since 1146 was 1146, checked in by pharms, 11 years ago
  • complete refactoring of task tree model with a separation of task models and task instances
  • appropriate adaptation of task tree generation process
  • appropriate adaptation of commands and task tree visualization
File size: 2.9 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;
16
17import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder;
19import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;
20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList;
21import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;
22
23/**
24 * <p>
25 * TODO comment
26 * </p>
27 *
28 * @author Patrick Harms
29 */
30class RuleUtils {
31   
32    /** */
33    private static int idCounter = 0;
34
35    /**
36     *
37     */
38    static ITaskInstance getSubSequenceInRange(ITaskInstanceList parent,
39                                               int               startIndex,
40                                               int               endIndex,
41                                               ITask             model,
42                                               ITaskFactory      taskFactory,
43                                               ITaskBuilder      taskBuilder)
44    {
45        ITaskInstance subsequence = taskFactory.createNewTaskInstance(model);
46
47        for (int i = startIndex; i <= endIndex; i++) {
48            taskBuilder.addChild(subsequence, parent.get(i));
49        }
50
51        return subsequence;
52    }
53
54    /**
55     *
56     */
57    static ITaskInstance createNewSubSequenceInRange(ITaskInstanceList parent,
58                                                     int               startIndex,
59                                                     int               endIndex,
60                                                     ITask             model,
61                                                     ITaskFactory      taskFactory,
62                                                     ITaskBuilder      taskBuilder)
63    {
64        ITaskInstance subsequence = taskFactory.createNewTaskInstance(model);
65
66        for (int i = startIndex; i <= endIndex; i++) {
67            taskBuilder.addChild(subsequence, parent.get(startIndex));
68            taskBuilder.removeTaskInstance(parent, startIndex);
69        }
70
71
72        taskBuilder.addTaskInstance(parent, startIndex, subsequence);
73
74        return subsequence;
75    }
76
77    /**
78     *
79     */
80    static synchronized String getNewId() {
81        return Integer.toString(idCounter++);
82    }
83
84    /**
85     *
86     */
87    private RuleUtils() {
88        // prevent instantiation
89    }
90
91}
Note: See TracBrowser for help on using the repository browser.