+/*\r
+ * This file is part of the Vamsas Client version 0.1. \r
+ * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, \r
+ * Andrew Waterhouse and Dominik Lindner.\r
+ * \r
+ * Earlier versions have also been incorporated into Jalview version 2.4 \r
+ * since 2008, and TOPALi version 2 since 2007.\r
+ * \r
+ * The Vamsas Client is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU Lesser General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * The Vamsas Client is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU Lesser General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU Lesser General Public License\r
+ * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
package uk.ac.vamsas.client.picking;\r
\r
/**\r
* Abstract base class for all message types supported by the picking API.\r
*/\r
-public abstract class Message\r
-{\r
- protected String message;\r
- \r
- /**\r
- * Constructs a new message.\r
- */\r
- protected Message()\r
- {\r
+public abstract class Message {\r
+ protected String message;\r
+\r
+ /**\r
+ * Constructs a new message.\r
+ */\r
+ protected Message() {\r
+\r
+ }\r
+\r
+ /**\r
+ * Returns the raw message content as a string.\r
+ * \r
+ * @return the raw message content as a string\r
+ */\r
+ public String getRawMessage() {\r
+ return message;\r
+ }\r
+\r
+ /**\r
+ * compare the on-wire message content of the given message to this.\r
+ * \r
+ * @param msg\r
+ * @return true if message content is equal\r
+ */\r
+ public boolean equals(Message msg) {\r
+ return message.equals(msg.getRawMessage());\r
+ }\r
\r
- }\r
- \r
- /**\r
- * Returns the raw message content as a string.\r
- * @return the raw message content as a string\r
- */\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
+ /**\r
+ * Test consistence of a Message class implementation. This method throws an\r
+ * error if the message object cannot be parsed into another instance of the\r
+ * same object by invoking the MessageImpl(String this.getRawMessage())\r
+ * constructor or that 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
+ java.lang.reflect.Constructor msgcons = this.getClass().getConstructor(\r
+ new Class[] { String.class });\r
+ if (msgcons == null) {\r
+ throw new Exception("No " + this.getClass().getName()\r
+ + "(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
+ Message instance = (Message) msgcons.newInstance(new Object[] { this\r
+ .getRawMessage() });\r
+ if (!instance.getRawMessage().equals(getRawMessage())) {\r
+ throw new Error(\r
+ "Raw Message Content does not match :\nInitial Message:"\r
+ + getRawMessage() + "\nParsed and regnerated as :\n"\r
+ + instance.getRawMessage() + "\n");\r
}\r
- } catch (Exception e)\r
- {\r
- throw new Error("Message implementation broken for "+this.getClass(),e);\r
+ } catch (Exception e) {\r
+ throw new Error("Message implementation broken for " + this.getClass(), e);\r
}\r
}\r
\r
-}
\ No newline at end of file
+}\r