Added getter methods to the MouseOverMessage class.
[vamsas.git] / src / uk / ac / vamsas / client / picking / MouseOverMessage.java
1 package uk.ac.vamsas.client.picking;\r
2 \r
3 /**\r
4  * Message class that can be used to send mouse over events.\r
5  */\r
6 public class MouseOverMessage extends Message\r
7 {\r
8         private String vorbaID;\r
9         private int position;\r
10         \r
11         /**\r
12          * Constructs a new mouse over message.\r
13          * @param vorbaID the VAMSAS object ID of the event's source (usually an\r
14          * alignment or alignment sequence)\r
15          * @param position a position on the source in its coordinate system (ie a\r
16          * column or nucleotide/residue position)\r
17          */\r
18         public MouseOverMessage(String vorbaID, int position)\r
19         {\r
20                 this.vorbaID = vorbaID;\r
21                 this.position = position;\r
22                 \r
23                 message = "MOUSEOVER_"\r
24                         + "vorbaID=" + vorbaID + "_" + "position=" + position;\r
25         }\r
26         \r
27         /**\r
28          * Constructs a new mouse over message from its underlying string format.\r
29          * @param str the string representation of an instance of this object\r
30          * @throws java.lang.Exception if the message cannot be reconstructed\r
31          */\r
32         MouseOverMessage(String str)\r
33                 throws Exception\r
34         {\r
35                 String[] elements = str.split("_");\r
36                 \r
37                 for (int i = 0; i < elements.length; i++)\r
38                 {\r
39                         if (elements[i].startsWith("vorbaID="))\r
40                                 vorbaID = elements[i].substring(8);\r
41                         else if (elements[i].startsWith("position="))\r
42                                 position = Integer.parseInt(elements[i].substring(9));\r
43                 }\r
44         }\r
45         \r
46         /**\r
47          * Returns the VAMSAS object ID associated with this message.\r
48          * @return the VAMSAS object ID associated with this message\r
49          */\r
50         public String getVorbaID()\r
51                 { return vorbaID; }\r
52         \r
53         /**\r
54          * Returns the position value associated with this message.\r
55          * @return the position value associated with this message\r
56          */\r
57         public int getPosition()\r
58                 { return position; }\r
59 }