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

Last change on this file since 1127 was 1127, checked in by pharms, 11 years ago
  • complete refactoring of task detection
  • many performance improvements in task detection
  • improved merging of sequences using Myers diff algorithm
File size: 3.0 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.ISequence;
18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder;
19import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory;
21
22/**
23 * <p>
24 * TODO comment
25 * </p>
26 *
27 * @author Patrick Harms
28 */
29class RuleUtils {
30   
31    /** */
32    private static int idCounter = 0;
33
34    /**
35     *
36     */
37    static ISequence getSubSequenceInRange(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(i));
51        }
52
53        return sequence;
54    }
55
56    /**
57     *
58     */
59    static ISequence createNewSubSequenceInRange(ITaskTreeNode         parent,
60                                                 int                   startIndex,
61                                                 int                   endIndex,
62                                                 String                description,
63                                                 ITaskTreeNodeFactory  nodeFactory,
64                                                 ITaskTreeBuilder      builder)
65    {
66        ISequence sequence = nodeFactory.createNewSequence();
67        if (description != null) {
68            builder.setDescription(sequence, description);
69        }
70
71        for (int i = startIndex; i <= endIndex; i++) {
72            builder.addChild(sequence, parent.getChildren().get(startIndex));
73            builder.removeChild((ISequence) parent, startIndex);
74        }
75
76        builder.addChild((ISequence) parent, startIndex, sequence);
77
78        return sequence;
79    }
80
81    /**
82     *
83     */
84    static synchronized String getNewId() {
85        return Integer.toString(idCounter++);
86    }
87
88    /**
89     *
90     */
91    private RuleUtils() {
92        // prevent instantiation
93    }
94
95}
Note: See TracBrowser for help on using the repository browser.