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

Last change on this file since 1285 was 1285, checked in by pharms, 11 years ago
  • improved performance of task instance trie generation by using different symbol management strategies while creating the trie. This performance improvement is significant and allows to detect tasks now in a much faster manner.
File size: 3.1 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.taskequality.TaskEquality;
18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;
19import de.ugoe.cs.autoquest.usageprofiles.DefaultSymbolMap;
20import de.ugoe.cs.autoquest.usageprofiles.SymbolComparator;
21import de.ugoe.cs.autoquest.usageprofiles.SymbolMap;
22import de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy;
23
24/**
25 * <p>
26 * TODO comment
27 * </p>
28 *
29 * @author Patrick Harms
30 */
31class TaskHandlingStrategy implements SymbolStrategy<ITaskInstance> {
32   
33    /**  */
34    private static final long serialVersionUID = 1L;
35
36    /**
37     *
38     */
39    private TaskEquality consideredEquality;
40
41    /**
42     *
43     */
44    private TaskComparator comparator;
45
46    /**
47     * <p>
48     * TODO: comment
49     * </p>
50     *
51     * @param consideredEquality
52     */
53    TaskHandlingStrategy(TaskEquality consideredEquality) {
54        this.consideredEquality = consideredEquality;
55       
56        if (this.consideredEquality == TaskEquality.IDENTICAL) {
57            comparator = new TaskIdentityComparator();
58        }
59        else {
60            comparator = new TaskComparator(this.consideredEquality);
61        }
62    }
63
64    /* (non-Javadoc)
65     * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#getSymbolComparator()
66     */
67    @Override
68    public SymbolComparator<ITaskInstance> getSymbolComparator() {
69        return comparator;
70    }
71
72    /**
73     * <p>
74     * TODO: comment
75     * </p>
76     *
77     * @return
78     */
79    public TaskComparator getTaskComparator() {
80        return comparator;
81    }
82
83    /* (non-Javadoc)
84     * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#createSymbolMap()
85     */
86    @Override
87    public <V> SymbolMap<ITaskInstance, V> createSymbolMap() {
88        if (consideredEquality == TaskEquality.IDENTICAL) {
89            return new TaskSymbolIdentityMap<V>();
90        }
91        else {
92            return new TaskSymbolBucketedMap<V>(comparator);
93        }
94    }
95
96    /* (non-Javadoc)
97     * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#copySymbolMap(de.ugoe.cs.autoquest.usageprofiles.SymbolMap)
98     */
99    @Override
100    public <V> SymbolMap<ITaskInstance, V> copySymbolMap(SymbolMap<ITaskInstance, V> other) {
101        if (consideredEquality == TaskEquality.IDENTICAL) {
102            return new DefaultSymbolMap<ITaskInstance, V>(other);
103        }
104        else {
105            return new TaskSymbolBucketedMap<V>(comparator);
106        }
107    }
108
109}
Note: See TracBrowser for help on using the repository browser.