source: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskHandlingStrategy.java @ 1551

Last change on this file since 1551 was 1551, checked in by rkrimmel, 10 years ago

Own ruleset

File size: 3.8 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.SymbolComparator;
20import de.ugoe.cs.autoquest.usageprofiles.SymbolMap;
21import de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy;
22
23/**
24 * <p>
25 * concrete implementation of a symbol strategy required in the creation of a
26 * {@link de.ugoe.cs.autoquest.usageprofiles.Trie}. The strategy can be parameterized with a
27 * considered task equality. It uses task instance comparators to perform task comparison.
28 * It creates task specific symbol maps, which are {@link TaskSymbolIdentityMap} and
29 * {@link TaskSymbolBucketedMap} depending on the level of considered task equality.
30 * </p>
31 *
32 * @author Patrick Harms
33 */
34public class TaskHandlingStrategy implements SymbolStrategy<ITaskInstance> {
35   
36    /**  */
37    private static final long serialVersionUID = 1L;
38
39    /**
40     * <p>
41     * the level of task equality considered in this task handling strategy
42     * </p>
43     */
44    private TaskEquality consideredEquality;
45
46    /**
47     * <p>
48     * the comparator used for task comparisons
49     * </p>
50     */
51    private TaskInstanceComparator comparator;
52
53    /**
54     * <p>
55     * initializes this strategy with a task equality to be considered for task comparisons
56     * g</p>
57     *
58     * @param consideredEquality the task equality to be considered for task comparisons
59     */
60    public TaskHandlingStrategy(TaskEquality consideredEquality) {
61        this.consideredEquality = consideredEquality;
62       
63        if (this.consideredEquality == TaskEquality.IDENTICAL) {
64            comparator = new TaskIdentityComparator();
65        }
66        else {
67            comparator = new TaskInstanceComparator(this.consideredEquality);
68        }
69    }
70
71    /* (non-Javadoc)
72     * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#getSymbolComparator()
73     */
74    @Override
75    public SymbolComparator<ITaskInstance> getSymbolComparator() {
76        return comparator;
77    }
78
79    /**
80     * <p>
81     * convenience method to have a correctly typed return value as alternative to
82     * {@link #getSymbolComparator()};
83     * </p>
84     */
85    public TaskInstanceComparator getTaskComparator() {
86        return comparator;
87    }
88
89    /* (non-Javadoc)
90     * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#createSymbolMap()
91     */
92    @Override
93    public <V> SymbolMap<ITaskInstance, V> createSymbolMap() {
94        if (consideredEquality == TaskEquality.IDENTICAL) {
95            return new TaskSymbolIdentityMap<V>();
96        }
97        else {
98            return new TaskSymbolBucketedMap<V>(comparator);
99        }
100    }
101
102    /* (non-Javadoc)
103     * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#copySymbolMap(SymbolMap)
104     */
105    @Override
106    public <V> SymbolMap<ITaskInstance, V> copySymbolMap(SymbolMap<ITaskInstance, V> other) {
107        if (consideredEquality == TaskEquality.IDENTICAL) {
108            return new TaskSymbolIdentityMap<V>(other);
109        }
110        else {
111            return new TaskSymbolBucketedMap<V>(comparator);
112        }
113    }
114
115}
Note: See TracBrowser for help on using the repository browser.