Browse Source

Add getMap() to Parser and IRCParser. Fixes issue 3206

Add getMap() to ChannelInfo and make getMap() in IRCChannelInfo behave the same way as in IRCClientInfo and IRCChannelClientInfo

Change-Id: I2cdce2eb87e77139520254eec98b51288510f043
Reviewed-on: http://gerrit.dmdirc.com/125
Tested-by: Shane Mc Cormack <shane@dmdirc.com>
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3
Shane Mc Cormack 14 years ago
parent
commit
0e1eb49b56

+ 9
- 0
src/com/dmdirc/parser/interfaces/ChannelInfo.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.parser.interfaces;
24 24
 
25 25
 import com.dmdirc.parser.common.ChannelListModeItem;
26 26
 import java.util.Collection;
27
+import java.util.Map;
27 28
 
28 29
 /**
29 30
  * Holds information about a channel and allows various operations to be
@@ -183,6 +184,14 @@ public interface ChannelInfo {
183 184
      */
184 185
     int getChannelClientCount();
185 186
 
187
+    /**
188
+     * Retrieves a {@link Map} which can be used to store arbitrary data
189
+     * about the channel client.
190
+     *
191
+     * @return A map used for storing arbitrary data
192
+     */
193
+    Map<Object, Object> getMap();
194
+
186 195
     /**
187 196
      * Retrieves the parser which created this ChannelInfo.
188 197
      *

+ 9
- 0
src/com/dmdirc/parser/interfaces/Parser.java View File

@@ -28,6 +28,7 @@ import com.dmdirc.parser.common.CallbackManager;
28 28
 import com.dmdirc.parser.common.QueuePriority;
29 29
 import java.net.URI;
30 30
 import java.util.Collection;
31
+import java.util.Map;
31 32
 
32 33
 /**
33 34
  * A parser connects to a back-end chat system and handles all communication
@@ -90,6 +91,14 @@ public interface Parser extends Runnable {
90 91
      */
91 92
     void setBindIP(String ip);
92 93
 
94
+    /**
95
+     * Retrieves a {@link Map} which can be used to store arbitrary data
96
+     * about the client.
97
+     *
98
+     * @return A map used for storing arbitrary data
99
+     */
100
+    Map<Object, Object> getMap();
101
+
93 102
     /**
94 103
      * Determines the maximimum length a message of the specified type may be.
95 104
      *

+ 5
- 8
src/com/dmdirc/parser/irc/IRCChannelInfo.java View File

@@ -86,7 +86,7 @@ public class IRCChannelInfo implements ChannelInfo {
86 86
     /** Modes waiting to be sent to the server. */
87 87
     private final List<String> lModeQueue = new LinkedList<String>();
88 88
     /** A Map to allow applications to attach misc data to this object */
89
-    private Map myMap;
89
+    private Map<Object, Object> myMap;
90 90
     
91 91
     /** Queue of requested list modes */
92 92
     private final Queue<Character> listModeQueue = new LinkedList<Character>();
@@ -244,16 +244,13 @@ public class IRCChannelInfo implements ChannelInfo {
244 244
      *
245 245
      * @param newMap New Map to attatch.
246 246
      */
247
-    public void setMap(final Map newMap) {
247
+    public void setMap(final Map<Object, Object> newMap) {
248 248
         myMap = newMap;
249 249
     }
250 250
     
251
-    /**
252
-     * Get the Map object attatched to this object.
253
-     *
254
-     * @return Map to attatched to this.
255
-     */
256
-    public Map getMap() {
251
+    /** {@inheritDoc} */
252
+    @Override
253
+    public Map<Object, Object> getMap() {
257 254
         return myMap;
258 255
     }
259 256
     

+ 8
- 0
src/com/dmdirc/parser/irc/IRCParser.java View File

@@ -55,6 +55,7 @@ import java.security.NoSuchAlgorithmException;
55 55
 import java.security.cert.X509Certificate;
56 56
 import java.util.Arrays;
57 57
 import java.util.Collection;
58
+import java.util.HashMap;
58 59
 import java.util.Hashtable;
59 60
 import java.util.LinkedList;
60 61
 import java.util.List;
@@ -232,6 +233,9 @@ public class IRCParser implements SecureParser, Runnable {
232 233
     /** Current Socket State. */
233 234
     protected SocketState currentSocketState = SocketState.NULL;
234 235
 
236
+    /** Map to store arbitrary data. */
237
+    private Map<Object, Object> myMap = new HashMap<Object, Object>();
238
+
235 239
     /** This is the socket used for reading from/writing to the IRC server. */
236 240
     private Socket socket;
237 241
     /** Used for writing to the server. */
@@ -334,6 +338,10 @@ public class IRCParser implements SecureParser, Runnable {
334 338
     @Override
335 339
     public URI getURI() { return server.getURI(); }
336 340
 
341
+    /** {@inheritDoc} */
342
+    @Override
343
+    public Map<Object, Object> getMap() { return myMap; }
344
+
337 345
     /**
338 346
      * Get the current Value of createFake.
339 347
      *

Loading…
Cancel
Save