*/\r
public String getRawMessage()\r
{ return message; }\r
+ /**\r
+ * compare the on-wire message content of the given message to this.\r
+ * @param msg\r
+ * @return true if message content is equal\r
+ */\r
+ public boolean equals(Message msg)\r
+ {\r
+ return message.equals(msg.getRawMessage());\r
+ }\r
+ /**\r
+ * Test consistence of a Message class implementation. This method throws an error if\r
+ * the message object cannot be parsed into another instance of the same object by\r
+ * invoking the MessageImpl(String this.getRawMessage()) constructor or that\r
+ * newinstance.getRawMessage != this.getRawMessage \r
+ */\r
+ public void validate() {\r
+ try {\r
+ java.lang.reflect.Constructor msgcons = this.getClass().getConstructor(new Class[] { String.class });\r
+ if (msgcons==null)\r
+ {\r
+ throw new Exception("No "+this.getClass().getName()+"(String rawmessage) constructor.");\r
+ }\r
+ Message instance = (Message) msgcons.newInstance(new Object[] { this.getRawMessage() });\r
+ if (!instance.getRawMessage().equals(getRawMessage()))\r
+ {\r
+ throw new Error("Raw Message Content does not match :\nInitial Message:"+getRawMessage()+"\nParsed and regnerated as :\n"+instance.getRawMessage()+"\n");\r
+ }\r
+ } catch (Exception e)\r
+ {\r
+ throw new Error("Message implementation broken for "+this.getClass(),e);\r
+ }\r
+ }\r
+\r
}
\ No newline at end of file