source: trunk/autoquest-plugin-usability2/src/main/java/de/ugoe/cs/autoquest/plugin/usability2/rules/operator/Label.java @ 1326

Last change on this file since 1326 was 1326, checked in by khartmann, 10 years ago

Moved alexanders code into a new plugin project.
First commit of my experimental code (needs a lot of cleanup).

File size: 1.4 KB
Line 
1package de.ugoe.cs.autoquest.plugin.usability2.rules.operator;
2
3import de.ugoe.cs.autoquest.plugin.usability2.rules.results.DefaultMatch;
4import de.ugoe.cs.autoquest.plugin.usability2.rules.results.IMatch;
5import de.ugoe.cs.autoquest.plugin.usability2.rules.results.IResult;
6import de.ugoe.cs.autoquest.plugin.usability2.rules.results.TransformedResult;
7import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
8
9/**
10 *
11 * <p>
12 * A filter that will label the results of the marked filter with the provided name.
13 * The name can later be used to retrieve a named result.
14 * </p>
15 *
16 * @author Konni Hartmann
17 */
18public class Label extends MarkingFilter {
19
20    final String label;
21
22    public Label(String label, IFilter marked) {
23        this(label, marked, null);
24    }
25
26    public Label(String label, IFilter marked, IResultTransformer transformer) {
27        super(marked, transformer);
28        this.label = label;       
29    }
30
31    class LabeledTransformedResult extends TransformedResult {
32
33        public LabeledTransformedResult(IResult result) {
34            super(result);
35        }
36
37        @Override
38        protected IMatch transform(IMatch next) {
39            return new DefaultMatch(next.getTask(), label, next.getLabeledResults());
40        }
41       
42    }
43   
44    @Override
45    protected IResult match(ITask task, IFilter filter) {
46        IResult result = filter.match(task);
47        return new LabeledTransformedResult(result);
48    }
49
50}
Note: See TracBrowser for help on using the repository browser.