Ignore:
Timestamp:
10/30/12 14:00:22 (12 years ago)
Author:
pharms
Message:
  • made event final, so that it can't be derived of
  • added support for adding further event parameters
Location:
trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/Event.java

    r927 r958  
    1616 
    1717import java.io.Serializable; 
     18import java.util.HashMap; 
    1819import java.util.LinkedList; 
    1920import java.util.List; 
     21import java.util.Map; 
    2022 
    2123/** 
     
    3032 *            Can be used to declare that events belong to a specific platform without subclassing. 
    3133 */ 
    32 public class Event implements Serializable { 
     34public final class Event implements Serializable { 
    3335 
    3436    /** 
     
    5759     * </p> 
    5860     */ 
    59     protected IEventType type; 
     61    private IEventType type; 
    6062 
    6163    /** 
    6264     * </p> Target of the event. 
    6365     */ 
    64     protected IEventTarget target = null; 
     66    private IEventTarget target = null; 
     67     
     68    /** 
     69     * <p> 
     70     * Map with further parameters of the event, which are not belonging to the type or target. 
     71     * </p> 
     72     */ 
     73    private Map<String, String> parameters = new HashMap<String, String>(); 
    6574 
    6675    /** 
     
    7180     * </p> 
    7281     */ 
    73     protected List<IReplayable> replay = new LinkedList<IReplayable>(); 
     82    private List<IReplayable> replay = new LinkedList<IReplayable>(); 
    7483 
    7584    /** 
     
    235244    /** 
    236245     * <p> 
    237      * Adds a {@link List}ist of {@link IReplayable} to the replay sequence. 
     246     * Adds a {@link List} of {@link IReplayable} to the replay sequence. 
    238247     * </p> 
    239248     *  
     
    249258        replay.addAll(generatedReplaySeq); 
    250259    } 
     260     
     261    /** 
     262     * <p> 
     263     * Adds a parameter to the event or sets it to a new value. The key must not be null. If a 
     264     * parameter with the specified key already exists, its value is replaced with the new one. 
     265     * If the value is null, the parameter with the specified key is removed, if it exists. 
     266     * </p> 
     267     *  
     268     * @param key   the key of the parameter 
     269     * @param value the value of the parameter 
     270     *  
     271     * @throws IllegalArgumentException 
     272     *             if the provided key is null 
     273     */ 
     274    public void setParameter(String key, String value) { 
     275        if (key == null) { 
     276            throw new IllegalArgumentException("key must not be null"); 
     277        } 
     278         
     279        if (value == null) { 
     280            parameters.remove(key); 
     281        } 
     282        else { 
     283            parameters.put(key, value); 
     284        } 
     285    } 
     286 
     287    /** 
     288     * <p> 
     289     * Returns the event parameter with the specified key if it exists or null if not. The key 
     290     * must not be null. 
     291     * </p> 
     292     *  
     293     * @param key the key of the parameter to be returned 
     294     *  
     295     * @return the value of the parameter with the specified key or null if there is no parameter 
     296     *         with that key 
     297     *  
     298     * @throws IllegalArgumentException 
     299     *             if the provided key is null 
     300     */ 
     301    public String getParameter(String key) { 
     302        if (key == null) { 
     303            throw new IllegalArgumentException("key must not be null"); 
     304        } 
     305         
     306        return parameters.get(key); 
     307    } 
    251308 
    252309    /** 
  • trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/gui/MouseClickCondenser.java

    r957 r958  
    2929 * provided sequence and identifies any match of the named event sequence pattern. This match is 
    3030 * condensed to the mouse click event. 
    31  * </p> 
    32  * <p> 
    33  * This class does not create events of proper type if the events are not of type {@link Event} 
    34  * but derived from it. 
    3531 * </p> 
    3632 * TODO correctly identify drag and drop 
Note: See TracChangeset for help on using the changeset viewer.