[1107] | 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.temporalrelation; |
---|
| 16 | |
---|
[1146] | 17 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
| 18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; |
---|
| 19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; |
---|
| 20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; |
---|
| 21 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; |
---|
[1107] | 22 | |
---|
| 23 | /** |
---|
| 24 | * <p> |
---|
| 25 | * TODO comment |
---|
| 26 | * </p> |
---|
| 27 | * |
---|
| 28 | * @author Patrick Harms |
---|
| 29 | */ |
---|
| 30 | class RuleUtils { |
---|
| 31 | |
---|
| 32 | /** */ |
---|
| 33 | private static int idCounter = 0; |
---|
| 34 | |
---|
| 35 | /** |
---|
| 36 | * |
---|
| 37 | */ |
---|
[1146] | 38 | static ITaskInstance getSubSequenceInRange(ITaskInstanceList parent, |
---|
| 39 | int startIndex, |
---|
| 40 | int endIndex, |
---|
| 41 | ITask model, |
---|
| 42 | ITaskFactory taskFactory, |
---|
| 43 | ITaskBuilder taskBuilder) |
---|
[1127] | 44 | { |
---|
[1146] | 45 | ITaskInstance subsequence = taskFactory.createNewTaskInstance(model); |
---|
[1127] | 46 | |
---|
| 47 | for (int i = startIndex; i <= endIndex; i++) { |
---|
[1146] | 48 | taskBuilder.addChild(subsequence, parent.get(i)); |
---|
[1127] | 49 | } |
---|
| 50 | |
---|
[1146] | 51 | return subsequence; |
---|
[1127] | 52 | } |
---|
| 53 | |
---|
| 54 | /** |
---|
| 55 | * |
---|
| 56 | */ |
---|
[1146] | 57 | static ITaskInstance createNewSubSequenceInRange(ITaskInstanceList parent, |
---|
| 58 | int startIndex, |
---|
| 59 | int endIndex, |
---|
| 60 | ITask model, |
---|
| 61 | ITaskFactory taskFactory, |
---|
| 62 | ITaskBuilder taskBuilder) |
---|
[1107] | 63 | { |
---|
[1146] | 64 | ITaskInstance subsequence = taskFactory.createNewTaskInstance(model); |
---|
[1107] | 65 | |
---|
| 66 | for (int i = startIndex; i <= endIndex; i++) { |
---|
[1146] | 67 | taskBuilder.addChild(subsequence, parent.get(startIndex)); |
---|
| 68 | taskBuilder.removeTaskInstance(parent, startIndex); |
---|
[1107] | 69 | } |
---|
| 70 | |
---|
| 71 | |
---|
[1146] | 72 | taskBuilder.addTaskInstance(parent, startIndex, subsequence); |
---|
| 73 | |
---|
| 74 | return subsequence; |
---|
[1107] | 75 | } |
---|
| 76 | |
---|
| 77 | /** |
---|
| 78 | * |
---|
| 79 | */ |
---|
[1127] | 80 | static synchronized String getNewId() { |
---|
[1107] | 81 | return Integer.toString(idCounter++); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | /** |
---|
| 85 | * |
---|
| 86 | */ |
---|
| 87 | private RuleUtils() { |
---|
| 88 | // prevent instantiation |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | } |
---|