Ignore:
Timestamp:
09/09/11 06:23:36 (13 years ago)
Author:
sherbold
Message:
  • code documentation and formatting
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows/data/WindowsMessage.java

    r141 r171  
    88import de.ugoe.cs.util.StringTools; 
    99 
     10/** 
     11 * <p> 
     12 * Contains all informations about a windows message, i.e., all parameters that 
     13 * are read when a windows message is parsed as well as its target, hwnd, etc. 
     14 * </p> 
     15 *  
     16 * @author Steffen Herbold 
     17 * @version 1.0 
     18 *  
     19 */ 
    1020public class WindowsMessage implements IReplayable { 
    11         /** 
    12          * Id for object serialization.  
     21 
     22        /** 
     23         * <p> 
     24         * Id for object serialization. 
     25         * </p> 
    1326         */ 
    1427        private static final long serialVersionUID = 1L; 
    15          
     28 
     29        /** 
     30         * <p> 
     31         * Type of the message. 
     32         * </p> 
     33         */ 
    1634        final int type; 
     35 
     36        /** 
     37         * <p> 
     38         * Window class of the message target. Default: "" 
     39         * </p> 
     40         */ 
    1741        private String windowClass = ""; 
     42 
     43        /** 
     44         * <p> 
     45         * Resource Id of the message target. Default: 0 
     46         * </p> 
     47         */ 
    1848        private int resourceId = 0; 
     49 
     50        /** 
     51         * <p> 
     52         * XML representation of the message target. 
     53         * </p> 
     54         */ 
    1955        private String xmlWindowDescription = ""; 
     56 
     57        /** 
     58         * <p> 
     59         * String that contains the names of all parent widgets and itself, separated by dots, 
     60         * e.g., "GrandParent.Parent.self". 
     61         * </p> 
     62         */ 
    2063        private String parentNames = null; 
     64 
     65        /** 
     66         * <p> 
     67         * String that contains the window class of the parent widget. 
     68         * </p> 
     69         */ 
    2170        private String parentClass = null; 
    2271 
     72        /** 
     73         * <p> 
     74         * LPARAM of the message. Default: 0 
     75         * </p> 
     76         */ 
    2377        private long LPARAM = 0; 
     78 
     79        /** 
     80         * <p> 
     81         * WPARAM of the message. Default: 0 
     82         * </p> 
     83         */ 
    2484        private long WPARAM = 0; 
    2585 
     86        /** 
     87         * <p> 
     88         * If the LPARAM contains a HWND, this string stores the target of the HWND. 
     89         * </p> 
     90         */ 
    2691        private String LPARAMasWindowDesc = null; 
     92 
     93        /** 
     94         * <p> 
     95         * If the WPARAM contains a HWND, this string stores the target of the HWND. 
     96         * </p> 
     97         */ 
    2798        private String WPARAMasWindowDesc = null; 
    2899 
     100        /** 
     101         * <p> 
     102         * Delay after sending the messages during a replay. Default: 0 
     103         * </p> 
     104         */ 
    29105        private int delay = 0; 
    30          
     106 
     107        /** 
     108         * <p> 
     109         * A map of all parameters, associated with the message, created during the 
     110         * parsing of messages from the logs {@code param}-nodes. 
     111         * </p> 
     112         */ 
    31113        private Map<String, String> params = new HashMap<String, String>(); 
    32114 
     115        /** 
     116         * <p> 
     117         * Constructor. Creates a new message with a given message type. 
     118         * </p> 
     119         *  
     120         * @param type 
     121         *            type of the message 
     122         */ 
    33123        public WindowsMessage(int type) { 
    34124                this.type = type; 
    35125        } 
    36126 
     127        /** 
     128         * <p> 
     129         * Adds a parameter to the message. 
     130         * </p> 
     131         *  
     132         * @param type 
     133         *            type descriptor of the parameter 
     134         * @param value 
     135         *            value of the parameter 
     136         */ 
    37137        public void addParameter(String type, String value) { 
    38138                params.put(type, value); 
     
    44144        } 
    45145 
     146        /** 
     147         * <p> 
     148         * Returns the type of the message. 
     149         * </p> 
     150         *  
     151         * @return type of the message 
     152         */ 
    46153        public int getType() { 
    47154                return type; 
    48155        } 
    49156 
     157        /** 
     158         * <p> 
     159         * Returns the value of a parameter, given its type. If the parameter is not 
     160         * found, {@code null} is returned. 
     161         * </p> 
     162         *  
     163         * @param type 
     164         *            type of the parameter 
     165         * @return value of the parameter 
     166         */ 
    50167        public String getParameter(String type) { 
    51168                return params.get(type); 
    52169        } 
    53170 
     171        /** 
     172         * <p> 
     173         * Returns the window class of the message target. 
     174         * </p> 
     175         *  
     176         * @return window class of the message target 
     177         */ 
    54178        public String getWindowClass() { 
    55179                return windowClass; 
    56180        } 
    57181 
     182        /** 
     183         * <p> 
     184         * Returns the HWND the message is addressed to. 
     185         * </p> 
     186         *  
     187         * @return HWND the message is addressed to 
     188         */ 
    58189        public int getHwnd() { 
    59190                int hwnd = -1; 
     
    67198        } 
    68199 
     200        /** 
     201         * <p> 
     202         * Returns the resource Id of the message target. 
     203         * </p> 
     204         *  
     205         * @return resource Id of the message target 
     206         */ 
    69207        public int getWindowResourceId() { 
    70208                return resourceId; 
    71209        } 
    72210 
     211        /** 
     212         * <p> 
     213         * Two {@link WindowsMessage} are equal, if their {@link #type}, 
     214         * {@link #xmlWindowDescription}, and {@link #params} are equal. 
     215         * </p> 
     216         *  
     217         * @see java.lang.Object#equals(java.lang.Object) 
     218         */ 
    73219        @Override 
    74220        public boolean equals(Object other) { 
    75                 if( other==this) { 
     221                if (other == this) { 
    76222                        return true; 
    77223                } 
     
    86232        } 
    87233 
     234        /* 
     235         * (non-Javadoc) 
     236         *  
     237         * @see java.lang.Object#hashCode() 
     238         */ 
    88239        @Override 
    89240        public int hashCode() { 
     
    98249        } 
    99250 
     251        /** 
     252         * <p> 
     253         * Returns a string representation of the message of the form 
     254         * "msg[target=HWND;type=TYPE]". 
     255         * </p> 
     256         *  
     257         * @see java.lang.Object#toString() 
     258         */ 
    100259        @Override 
    101260        public String toString() { 
     
    104263        } 
    105264 
     265        /** 
     266         * <p> 
     267         * Retrieves the target string of a message from a given {@link WindowTree} 
     268         * through looking up the HWND the message is addressed to in the window 
     269         * tree. 
     270         * </p> 
     271         *  
     272         * @param windowTree 
     273         *            {@link WindowTree} from which the target is extracted 
     274         * @throws InvalidParameterException 
     275         *             thrown if HWND is not contained in windowTree 
     276         */ 
    106277        public void setTarget(WindowTree windowTree) 
    107278                        throws InvalidParameterException { 
     
    117288                        parentNames = node.getParentNames(); 
    118289                        WindowTreeNode parent = node.getParent(); 
    119                         if( parent==null ) { 
     290                        if (parent == null) { 
    120291                                parentClass = ""; 
    121292                        } else { 
     
    125296        } 
    126297 
     298        /** 
     299         * <p> 
     300         * Sets the LPARAM of a message. 
     301         * </p> 
     302         *  
     303         * @param paramValue 
     304         *            value of the LPARAM 
     305         */ 
    127306        public void setLPARAM(long paramValue) { 
    128307                LPARAM = paramValue; 
    129308        } 
    130309 
     310        /** 
     311         * <p> 
     312         * Sets the WPARAM of a message. 
     313         * </p> 
     314         *  
     315         * @param paramValue 
     316         *            value of the WPARAM 
     317         */ 
    131318        public void setWPARAM(long paramValue) { 
    132319                WPARAM = paramValue; 
    133320        } 
    134321 
     322        /** 
     323         * <p> 
     324         * Returns the LPARAM of a message. 
     325         * </p> 
     326         *  
     327         * @return LPARAM of the message 
     328         */ 
    135329        public long getLPARAM() { 
    136330                return LPARAM; 
    137331        } 
    138332 
     333        /** 
     334         * <p> 
     335         * Returns the WPARAM of a message. 
     336         * </p> 
     337         *  
     338         * @return WPARAM of the message 
     339         */ 
    139340        public long getWPARAM() { 
    140341                return WPARAM; 
    141342        } 
    142343 
     344        /** 
     345         * <p> 
     346         * If the LPARAM contains a HWND, this function can be used to set a target 
     347         * string to identify the HWND at run-time. 
     348         * </p> 
     349         *  
     350         * @param windowDesc 
     351         *            target string 
     352         */ 
    143353        public void setLPARAMasWindowDesc(String windowDesc) { 
    144354                LPARAMasWindowDesc = windowDesc; 
    145355        } 
    146356 
     357        /** 
     358         * <p> 
     359         * If the WPARAM contains a HWND, this function can be used to set a target 
     360         * string to identify the HWND at run-time. 
     361         * </p> 
     362         *  
     363         * @param windowDesc 
     364         *            target string 
     365         */ 
    147366        public void setWPARAMasWindowDesc(String windowDesc) { 
    148367                WPARAMasWindowDesc = windowDesc; 
    149368        } 
    150369 
     370        /** 
     371         * <p> 
     372         * If the LPARAM contains a HWND and the target string for the HWND is set, 
     373         * this function returns the target string. Otherwise, {@code null} is 
     374         * returned. 
     375         * </p> 
     376         *  
     377         * @return target string if available; {@code null} otherwise 
     378         */ 
    151379        public String getLPARAMasWindowDesc() { 
    152380                return LPARAMasWindowDesc; 
    153381        } 
    154382 
     383        /** 
     384         * <p> 
     385         * If the WPARAM contains a HWND and the target string for the HWND is set, 
     386         * this function returns the target string. Otherwise, {@code null} is 
     387         * returned. 
     388         * </p> 
     389         *  
     390         * @return target string if available; {@code null} otherwise 
     391         */ 
    155392        public String getWPARAMasWindowDesc() { 
    156393                return WPARAMasWindowDesc; 
    157394        } 
    158395 
     396        /** 
     397         * <p> 
     398         * Returns the target string of the message. 
     399         * </p> 
     400         *  
     401         * @return target string of the message 
     402         */ 
    159403        public String getXmlWindowDescription() { 
    160404                return xmlWindowDescription; 
    161405        } 
    162406 
     407        /** 
     408         * <p> 
     409         * Sets the target string manually. 
     410         * </p> 
     411         *  
     412         * @param xmlWindowDescription 
     413         *            target string 
     414         */ 
    163415        public void setXmlWindowDescription(String xmlWindowDescription) { 
    164416                this.xmlWindowDescription = xmlWindowDescription; 
    165417        } 
    166418 
     419        /** 
     420         * <p> 
     421         * Returns the delay after this message during replays. 
     422         * </p> 
     423         *  
     424         * @return delay after this message 
     425         */ 
    167426        public int getDelay() { 
    168427                return delay; 
    169428        } 
    170429 
     430        /** 
     431         * <p> 
     432         * Sets the delay after this message during replays. 
     433         * </p> 
     434         *  
     435         * @param delay 
     436         *            delay after this message 
     437         */ 
    171438        public void setDelay(int delay) { 
    172439                this.delay = delay; 
    173440        } 
    174441 
     442        /** 
     443         * <p> 
     444         * Returns the parent names separated by dots, e.g., "GrandParent.Parent". 
     445         * </p> 
     446         *  
     447         * @return names of the parents 
     448         */ 
    175449        public String getParentNames() { 
    176450                return parentNames; 
    177451        } 
    178          
     452 
     453        /** 
     454         * <p> 
     455         * Returns the window class of the parent. 
     456         * </p> 
     457         *  
     458         * @return window classes of the parents 
     459         */ 
    179460        public String getParentClass() { 
    180461                return parentClass; 
    181462        } 
    182463 
     464        /** 
     465         * <p> 
     466         * Returns the number of parameters stored together with this message. 
     467         * </p> 
     468         *  
     469         * @return 
     470         */ 
    183471        public int getNumParams() { 
    184472                return params.size(); 
    185473        } 
    186          
     474 
     475        /* 
     476         * (non-Javadoc) 
     477         *  
     478         * @see de.ugoe.cs.eventbench.data.IReplayable#getReplay() 
     479         */ 
     480        @Override 
    187481        public String getReplay() { 
    188482                StringBuilder currentMsgStr = new StringBuilder(400); 
    189                 currentMsgStr.append("  <msg type=\""+type+"\" "); 
    190                 currentMsgStr.append("LPARAM=\""+LPARAM+"\" "); 
    191                 currentMsgStr.append("WPARAM=\""+WPARAM+"\" "); 
    192                 currentMsgStr.append("delay=\""+delay+"\">"); 
    193                 if( LPARAMasWindowDesc!=null ) { 
     483                currentMsgStr.append("  <msg type=\"" + type + "\" "); 
     484                currentMsgStr.append("LPARAM=\"" + LPARAM + "\" "); 
     485                currentMsgStr.append("WPARAM=\"" + WPARAM + "\" "); 
     486                currentMsgStr.append("delay=\"" + delay + "\">"); 
     487                if (LPARAMasWindowDesc != null) { 
    194488                        currentMsgStr.append(StringTools.ENDLINE); 
    195489                        currentMsgStr.append("   <LPARAM>"); 
     
    198492                        currentMsgStr.append(StringTools.ENDLINE); 
    199493                        currentMsgStr.append("</LPARAM>"); 
    200                 }  
    201                 if( WPARAMasWindowDesc!=null ) { 
     494                } 
     495                if (WPARAMasWindowDesc != null) { 
    202496                        currentMsgStr.append(StringTools.ENDLINE); 
    203497                        currentMsgStr.append("   <WPARAM>"); 
     
    214508                return currentMsgStr.toString(); 
    215509        } 
    216          
     510 
     511        /* 
     512         * (non-Javadoc) 
     513         *  
     514         * @see de.ugoe.cs.eventbench.data.IReplayable#getTarget() 
     515         */ 
     516        @Override 
    217517        public String getTarget() { 
    218518                return xmlWindowDescription; 
Note: See TracChangeset for help on using the changeset viewer.