Ignore:
Timestamp:
06/06/13 17:08:25 (11 years ago)
Author:
adeicke
Message:
  • Added proper formating and JavaDoc?.
  • Several renaming refactorings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/InteractionPatternVisitor.java

    r1204 r1217  
    2525import de.ugoe.cs.autoquest.eventcore.StringEventType; 
    2626import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
     27import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 
    2729import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    2831import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2932import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor; 
    30 import de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter; 
    31 import de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter; 
     33import de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter; 
     34import de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter; 
    3235 
    3336/** 
     
    3942 */ 
    4043public abstract class InteractionPatternVisitor implements ITaskVisitor { 
    41      
    42         protected TaskTypeFilter taskType; 
    43          
     44 
     45    protected TaskTypeFilter taskType; 
     46 
    4447    protected EventTypeFilter eventType; 
    45      
     48 
    4649    protected InteractionPattern containedPattern; 
    47      
     50 
    4851    protected boolean present = false; 
    49      
     52 
    5053    protected List<ITask> retainedSelectionTasks = Lists.newArrayList(); 
    51      
    52     /* (non-Javadoc) 
    53      * @see de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask) 
     54 
     55    /* 
     56     * (non-Javadoc) 
     57     *  
     58     * @see 
     59     * de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc 
     60     * .IEventTask) 
    5461     */ 
    5562    public void visit(IEventTask event) { 
    56         if(!this.present && isEventVisitor()) { 
     63        if (!this.present && isEventVisitor()) { 
    5764            IEventType eventType = event.getEventType(); 
    58             if(eventType instanceof StringEventType) { 
     65            if (eventType instanceof StringEventType) { 
    5966                this.present = eventType.toString().equals(nameOfEventType()); 
    60             } else { 
     67            } 
     68            else { 
    6169                this.present = eventType.getClass().equals(this.eventType.clazz()); 
    6270            } 
    6371        } 
    6472    } 
    65      
     73 
    6674    public boolean isEventVisitor() { 
    6775        return this.eventType != null && this.containedPattern == null; 
    6876    } 
    69      
     77 
    7078    protected String nameOfEventType() { 
    7179        String ret = StringUtils.EMPTY; 
    7280        Iterable<String> splitted = Splitter.on("_").split(this.eventType.name()); 
    73         for(String str : splitted) { 
     81        for (String str : splitted) { 
    7482            str = str.toLowerCase(); 
    7583            ret += Character.toString(str.charAt(0)).toUpperCase() + str.substring(1); 
     
    7785        return ret; 
    7886    } 
    79      
    80     /* (non-Javadoc) 
    81      * @see de.ugoe.cs.autoquest.tasktrees.treeifc.TaskVisitor#accept(de.ugoe.cs.autoquest.tasktrees.treeifc.ITask) 
     87 
     88    /* 
     89     * (non-Javadoc) 
     90     *  
     91     * @see 
     92     * de.ugoe.cs.autoquest.tasktrees.treeifc.TaskVisitor#accept(de.ugoe.cs.autoquest.tasktrees. 
     93     * treeifc.ITask) 
    8294     */ 
    8395    @Override 
    8496    public void visit(ITask task) { 
    85         task.accept(this); 
    86          
     97        if (task instanceof ISequence) { 
     98            this.visit((ISequence) task); 
     99        } 
     100        else if (task instanceof IIteration) { 
     101            this.visit((IIteration) task); 
     102        } 
     103        else if (task instanceof ISelection) { 
     104            this.visit((ISelection) task); 
     105        } 
     106        else { 
     107            this.visit((IOptional) task); 
     108        } 
    87109    } 
    88      
    89     /* (non-Javadoc) 
    90      * @see de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection) 
     110 
     111    /* 
     112     * (non-Javadoc) 
     113     *  
     114     * @see 
     115     * de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc 
     116     * .ISelection) 
    91117     */ 
    92118    public void visit(ISelection selection) { 
    93         if(isEventVisitor()) { 
     119        if (isEventVisitor()) { 
    94120            retainNodesWherePatternIsPresent(selection); 
    95121            this.present = patternIsPresent(); 
    96         } else { 
    97             this.present = containedPattern.containedIn(selection);   
     122        } 
     123        else { 
     124            this.present = containedPattern.containedIn(selection); 
    98125        } 
    99126    } 
    100127 
    101128    @SuppressWarnings("unchecked") 
    102         protected void retainNodesWherePatternIsPresent(ISelection selection) { 
    103         for(ITask task : selection.getChildren()) { 
     129    protected void retainNodesWherePatternIsPresent(ISelection selection) { 
     130        for (ITask task : selection.getChildren()) { 
    104131            this.present = false; 
    105132            task.accept(this); 
    106             if(this.present && this.taskType.filterPredicate().apply(selection)) { 
     133            if (this.present && this.taskType.filterPredicate().apply(selection)) { 
    107134                this.retainedSelectionTasks.add(selection); 
    108135            } 
    109             if(this.present) { 
    110                 break; 
     136            if (this.present) { 
     137                break; 
    111138            } 
    112139        } 
    113140    } 
    114      
     141 
    115142    private boolean patternIsPresent() { 
    116143        return !this.retainedSelectionTasks.isEmpty(); 
    117144    } 
    118      
     145 
    119146    /** 
    120147     * <p> 
    121148     * TODO: comment 
    122149     * </p> 
    123      * 
     150     *  
    124151     * @return 
    125152     */ 
     
    132159     * TODO: comment 
    133160     * </p> 
    134      * 
     161     *  
    135162     */ 
    136163    public void reset() { 
     
    143170     * TODO: comment 
    144171     * </p> 
    145      * 
     172     *  
    146173     * @return 
    147174     */ 
     
    154181     * TODO: comment 
    155182     * </p> 
    156      * 
     183     *  
    157184     * @return 
    158185     */ 
     
    160187        return this.retainedSelectionTasks; 
    161188    } 
    162      
     189 
    163190} 
Note: See TracChangeset for help on using the changeset viewer.