package de.ugoe.cs.quest.plugin.mfc.eventcore; import de.ugoe.cs.quest.IReplayDecorator; import de.ugoe.cs.quest.eventcore.IReplayable; import de.ugoe.cs.quest.plugin.mfc.MFCReplayDecorator; import de.ugoe.cs.util.StringTools; /** *

* Contains all informations about a windows message, i.e., all parameters that are read when a * windows message is parsed as well as its target, hwnd, etc. *

* * @author Steffen Herbold * @version 1.0 * */ public class ReplayWindowsMessage extends WindowsMessage implements IReplayable { /** *

* Id for object serialization. *

*/ private static final long serialVersionUID = 1L; /** *

* If the LPARAM contains a HWND, this string stores the target of the HWND. *

*/ private String LPARAMasWindowDesc = null; /** *

* If the WPARAM contains a HWND, this string stores the target of the HWND. *

*/ private String WPARAMasWindowDesc = null; /** *

* Delay after sending the messages during a replay. Default: 0 *

*/ private int delay = 0; /** *

* Constructor. Creates a new message with a given message type. *

* * @param type * type of the message * @param currentMessageParameters * @param target */ public ReplayWindowsMessage(WindowsMessage replayedMessage) { super(replayedMessage.getType(), replayedMessage.getTarget(), replayedMessage.getParameters()); } /** *

* Constructor. Creates a new message with a given message type. *

* * @param type * type of the message */ public ReplayWindowsMessage(WindowsMessageType type) { super(type); } /** *

* Two {@link ReplayWindowsMessage} are equal, if their {@link #type}, {@link #xmlWindowDescription}, * and {@link #params} are equal. *

* * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object other) { if (other == this) { return true; } boolean isEqual = false; if (other instanceof ReplayWindowsMessage) { isEqual = super.equals(other); } return isEqual; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return super.hashCode(); } /** *

* Returns a string representation of the message of the form "msg[target=HWND;type=TYPE]". *

* * @see java.lang.Object#toString() */ @Override public String toString() { return "msg[target=" + getParameter("window.hwnd") + ";type=" + type + "]"; } /** *

* Sets the LPARAM of a message. *

* * @param paramValue * value of the LPARAM */ public void setLPARAM(long paramValue) { super.addParameter("LPARAM", paramValue); } /** *

* Sets the WPARAM of a message. *

* * @param paramValue * value of the WPARAM */ public void setWPARAM(long paramValue) { super.addParameter("WPARAM", paramValue); } /** *

* If the LPARAM contains a HWND, this function can be used to set a target string to identify * the HWND at run-time. *

* * @param windowDesc * target string */ public void setLPARAMasWindowDesc(String windowDesc) { LPARAMasWindowDesc = windowDesc; } /** *

* If the WPARAM contains a HWND, this function can be used to set a target string to identify * the HWND at run-time. *

* * @param windowDesc * target string */ public void setWPARAMasWindowDesc(String windowDesc) { WPARAMasWindowDesc = windowDesc; } /** *

* If the LPARAM contains a HWND and the target string for the HWND is set, this function * returns the target string. Otherwise, {@code null} is returned. *

* * @return target string if available; {@code null} otherwise */ public String getLPARAMasWindowDesc() { return LPARAMasWindowDesc; } /** *

* If the WPARAM contains a HWND and the target string for the HWND is set, this function * returns the target string. Otherwise, {@code null} is returned. *

* * @return target string if available; {@code null} otherwise */ public String getWPARAMasWindowDesc() { return WPARAMasWindowDesc; } /** *

* TODO: comment *

* * @param termValue */ public void setTargetXML(String targetXML) { this.targetXML = targetXML; } /** *

* Returns the delay after this message during replays. *

* * @return delay after this message */ public int getDelay() { return delay; } /** *

* Sets the delay after this message during replays. *

* * @param delay * delay after this message */ public void setDelay(int delay) { this.delay = delay; } /* * (non-Javadoc) * * @see de.ugoe.cs.quest.eventcore.IReplayable#getReplay() */ @Override public String getReplay() { StringBuilder currentMsgStr = new StringBuilder(400); currentMsgStr.append(" "); if (LPARAMasWindowDesc != null) { currentMsgStr.append(StringTools.ENDLINE); currentMsgStr.append(" "); currentMsgStr.append(StringTools.ENDLINE); currentMsgStr.append(LPARAMasWindowDesc); currentMsgStr.append(StringTools.ENDLINE); currentMsgStr.append(""); } if (WPARAMasWindowDesc != null) { currentMsgStr.append(StringTools.ENDLINE); currentMsgStr.append(" "); currentMsgStr.append(StringTools.ENDLINE); currentMsgStr.append(WPARAMasWindowDesc); currentMsgStr.append(StringTools.ENDLINE); currentMsgStr.append(" "); } currentMsgStr.append(StringTools.ENDLINE); currentMsgStr.append(super.getTargetXML()); currentMsgStr.append(StringTools.ENDLINE); currentMsgStr.append(" "); currentMsgStr.append(StringTools.ENDLINE); return currentMsgStr.toString(); } /* * (non-Javadoc) * * @see de.ugoe.cs.quest.eventcore.IReplayable#getDecorator() */ @Override public IReplayDecorator getDecorator() { return MFCReplayDecorator.getInstance(); } }