Ignore:
Timestamp:
09/20/12 12:03:03 (12 years ago)
Author:
sherbold
Message:
  • code documentation and clean-up
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/guimodel/MFCGUIElementSpec.java

    r832 r837  
     1 
    12package de.ugoe.cs.quest.plugin.mfc.guimodel; 
    23 
     
    99100     *            modality of the window 
    100101     */ 
    101     protected MFCGUIElementSpec(long    hwnd, 
    102                                 String  name, 
    103                                 int     resourceId, 
    104                                 String  type, 
    105                                 boolean isModal) 
     102    protected MFCGUIElementSpec(long hwnd, String name, int resourceId, String type, boolean isModal) 
    106103    { 
    107104        this.hwnd = hwnd; 
     
    121118    public String getName() { 
    122119        StringBuffer names = new StringBuffer(); 
    123          
     120 
    124121        if (name != null) { 
    125122            names.append('"'); 
     
    130127            names.append("NOT_SET"); 
    131128        } 
    132          
     129 
    133130        if (formerNames.size() > 0) { 
    134              
     131 
    135132            names.append(" (aka "); 
    136              
     133 
    137134            for (int i = 0; i < formerNames.size(); i++) { 
    138135                if (i > 0) { 
     
    144141                names.append('"'); 
    145142            } 
    146              
     143 
    147144            names.append(")"); 
    148145        } 
    149          
     146 
    150147        return names.toString(); 
    151148    } 
     
    173170    } 
    174171 
    175     /* (non-Javadoc) 
     172    /* 
     173     * (non-Javadoc) 
     174     *  
    176175     * @see de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec#getType() 
    177176     */ 
     
    183182    /** 
    184183     * <p> 
    185      * TODO: comment 
    186      * </p> 
    187      * 
    188      * @return 
     184     * Returns the modality of the specified GUI element. 
     185     * </p> 
     186     *  
     187     * @return the modality 
    189188     */ 
    190189    public boolean isModal() { 
     
    201200     */ 
    202201    public void setName(String newName) { 
    203         if ((this.name != null) && 
    204             (!this.name.equals(newName)) && 
     202        if ((this.name != null) && (!this.name.equals(newName)) && 
    205203            (!this.formerNames.contains(this.name))) 
    206204        { 
    207205            this.formerNames.add(this.name); 
    208206        } 
    209          
     207 
    210208        this.name = newName; 
    211209    } 
     
    223221            this.formerHwnds.add(this.hwnd); 
    224222        } 
    225          
     223 
    226224        this.hwnd = newHwnd; 
    227225    } 
    228226 
    229     /* (non-Javadoc) 
    230      * @see de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec#getSimilarity(de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec) 
     227    /* 
     228     * (non-Javadoc) 
     229     *  
     230     * @see 
     231     * de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec#getSimilarity(de.ugoe.cs.quest.eventcore 
     232     * .guimodel.IGUIElementSpec) 
    231233     */ 
    232234    @Override 
    233235    public boolean getSimilarity(IGUIElementSpec other) { 
    234          
     236 
    235237        if (this == other) { 
    236238            return true; 
    237239        } 
    238          
     240 
    239241        if (!(other instanceof MFCGUIElementSpec)) { 
    240242            return false; 
    241243        } 
    242          
     244 
    243245        MFCGUIElementSpec otherSpec = (MFCGUIElementSpec) other; 
    244246 
     
    260262        // and reopend, i.e. a new instance is created. If one of them stays the same, then 
    261263        // similarity is given. Therefore these are the first two comparisons 
    262          
     264 
    263265        if (hwnd == otherSpec.hwnd) { 
    264266            return true; 
    265267        } 
    266          
     268 
    267269        if ((name != null) && (name.equals(otherSpec.name))) { 
    268270            return true; 
    269271        } 
    270          
    271         if ((((name == null) && (otherSpec.name == null)) || 
    272              (("".equals(name)) && ("".equals(otherSpec.name)))) && 
    273             (formerNames.size() == 0) && (otherSpec.formerNames.size() == 0)) 
     272 
     273        if ((((name == null) && (otherSpec.name == null)) || (("".equals(name)) && ("" 
     274            .equals(otherSpec.name)))) && 
     275            (formerNames.size() == 0) && 
     276            (otherSpec.formerNames.size() == 0)) 
    274277        { 
    275278            return true; 
    276279        } 
    277          
     280 
    278281        // if the hwnd and the name did not stay the same, then the name should be checked first. 
    279282        // The current name of one of the specs must be contained in the former names of the 
     
    291294            return true; 
    292295        } 
    293          
     296 
    294297        // ok. Even the names do not match. This is usually a clear indication, that the elements 
    295298        // are distinct. However, we check, if the former handles matched. This is very unlikely 
     
    302305 
    303306        // now we can be really sure, that the GUI elements differ 
    304          
     307 
    305308        return false; 
    306309    } 
    307310 
    308     /* (non-Javadoc) 
     311    /* 
     312     * (non-Javadoc) 
     313     *  
    309314     * @see de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec#equals(IGUIElementSpec) 
    310315     */ 
    311316    @Override 
    312317    public boolean equals(Object other) { 
    313          
     318 
    314319        if (this == other) { 
    315320            return true; 
    316321        } 
    317          
     322 
    318323        if (!(other instanceof MFCGUIElementSpec)) { 
    319324            return false; 
    320325        } 
    321          
     326 
    322327        MFCGUIElementSpec otherSpec = (MFCGUIElementSpec) other; 
    323          
    324         return 
    325             (hwnd == otherSpec.hwnd) && (isModal == otherSpec.isModal) && 
     328 
     329        return (hwnd == otherSpec.hwnd) && (isModal == otherSpec.isModal) && 
    326330            (resourceId == otherSpec.resourceId) && 
    327331            ((type == otherSpec.type) || ((type != null) && (type.equals(otherSpec.type)))) && 
     
    329333    } 
    330334 
    331     /* (non-Javadoc) 
     335    /* 
     336     * (non-Javadoc) 
     337     *  
    332338     * @see java.lang.Object#hashCode() 
    333339     */ 
     
    340346    /** 
    341347     * <p> 
    342      * Returns a string identfier of the window:<br> 
     348     * Returns a string identifier of the window:<br> 
    343349     * {@code [resourceId;"windowName";"className";modality]} 
    344350     * </p> 
     
    348354    @Override 
    349355    public String toString() { 
    350         return "[" + resourceId + ";" + getName() + ";\"" + type + "\";" + isModal + ";" + 
    351             hwnd + "]"; 
    352     } 
    353  
    354     /** 
    355      * <p> 
    356      * TODO: comment 
    357      * </p> 
     356        return "[" + resourceId + ";" + getName() + ";\"" + type + "\";" + isModal + ";" + hwnd + 
     357            "]"; 
     358    } 
     359 
     360    /** 
     361     * <p> 
     362     * Returns the XML representation of this specification. 
     363     * </p> 
     364     *  
     365     * @return the XML representation 
    358366     */ 
    359367    String toXML() { 
    360         return 
    361             "<window name=\"" + (name != null ? StringTools.xmlEntityReplacement(name) : "") + 
    362             "\" class=\"" + StringTools.xmlEntityReplacement(type) + 
    363             "\" resourceId=\"" + resourceId + "\" isModal=\"" + 
    364             isModal + "\"/>"; 
    365     } 
    366  
    367     /** 
    368      * <p> 
    369      * TODO: comment 
    370      * </p> 
    371      * 
     368        return "<window name=\"" + (name != null ? StringTools.xmlEntityReplacement(name) : "") + 
     369            "\" class=\"" + StringTools.xmlEntityReplacement(type) + "\" resourceId=\"" + 
     370            resourceId + "\" isModal=\"" + isModal + "\"/>"; 
     371    } 
     372 
     373    /** 
     374     * <p> 
     375     * Updates the specification with another specification. 
     376     * </p> 
     377     *  
    372378     * @param furtherSpec 
     379     *            specification used to update the current specification 
    373380     */ 
    374381    void update(IGUIElementSpec furtherSpec) { 
    375382        MFCGUIElementSpec other = (MFCGUIElementSpec) furtherSpec; 
    376          
     383 
    377384        if (other != this) { 
    378385            for (long formerHwnd : other.formerHwnds) { 
     
    388395            } 
    389396 
    390             if ((name != other.name) && (name != null) && (!name.equals(other.name))) 
    391             { 
     397            if ((name != other.name) && (name != null) && (!name.equals(other.name))) { 
    392398                setName(other.name); 
    393399            } 
Note: See TracChangeset for help on using the changeset viewer.