Ignore:
Timestamp:
09/03/12 12:05:42 (12 years ago)
Author:
sherbold
Message:
  • TextInput? events can now be configured to support a specific type of equality: Lexical, Syntactical, and Semantical
  • the command detextTestInputEvents now allows the definition of the equality of the generated TextInput? events (see above)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/gui/TextInput.java

    r687 r751  
    1515 */ 
    1616public class TextInput implements IInteraction { 
     17     
     18    public enum TextEquality {LEXICAL, SYNTACTICAL, SEMANTICAL}; 
    1719 
    1820    /**  */ 
     
    2426    /** the text input events that caused the entering of the text */ 
    2527    private List<Event> textInputEvents; 
     28     
     29    private final TextEquality equalityType; 
    2630 
    2731    /** 
     
    3438     */ 
    3539    public TextInput(String enteredText, List<Event> textInputEvents) { 
     40        this(enteredText, textInputEvents, TextEquality.LEXICAL); 
     41    } 
     42     
     43    /** 
     44     * <p> 
     45     * TODO: comment 
     46     * </p> 
     47     * 
     48     * @param enteredText 
     49     * @param textInputEvents 
     50     * @param equalityType 
     51     */ 
     52    public TextInput(String enteredText, List<Event> textInputEvents, TextEquality equalityType) { 
    3653        this.enteredText = enteredText; 
    3754        this.textInputEvents = textInputEvents; 
     55        this.equalityType = equalityType; 
    3856    } 
    3957 
     
    100118        } 
    101119        else if (obj instanceof TextInput) { 
    102             return 
    103                 enteredText.equals(((TextInput) obj).enteredText) && 
    104                 textInputEvents.equals(((TextInput) obj).textInputEvents); 
     120            switch (equalityType) 
     121            { 
     122                case LEXICAL: 
     123                    return textInputEvents.equals(((TextInput) obj).textInputEvents); 
     124                case SYNTACTICAL: 
     125                    return enteredText.equals(((TextInput) obj).enteredText); 
     126                case SEMANTICAL: 
     127                    return true; 
     128                default: 
     129                    throw new AssertionError("reached source code that should be unreachable"); 
     130            } 
    105131        } 
    106132        return false; 
     
    114140    @Override 
    115141    public int hashCode() { 
    116         return getClass().hashCode() + enteredText.hashCode() + textInputEvents.size(); 
     142        int hashCode = getClass().hashCode(); 
     143        if( equalityType==TextEquality.LEXICAL) { 
     144            hashCode += enteredText.hashCode() + textInputEvents.size(); 
     145        } 
     146        else if( equalityType==TextEquality.SYNTACTICAL) { 
     147            hashCode += enteredText.hashCode(); 
     148        } 
     149        return hashCode; 
    117150    } 
    118151 
Note: See TracChangeset for help on using the changeset viewer.