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 | |
---|
17 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; |
---|
18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; |
---|
19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; |
---|
20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; |
---|
21 | |
---|
22 | /** |
---|
23 | * <p> |
---|
24 | * TODO comment |
---|
25 | * </p> |
---|
26 | * |
---|
27 | * @author Patrick Harms |
---|
28 | */ |
---|
29 | class RuleUtils { |
---|
30 | |
---|
31 | /** */ |
---|
32 | private static int idCounter = 0; |
---|
33 | |
---|
34 | /** |
---|
35 | * |
---|
36 | */ |
---|
37 | static ISequence createNewSubSequenceInRange(ITaskTreeNode parent, |
---|
38 | int startIndex, |
---|
39 | int endIndex, |
---|
40 | String description, |
---|
41 | ITaskTreeNodeFactory nodeFactory, |
---|
42 | ITaskTreeBuilder builder) |
---|
43 | { |
---|
44 | ISequence sequence = nodeFactory.createNewSequence(); |
---|
45 | if (description != null) { |
---|
46 | builder.setDescription(sequence, description); |
---|
47 | } |
---|
48 | |
---|
49 | for (int i = startIndex; i <= endIndex; i++) { |
---|
50 | builder.addChild(sequence, parent.getChildren().get(startIndex)); |
---|
51 | builder.removeChild((ISequence) parent, startIndex); |
---|
52 | } |
---|
53 | |
---|
54 | builder.addChild((ISequence) parent, startIndex, sequence); |
---|
55 | |
---|
56 | return sequence; |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * |
---|
61 | */ |
---|
62 | public static synchronized String getNewId() { |
---|
63 | return Integer.toString(idCounter++); |
---|
64 | } |
---|
65 | |
---|
66 | /** |
---|
67 | * |
---|
68 | */ |
---|
69 | private RuleUtils() { |
---|
70 | // prevent instantiation |
---|
71 | } |
---|
72 | |
---|
73 | } |
---|