Browse Source

Parser abstraction part 2. The parser now works.

tags/0.6.3m2a1
Chris Smith 15 years ago
parent
commit
6e1beb7bb3
39 changed files with 405 additions and 299 deletions
  1. 6
    5
      src/com/dmdirc/ChannelEventHandler.java
  2. 8
    9
      src/com/dmdirc/EventHandler.java
  3. 8
    8
      src/com/dmdirc/Query.java
  4. 2
    2
      src/com/dmdirc/Raw.java
  5. 4
    3
      src/com/dmdirc/ServerEventHandler.java
  6. 1
    1
      src/com/dmdirc/addons/dcc/DCCSendWindow.java
  7. 22
    11
      src/com/dmdirc/parser/irc/IRCParser.java
  8. 3
    1
      src/com/dmdirc/parser/irc/Process001.java
  9. 3
    1
      src/com/dmdirc/parser/irc/Process004005.java
  10. 3
    1
      src/com/dmdirc/parser/irc/Process464.java
  11. 3
    1
      src/com/dmdirc/parser/irc/ProcessAway.java
  12. 3
    1
      src/com/dmdirc/parser/irc/ProcessInvite.java
  13. 5
    2
      src/com/dmdirc/parser/irc/ProcessJoin.java
  14. 3
    1
      src/com/dmdirc/parser/irc/ProcessKick.java
  15. 2
    1
      src/com/dmdirc/parser/irc/ProcessListModes.java
  16. 7
    3
      src/com/dmdirc/parser/irc/ProcessMOTD.java
  17. 30
    15
      src/com/dmdirc/parser/irc/ProcessMessage.java
  18. 12
    6
      src/com/dmdirc/parser/irc/ProcessMode.java
  19. 3
    1
      src/com/dmdirc/parser/irc/ProcessNames.java
  20. 5
    2
      src/com/dmdirc/parser/irc/ProcessNick.java
  21. 3
    1
      src/com/dmdirc/parser/irc/ProcessNickInUse.java
  22. 3
    1
      src/com/dmdirc/parser/irc/ProcessNoticeAuth.java
  23. 3
    1
      src/com/dmdirc/parser/irc/ProcessPart.java
  24. 4
    2
      src/com/dmdirc/parser/irc/ProcessQuit.java
  25. 3
    1
      src/com/dmdirc/parser/irc/ProcessTopic.java
  26. 7
    3
      src/com/dmdirc/parser/irc/ProcessWallops.java
  27. 7
    3
      src/com/dmdirc/parser/irc/ProcessWho.java
  28. 2
    1
      src/com/dmdirc/parser/irc/ProcessingManager.java
  29. 184
    160
      src/com/dmdirc/parser/irc/callbacks/CallbackManager.java
  30. 12
    17
      src/com/dmdirc/parser/irc/callbacks/CallbackObject.java
  31. 23
    15
      test/com/dmdirc/parser/irc/IRCParserTest.java
  32. 2
    1
      test/com/dmdirc/parser/irc/Process004005Test.java
  33. 3
    2
      test/com/dmdirc/parser/irc/ProcessJoinTest.java
  34. 1
    1
      test/com/dmdirc/parser/irc/ProcessNamesTest.java
  35. 5
    3
      test/com/dmdirc/parser/irc/ProcessNickTest.java
  36. 2
    4
      test/com/dmdirc/parser/irc/ProcessPartTest.java
  37. 5
    5
      test/com/dmdirc/parser/irc/ProcessQuitTest.java
  38. 2
    2
      test/com/dmdirc/parser/irc/ProcessTopicTest.java
  39. 1
    1
      test/com/dmdirc/parser/irc/ProcessWhoTest.java

+ 6
- 5
src/com/dmdirc/ChannelEventHandler.java View File

58
     }
58
     }
59
 
59
 
60
     /** {@inheritDoc} */
60
     /** {@inheritDoc} */
61
+    @SuppressWarnings("unchecked")
61
     @Override
62
     @Override
62
-    protected void addCallback(final CallbackManager cbm, final String name)
63
-            throws CallbackNotFoundException {
64
-        if ("onAwayStateOther".equals(name)) {
65
-            cbm.addCallback(name, this);
63
+    protected <T extends CallbackInterface> void addCallback(
64
+            final CallbackManager cbm, final Class<T> type) throws CallbackNotFoundException {
65
+        if (OtherAwayStateListener.class.equals(type)) {
66
+            cbm.addCallback(type, (T) this);
66
         } else {
67
         } else {
67
-            cbm.addCallback(name, this, owner.getChannelInfo().getName());
68
+            cbm.addCallback(type, (T) this, owner.getChannelInfo().getName());
68
         }
69
         }
69
     }
70
     }
70
 
71
 

+ 8
- 9
src/com/dmdirc/EventHandler.java View File

36
  */
36
  */
37
 public abstract class EventHandler implements CallbackInterface {
37
 public abstract class EventHandler implements CallbackInterface {
38
     
38
     
39
-    /** The prefix indicating that the interface is a parser callback. */
40
-    private static final String CALLBACK_PREFIX = "com.dmdirc.parser.irc.callbacks.interfaces.I";
41
-    
42
     /**
39
     /**
43
      * Registers all callbacks that this event handler implements with the
40
      * Registers all callbacks that this event handler implements with the
44
      * owner's parser.
41
      * owner's parser.
45
      */
42
      */
43
+    @SuppressWarnings("unchecked")
46
     public void registerCallbacks() {
44
     public void registerCallbacks() {
47
         final CallbackManager cbm = getServer().getParser().getCallbackManager();
45
         final CallbackManager cbm = getServer().getParser().getCallbackManager();
48
         
46
         
49
         try {
47
         try {
50
             for (Class iface : this.getClass().getInterfaces()) {
48
             for (Class iface : this.getClass().getInterfaces()) {
51
-                if (iface.getName().startsWith(CALLBACK_PREFIX)) {
52
-                    addCallback(cbm, "on"
53
-                            + iface.getName().substring(CALLBACK_PREFIX.length()));
49
+                if (CallbackInterface.class.isAssignableFrom(iface)) {
50
+                    addCallback(cbm, iface);
54
                 }
51
                 }
55
             }
52
             }
56
         } catch (CallbackNotFoundException exception) {
53
         } catch (CallbackNotFoundException exception) {
71
     /**
68
     /**
72
      * Adds a callback to this event handler.
69
      * Adds a callback to this event handler.
73
      * 
70
      * 
71
+     * @param <T> The type of callback to be added
74
      * @param cbm The callback manager to use
72
      * @param cbm The callback manager to use
75
-     * @param name The name of the callback to be added
73
+     * @param type The type of the callback to be added
76
      * @throws com.dmdirc.parser.irc.callbacks.CallbackNotFoundException
74
      * @throws com.dmdirc.parser.irc.callbacks.CallbackNotFoundException
77
      * if the specified callback isn't found
75
      * if the specified callback isn't found
78
      */
76
      */
79
-    protected abstract void addCallback(CallbackManager cbm, String name) 
80
-            throws CallbackNotFoundException;
77
+    @SuppressWarnings("unchecked")
78
+    protected abstract <T extends CallbackInterface> void addCallback(
79
+            final CallbackManager cbm, final Class<T> type) throws CallbackNotFoundException;
81
     
80
     
82
     /**
81
     /**
83
      * Retrieves the server belonging to this EventHandler's owner.
82
      * Retrieves the server belonging to this EventHandler's owner.

+ 8
- 8
src/com/dmdirc/Query.java View File

243
         final CallbackManager callbackManager = server.getParser().getCallbackManager();
243
         final CallbackManager callbackManager = server.getParser().getCallbackManager();
244
 
244
 
245
         try {
245
         try {
246
-            callbackManager.addCallback("onPrivateAction", this, ClientInfo.parseHost(host));
247
-            callbackManager.addCallback("onPrivateMessage", this, ClientInfo.parseHost(host));
248
-            callbackManager.addCallback("onQuit", this);
249
-            callbackManager.addCallback("onNickChanged", this);
246
+            callbackManager.addCallback(PrivateActionListener.class, this, ClientInfo.parseHost(host));
247
+            callbackManager.addCallback(PrivateMessageListener.class, this, ClientInfo.parseHost(host));
248
+            callbackManager.addCallback(QuitListener.class, this);
249
+            callbackManager.addCallback(NickChangeListener.class, this);
250
         } catch (CallbackNotFoundException ex) {
250
         } catch (CallbackNotFoundException ex) {
251
             Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
251
             Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
252
         }
252
         }
259
         if (sOldNick.equals(ClientInfo.parseHost(host))) {
259
         if (sOldNick.equals(ClientInfo.parseHost(host))) {
260
             final CallbackManager callbackManager = server.getParser().getCallbackManager();
260
             final CallbackManager callbackManager = server.getParser().getCallbackManager();
261
 
261
 
262
-            callbackManager.delCallback("onPrivateAction", this);
263
-            callbackManager.delCallback("onPrivateMessage", this);
262
+            callbackManager.delCallback(PrivateActionListener.class, this);
263
+            callbackManager.delCallback(PrivateMessageListener.class, this);
264
 
264
 
265
             try {
265
             try {
266
-                callbackManager.addCallback("onPrivateAction", this, cClient.getNickname());
267
-                callbackManager.addCallback("onPrivateMessage", this, cClient.getNickname());
266
+                callbackManager.addCallback(PrivateActionListener.class, this, cClient.getNickname());
267
+                callbackManager.addCallback(PrivateMessageListener.class, this, cClient.getNickname());
268
             } catch (CallbackNotFoundException ex) {
268
             } catch (CallbackNotFoundException ex) {
269
                 Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
269
                 Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
270
             }
270
             }

+ 2
- 2
src/com/dmdirc/Raw.java View File

77
      */
77
      */
78
     public void registerCallbacks() {
78
     public void registerCallbacks() {
79
         try {
79
         try {
80
-            server.getParser().getCallbackManager().addCallback("OnDataIn", this);
81
-            server.getParser().getCallbackManager().addCallback("OnDataOut", this);
80
+            server.getParser().getCallbackManager().addCallback(DataInListener.class, this);
81
+            server.getParser().getCallbackManager().addCallback(DataOutListener.class, this);
82
         } catch (CallbackNotFoundException ex) {
82
         } catch (CallbackNotFoundException ex) {
83
             Logger.appError(ErrorLevel.HIGH, "Unable to register raw callbacks", ex);
83
             Logger.appError(ErrorLevel.HIGH, "Unable to register raw callbacks", ex);
84
         }
84
         }

+ 4
- 3
src/com/dmdirc/ServerEventHandler.java View File

64
 
64
 
65
     /** {@inheritDoc} */
65
     /** {@inheritDoc} */
66
     @Override
66
     @Override
67
-    protected void addCallback(final CallbackManager cbm, final String name)
68
-            throws CallbackNotFoundException {
69
-        cbm.addCallback(name, this);
67
+    @SuppressWarnings("unchecked")
68
+    protected <T extends CallbackInterface> void addCallback(
69
+            final CallbackManager cbm, final Class<T> type) throws CallbackNotFoundException {
70
+        cbm.addCallback(type, (T) this);
70
     }
71
     }
71
 
72
 
72
     /** {@inheritDoc} */
73
     /** {@inheritDoc} */

+ 1
- 1
src/com/dmdirc/addons/dcc/DCCSendWindow.java View File

98
         this.myPlugin = plugin;
98
         this.myPlugin = plugin;
99
         
99
         
100
 		if (parser != null) {
100
 		if (parser != null) {
101
-			parser.getCallbackManager().addNonCriticalCallback("onSocketClosed", this);
101
+			parser.getCallbackManager().addNonCriticalCallback(SocketCloseListener.class, this);
102
 		}
102
 		}
103
 		dcc.setHandler(this);
103
 		dcc.setHandler(this);
104
 
104
 

+ 22
- 11
src/com/dmdirc/parser/irc/IRCParser.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ConnectErrorListener;
26
+import com.dmdirc.parser.interfaces.callbacks.DataInListener;
27
+import com.dmdirc.parser.interfaces.callbacks.DataOutListener;
28
+import com.dmdirc.parser.interfaces.callbacks.DebugInfoListener;
29
+import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
30
+import com.dmdirc.parser.interfaces.callbacks.PingFailureListener;
31
+import com.dmdirc.parser.interfaces.callbacks.PingSentListener;
32
+import com.dmdirc.parser.interfaces.callbacks.PingSuccessListener;
33
+import com.dmdirc.parser.interfaces.callbacks.Post005Listener;
34
+import com.dmdirc.parser.interfaces.callbacks.ServerErrorListener;
35
+import com.dmdirc.parser.interfaces.callbacks.SocketCloseListener;
25
 import com.dmdirc.parser.irc.callbacks.CallbackManager;
36
 import com.dmdirc.parser.irc.callbacks.CallbackManager;
26
 
37
 
27
 import java.io.BufferedReader;
38
 import java.io.BufferedReader;
429
 	 * @return true if a method was called, false otherwise
440
 	 * @return true if a method was called, false otherwise
430
 	 */
441
 	 */
431
 	protected boolean callServerError(final String message) {
442
 	protected boolean callServerError(final String message) {
432
-		return myCallbackManager.getCallbackType("OnServerError").call(message);
443
+		return myCallbackManager.getCallbackType(ServerErrorListener.class).call(message);
433
 	}
444
 	}
434
 
445
 
435
 	/**
446
 	/**
440
 	 * @return true if a method was called, false otherwise
451
 	 * @return true if a method was called, false otherwise
441
 	 */
452
 	 */
442
 	protected boolean callDataIn(final String data) {
453
 	protected boolean callDataIn(final String data) {
443
-		return myCallbackManager.getCallbackType("OnDataIn").call(data);
454
+		return myCallbackManager.getCallbackType(DataInListener.class).call(data);
444
 	}
455
 	}
445
 
456
 
446
 	/**
457
 	/**
452
 	 * @see com.dmdirc.parser.irc.callbacks.interfaces.IDataOut
463
 	 * @see com.dmdirc.parser.irc.callbacks.interfaces.IDataOut
453
 	 */
464
 	 */
454
 	protected boolean callDataOut(final String data, final boolean fromParser) {
465
 	protected boolean callDataOut(final String data, final boolean fromParser) {
455
-		return myCallbackManager.getCallbackType("OnDataOut").call(data, fromParser);
466
+		return myCallbackManager.getCallbackType(DataOutListener.class).call(data, fromParser);
456
 	}
467
 	}
457
 
468
 
458
 	/**
469
 	/**
476
 	 * @return true if a method was called, false otherwise
487
 	 * @return true if a method was called, false otherwise
477
 	 */
488
 	 */
478
 	protected boolean callDebugInfo(final int level, final String data) {
489
 	protected boolean callDebugInfo(final int level, final String data) {
479
-		return myCallbackManager.getCallbackType("OnDebugInfo").call(level, data);
490
+		return myCallbackManager.getCallbackType(DebugInfoListener.class).call(level, data);
480
 	}
491
 	}
481
 
492
 
482
 	/**
493
 	/**
487
 	 * @return true if a method was called, false otherwise
498
 	 * @return true if a method was called, false otherwise
488
 	 */
499
 	 */
489
 	protected boolean callErrorInfo(final ParserError errorInfo) {
500
 	protected boolean callErrorInfo(final ParserError errorInfo) {
490
-		return myCallbackManager.getCallbackType("OnErrorInfo").call(errorInfo);
501
+		return myCallbackManager.getCallbackType(ErrorInfoListener.class).call(errorInfo);
491
 	}
502
 	}
492
 
503
 
493
 	/**
504
 	/**
498
 	 * @return true if a method was called, false otherwise
509
 	 * @return true if a method was called, false otherwise
499
 	 */
510
 	 */
500
 	protected boolean callConnectError(final ParserError errorInfo) {
511
 	protected boolean callConnectError(final ParserError errorInfo) {
501
-		return myCallbackManager.getCallbackType("OnConnectError").call(errorInfo);
512
+		return myCallbackManager.getCallbackType(ConnectErrorListener.class).call(errorInfo);
502
 	}
513
 	}
503
 
514
 
504
 	/**
515
 	/**
508
 	 * @return true if a method was called, false otherwise
519
 	 * @return true if a method was called, false otherwise
509
 	 */
520
 	 */
510
 	protected boolean callSocketClosed() {
521
 	protected boolean callSocketClosed() {
511
-		return myCallbackManager.getCallbackType("OnSocketClosed").call();
522
+		return myCallbackManager.getCallbackType(SocketCloseListener.class).call();
512
 	}
523
 	}
513
 
524
 
514
 	/**
525
 	/**
518
 	 * @return true if a method was called, false otherwise
529
 	 * @return true if a method was called, false otherwise
519
 	 */
530
 	 */
520
 	protected boolean callPingFailed() {
531
 	protected boolean callPingFailed() {
521
-		return myCallbackManager.getCallbackType("OnPingFailed").call();
532
+		return myCallbackManager.getCallbackType(PingFailureListener.class).call();
522
 	}
533
 	}
523
 
534
 
524
 	/**
535
 	/**
528
 	 * @return true if a method was called, false otherwise
539
 	 * @return true if a method was called, false otherwise
529
 	 */
540
 	 */
530
 	protected boolean callPingSent() {
541
 	protected boolean callPingSent() {
531
-		return myCallbackManager.getCallbackType("OnPingSent").call();
542
+		return myCallbackManager.getCallbackType(PingSentListener.class).call();
532
 	}
543
 	}
533
 
544
 
534
 	/**
545
 	/**
538
 	 * @return true if a method was called, false otherwise
549
 	 * @return true if a method was called, false otherwise
539
 	 */
550
 	 */
540
 	protected boolean callPingSuccess() {
551
 	protected boolean callPingSuccess() {
541
-		return myCallbackManager.getCallbackType("OnPingSuccess").call();
552
+		return myCallbackManager.getCallbackType(PingSuccessListener.class).call();
542
 	}
553
 	}
543
 
554
 
544
 	/**
555
 	/**
556
 		if (!h005Info.containsKey("USERMODES")) { parseUserModes(); }
567
 		if (!h005Info.containsKey("USERMODES")) { parseUserModes(); }
557
 		if (!h005Info.containsKey("CHANMODES")) { parseChanModes(); }
568
 		if (!h005Info.containsKey("CHANMODES")) { parseChanModes(); }
558
 
569
 
559
-		return getCallbackManager().getCallbackType("OnPost005").call();
570
+		return getCallbackManager().getCallbackType(Post005Listener.class).call();
560
 	}
571
 	}
561
 
572
 
562
 	//---------------------------------------------------------------------------
573
 	//---------------------------------------------------------------------------

+ 3
- 1
src/com/dmdirc/parser/irc/Process001.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ServerReadyListener;
26
+
25
 /**
27
 /**
26
  * Process a 001 message.
28
  * Process a 001 message.
27
  */
29
  */
74
 	 * @return true if a method was called, false otherwise
76
 	 * @return true if a method was called, false otherwise
75
 	 */	
77
 	 */	
76
 	protected boolean callServerReady() {
78
 	protected boolean callServerReady() {
77
-		return getCallbackManager().getCallbackType("OnServerReady").call();
79
+		return getCallbackManager().getCallbackType(ServerReadyListener.class).call();
78
 	}
80
 	}
79
 	
81
 	
80
 	/**
82
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/Process004005.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.NetworkDetectedListener;
26
+
25
 /**
27
 /**
26
  * Process ISUPPORT lines.
28
  * Process ISUPPORT lines.
27
  */
29
  */
132
 		final String ircdVersion = myParser.getIRCD(false);
134
 		final String ircdVersion = myParser.getIRCD(false);
133
 		final String ircdType = myParser.getIRCD(true);
135
 		final String ircdType = myParser.getIRCD(true);
134
 		
136
 		
135
-		return getCallbackManager().getCallbackType("OnGotNetwork").call(networkName, ircdVersion, ircdType);
137
+		return getCallbackManager().getCallbackType(NetworkDetectedListener.class).call(networkName, ircdVersion, ircdType);
136
 	}
138
 	}
137
 	
139
 	
138
 	/**
140
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/Process464.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.PasswordRequiredListener;
26
+
25
 /**
27
 /**
26
  * Process a 464 message.
28
  * Process a 464 message.
27
  */
29
  */
56
 	 * @return true if a method was called, false otherwise
58
 	 * @return true if a method was called, false otherwise
57
 	 */
59
 	 */
58
 	protected boolean callPasswordRequired() {
60
 	protected boolean callPasswordRequired() {
59
-		return getCallbackManager().getCallbackType("OnPasswordRequired").call();
61
+		return getCallbackManager().getCallbackType(PasswordRequiredListener.class).call();
60
 	}
62
 	}
61
 	
63
 	
62
 	/**
64
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/ProcessAway.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.AwayStateListener;
26
+
25
 /**
27
 /**
26
  * Process an Away/Back message.
28
  * Process an Away/Back message.
27
  */
29
  */
52
 	 * @return true if a method was called, false otherwise
54
 	 * @return true if a method was called, false otherwise
53
 	 */
55
 	 */
54
 	protected boolean callAwayState(boolean currentState, String reason) {
56
 	protected boolean callAwayState(boolean currentState, String reason) {
55
-		return myParser.getCallbackManager().getCallbackType("OnAwayState").call(currentState, reason);
57
+		return myParser.getCallbackManager().getCallbackType(AwayStateListener.class).call(currentState, reason);
56
 	}
58
 	}
57
 	
59
 	
58
 	/**
60
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/ProcessInvite.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.InviteListener;
26
+
25
 /**
27
 /**
26
  * Process an Invite Request.
28
  * Process an Invite Request.
27
  */
29
  */
49
 	 * @return true if a method was called, false otherwise
51
 	 * @return true if a method was called, false otherwise
50
 	 */
52
 	 */
51
 	protected boolean callInvite(final String userHost, final String channel) {
53
 	protected boolean callInvite(final String userHost, final String channel) {
52
-		return getCallbackManager().getCallbackType("OnInvite").call(userHost, channel);
54
+		return getCallbackManager().getCallbackType(InviteListener.class).call(userHost, channel);
53
 	}
55
 	}
54
 	
56
 	
55
 	/**
57
 	/**

+ 5
- 2
src/com/dmdirc/parser/irc/ProcessJoin.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelJoinListener;
26
+import com.dmdirc.parser.interfaces.callbacks.ChannelSelfJoinListener;
27
+
25
 /**
28
 /**
26
  * Process a channel join.
29
  * Process a channel join.
27
  */
30
  */
106
 	 * @return true if a method was called, false otherwise
109
 	 * @return true if a method was called, false otherwise
107
 	 */
110
 	 */
108
 	protected boolean callChannelJoin(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient) {
111
 	protected boolean callChannelJoin(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient) {
109
-		return getCallbackManager().getCallbackType("OnChannelJoin").call(cChannel, cChannelClient);
112
+		return getCallbackManager().getCallbackType(ChannelJoinListener.class).call(cChannel, cChannelClient);
110
 	}
113
 	}
111
 	
114
 	
112
 	/**
115
 	/**
117
 	 * @return true if a method was called, false otherwise
120
 	 * @return true if a method was called, false otherwise
118
 	 */
121
 	 */
119
 	protected boolean callChannelSelfJoin(final ChannelInfo cChannel) {
122
 	protected boolean callChannelSelfJoin(final ChannelInfo cChannel) {
120
-		return  getCallbackManager().getCallbackType("OnChannelSelfJoin").call(cChannel);
123
+		return  getCallbackManager().getCallbackType(ChannelSelfJoinListener.class).call(cChannel);
121
 	}
124
 	}
122
 	
125
 	
123
 	/**
126
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/ProcessKick.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelKickListener;
26
+
25
 /**
27
 /**
26
  * Process a channel kick.
28
  * Process a channel kick.
27
  */
29
  */
88
 	 * @return true if a method was called, false otherwise
90
 	 * @return true if a method was called, false otherwise
89
 	 */
91
 	 */
90
 	protected boolean callChannelKick(ChannelInfo cChannel, ChannelClientInfo cKickedClient, ChannelClientInfo cKickedByClient, String sReason, String sKickedByHost) {
92
 	protected boolean callChannelKick(ChannelInfo cChannel, ChannelClientInfo cKickedClient, ChannelClientInfo cKickedByClient, String sReason, String sKickedByHost) {
91
-		return getCallbackManager().getCallbackType("OnChannelKick").call(cChannel, cKickedClient, cKickedByClient, sReason, sKickedByHost);
93
+		return getCallbackManager().getCallbackType(ChannelKickListener.class).call(cChannel, cKickedClient, cKickedByClient, sReason, sKickedByHost);
92
 	}
94
 	}
93
 	
95
 	
94
 	/**
96
 	/**

+ 2
- 1
src/com/dmdirc/parser/irc/ProcessListModes.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelListModeListener;
25
 import java.util.List;
26
 import java.util.List;
26
 import java.util.LinkedList;
27
 import java.util.LinkedList;
27
 import java.util.Queue;
28
 import java.util.Queue;
227
 	 * @return true if a method was called, false otherwise
228
 	 * @return true if a method was called, false otherwise
228
 	 */
229
 	 */
229
 	protected boolean callChannelGotListModes(ChannelInfo cChannel) {
230
 	protected boolean callChannelGotListModes(ChannelInfo cChannel) {
230
-		return getCallbackManager().getCallbackType("OnChannelGotListModes").call(cChannel);
231
+		return getCallbackManager().getCallbackType(ChannelListModeListener.class).call(cChannel);
231
 	}
232
 	}
232
 	
233
 	
233
 	/**
234
 	/**

+ 7
- 3
src/com/dmdirc/parser/irc/ProcessMOTD.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.MotdEndListener;
26
+import com.dmdirc.parser.interfaces.callbacks.MotdLineListener;
27
+import com.dmdirc.parser.interfaces.callbacks.MotdStartListener;
28
+
25
 /**
29
 /**
26
  * Process a MOTD Related Line.
30
  * Process a MOTD Related Line.
27
  */
31
  */
53
 	 * @return true if a method was called, false otherwise
57
 	 * @return true if a method was called, false otherwise
54
 	 */
58
 	 */
55
 	protected boolean callMOTDEnd(final boolean noMOTD, final String data) {
59
 	protected boolean callMOTDEnd(final boolean noMOTD, final String data) {
56
-		return getCallbackManager().getCallbackType("OnMOTDEnd").call(noMOTD, data);
60
+		return getCallbackManager().getCallbackType(MotdEndListener.class).call(noMOTD, data);
57
 	}
61
 	}
58
 	
62
 	
59
 	/**
63
 	/**
64
 	 * @return true if a method was called, false otherwise
68
 	 * @return true if a method was called, false otherwise
65
 	 */
69
 	 */
66
 	protected boolean callMOTDLine(final String data) {
70
 	protected boolean callMOTDLine(final String data) {
67
-		return getCallbackManager().getCallbackType("OnMOTDLine").call(data);
71
+		return getCallbackManager().getCallbackType(MotdLineListener.class).call(data);
68
 	}
72
 	}
69
 	
73
 	
70
 	/**
74
 	/**
75
 	 * @return true if a method was called, false otherwise
79
 	 * @return true if a method was called, false otherwise
76
 	 */
80
 	 */
77
 	protected boolean callMOTDStart(String data) {
81
 	protected boolean callMOTDStart(String data) {
78
-		return getCallbackManager().getCallbackType("OnMOTDStart").call(data);
82
+		return getCallbackManager().getCallbackType(MotdStartListener.class).call(data);
79
 	}
83
 	}
80
 	
84
 	
81
 	/**
85
 	/**

+ 30
- 15
src/com/dmdirc/parser/irc/ProcessMessage.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelActionListener;
26
+import com.dmdirc.parser.interfaces.callbacks.ChannelCtcpListener;
27
+import com.dmdirc.parser.interfaces.callbacks.ChannelCtcpReplyListener;
28
+import com.dmdirc.parser.interfaces.callbacks.ChannelMessageListener;
29
+import com.dmdirc.parser.interfaces.callbacks.ChannelNoticeListener;
30
+import com.dmdirc.parser.interfaces.callbacks.PrivateActionListener;
31
+import com.dmdirc.parser.interfaces.callbacks.PrivateCtcpListener;
32
+import com.dmdirc.parser.interfaces.callbacks.PrivateCtcpReplyListener;
33
+import com.dmdirc.parser.interfaces.callbacks.PrivateMessageListener;
34
+import com.dmdirc.parser.interfaces.callbacks.PrivateNoticeListener;
35
+import com.dmdirc.parser.interfaces.callbacks.UnknownActionListener;
36
+import com.dmdirc.parser.interfaces.callbacks.UnknownCtcpListener;
37
+import com.dmdirc.parser.interfaces.callbacks.UnknownCtcpReplyListener;
38
+import com.dmdirc.parser.interfaces.callbacks.UnknownMessageListener;
39
+import com.dmdirc.parser.interfaces.callbacks.UnknownNoticeListener;
25
 import java.util.regex.PatternSyntaxException;
40
 import java.util.regex.PatternSyntaxException;
26
 
41
 
27
 /**
42
 /**
222
 	 * @return true if a method was called, false otherwise
237
 	 * @return true if a method was called, false otherwise
223
 	 */
238
 	 */
224
 	protected boolean callChannelAction(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
239
 	protected boolean callChannelAction(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
225
-		return getCallbackManager().getCallbackType("OnChannelAction").call(cChannel, cChannelClient, sMessage, sHost);
240
+		return getCallbackManager().getCallbackType(ChannelActionListener.class).call(cChannel, cChannelClient, sMessage, sHost);
226
 	}
241
 	}
227
 	
242
 	
228
 	/**
243
 	/**
237
 	 * @return true if a method was called, false otherwise
252
 	 * @return true if a method was called, false otherwise
238
 	 */
253
 	 */
239
 	protected boolean callChannelCTCP(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sType, final String sMessage, final String sHost) {
254
 	protected boolean callChannelCTCP(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sType, final String sMessage, final String sHost) {
240
-		return getCallbackManager().getCallbackType("OnChannelCTCP").call(cChannel, cChannelClient, sType, sMessage, sHost);
255
+		return getCallbackManager().getCallbackType(ChannelCtcpListener.class).call(cChannel, cChannelClient, sType, sMessage, sHost);
241
 	}
256
 	}
242
 
257
 
243
 	/**
258
 	/**
252
 	 * @return true if a method was called, false otherwise
267
 	 * @return true if a method was called, false otherwise
253
 	 */
268
 	 */
254
 	protected boolean callChannelCTCPReply(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sType, final String sMessage, final String sHost) {
269
 	protected boolean callChannelCTCPReply(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sType, final String sMessage, final String sHost) {
255
-		return getCallbackManager().getCallbackType("OnChannelCTCPReply").call(cChannel, cChannelClient, sType, sMessage, sHost);
270
+		return getCallbackManager().getCallbackType(ChannelCtcpReplyListener.class).call(cChannel, cChannelClient, sType, sMessage, sHost);
256
 	}
271
 	}
257
 	
272
 	
258
 	/**
273
 	/**
266
 	 * @return true if a method was called, false otherwise
281
 	 * @return true if a method was called, false otherwise
267
 	 */
282
 	 */
268
 	protected boolean callChannelMessage(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
283
 	protected boolean callChannelMessage(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
269
-		return getCallbackManager().getCallbackType("OnChannelMessage").call(cChannel, cChannelClient, sMessage, sHost);
284
+		return getCallbackManager().getCallbackType(ChannelMessageListener.class).call(cChannel, cChannelClient, sMessage, sHost);
270
 	}
285
 	}
271
 	
286
 	
272
 	/**
287
 	/**
280
 	 * @return true if a method was called, false otherwise
295
 	 * @return true if a method was called, false otherwise
281
 	 */
296
 	 */
282
 	protected boolean callChannelNotice(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
297
 	protected boolean callChannelNotice(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
283
-		return getCallbackManager().getCallbackType("OnChannelNotice").call(cChannel, cChannelClient, sMessage, sHost);
298
+		return getCallbackManager().getCallbackType(ChannelNoticeListener.class).call(cChannel, cChannelClient, sMessage, sHost);
284
 	}
299
 	}
285
 	
300
 	
286
 	/**
301
 	/**
322
 	 * @return true if a method was called, false otherwise
337
 	 * @return true if a method was called, false otherwise
323
 	 */
338
 	 */
324
 	protected boolean callPrivateAction(final String sMessage, final String sHost) {
339
 	protected boolean callPrivateAction(final String sMessage, final String sHost) {
325
-		return getCallbackManager().getCallbackType("OnPrivateAction").call(sMessage, sHost);
340
+		return getCallbackManager().getCallbackType(PrivateActionListener.class).call(sMessage, sHost);
326
 	}
341
 	}
327
 
342
 
328
 	/**
343
 	/**
335
 	 * @return true if a method was called, false otherwise
350
 	 * @return true if a method was called, false otherwise
336
 	 */
351
 	 */
337
 	protected boolean callPrivateCTCP(final String sType, final String sMessage, final String sHost) {
352
 	protected boolean callPrivateCTCP(final String sType, final String sMessage, final String sHost) {
338
-		return getCallbackManager().getCallbackType("OnPrivateCTCP").call(sType, sMessage, sHost);
353
+		return getCallbackManager().getCallbackType(PrivateCtcpListener.class).call(sType, sMessage, sHost);
339
 	}
354
 	}
340
 
355
 
341
 	/**
356
 	/**
348
 	 * @return true if a method was called, false otherwise
363
 	 * @return true if a method was called, false otherwise
349
 	 */
364
 	 */
350
 	protected boolean callPrivateCTCPReply(final String sType, final String sMessage, final String sHost) {
365
 	protected boolean callPrivateCTCPReply(final String sType, final String sMessage, final String sHost) {
351
-		return getCallbackManager().getCallbackType("OnPrivateCTCPReply").call(sType, sMessage, sHost);
366
+		return getCallbackManager().getCallbackType(PrivateCtcpReplyListener.class).call(sType, sMessage, sHost);
352
 	}
367
 	}
353
 
368
 
354
 	/**
369
 	/**
360
 	 * @return true if a method was called, false otherwise
375
 	 * @return true if a method was called, false otherwise
361
 	 */
376
 	 */
362
 	protected boolean callPrivateMessage(final String sMessage, final String sHost) {
377
 	protected boolean callPrivateMessage(final String sMessage, final String sHost) {
363
-		return getCallbackManager().getCallbackType("OnPrivateMessage").call(sMessage, sHost);
378
+		return getCallbackManager().getCallbackType(PrivateMessageListener.class).call(sMessage, sHost);
364
 	}
379
 	}
365
 
380
 
366
 	/**
381
 	/**
372
 	 * @return true if a method was called, false otherwise
387
 	 * @return true if a method was called, false otherwise
373
 	 */
388
 	 */
374
 	protected boolean callPrivateNotice(final String sMessage, final String sHost) {
389
 	protected boolean callPrivateNotice(final String sMessage, final String sHost) {
375
-		return getCallbackManager().getCallbackType("OnPrivateNotice").call(sMessage, sHost);
390
+		return getCallbackManager().getCallbackType(PrivateNoticeListener.class).call(sMessage, sHost);
376
 	}
391
 	}
377
 	
392
 	
378
 	/**
393
 	/**
385
 	 * @return true if a method was called, false otherwise
400
 	 * @return true if a method was called, false otherwise
386
 	 */
401
 	 */
387
 	protected boolean callUnknownAction(final String sMessage, final String sTarget, final String sHost) {
402
 	protected boolean callUnknownAction(final String sMessage, final String sTarget, final String sHost) {
388
-		return getCallbackManager().getCallbackType("OnUnknownAction").call(sMessage, sTarget, sHost);
403
+		return getCallbackManager().getCallbackType(UnknownActionListener.class).call(sMessage, sTarget, sHost);
389
 	}
404
 	}
390
 
405
 
391
 	/**
406
 	/**
399
 	 * @return true if a method was called, false otherwise
414
 	 * @return true if a method was called, false otherwise
400
 	 */
415
 	 */
401
 	protected boolean callUnknownCTCP(final String sType, final String sMessage, final String sTarget, final String sHost) {
416
 	protected boolean callUnknownCTCP(final String sType, final String sMessage, final String sTarget, final String sHost) {
402
-		return getCallbackManager().getCallbackType("OnUnknownCTCP").call(sType, sMessage, sTarget, sHost);
417
+		return getCallbackManager().getCallbackType(UnknownCtcpListener.class).call(sType, sMessage, sTarget, sHost);
403
 	}
418
 	}
404
 
419
 
405
 	/**
420
 	/**
413
 	 * @return true if a method was called, false otherwise
428
 	 * @return true if a method was called, false otherwise
414
 	 */
429
 	 */
415
 	protected boolean callUnknownCTCPReply(final String sType, final String sMessage, final String sTarget, final String sHost) {
430
 	protected boolean callUnknownCTCPReply(final String sType, final String sMessage, final String sTarget, final String sHost) {
416
-		return getCallbackManager().getCallbackType("OnUnknownCTCPReply").call(sType, sMessage, sTarget, sHost);
431
+		return getCallbackManager().getCallbackType(UnknownCtcpReplyListener.class).call(sType, sMessage, sTarget, sHost);
417
 	}
432
 	}
418
 
433
 
419
 	/**
434
 	/**
426
 	 * @return true if a method was called, false otherwise
441
 	 * @return true if a method was called, false otherwise
427
 	 */
442
 	 */
428
 	protected boolean callUnknownMessage(final String sMessage, final String sTarget, final String sHost) {
443
 	protected boolean callUnknownMessage(final String sMessage, final String sTarget, final String sHost) {
429
-		return getCallbackManager().getCallbackType("OnUnknownMessage").call(sMessage, sTarget, sHost);
444
+		return getCallbackManager().getCallbackType(UnknownMessageListener.class).call(sMessage, sTarget, sHost);
430
 	}
445
 	}
431
 
446
 
432
 	/**
447
 	/**
439
 	 * @return true if a method was called, false otherwise
454
 	 * @return true if a method was called, false otherwise
440
 	 */
455
 	 */
441
 	protected boolean callUnknownNotice(final String sMessage, final String sTarget, final String sHost) {
456
 	protected boolean callUnknownNotice(final String sMessage, final String sTarget, final String sHost) {
442
-		return getCallbackManager().getCallbackType("OnUnknownNotice").call(sMessage, sTarget, sHost);
457
+		return getCallbackManager().getCallbackType(UnknownNoticeListener.class).call(sMessage, sTarget, sHost);
443
 	}
458
 	}
444
 
459
 
445
 	
460
 	

+ 12
- 6
src/com/dmdirc/parser/irc/ProcessMode.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelModeChangeListener;
26
+import com.dmdirc.parser.interfaces.callbacks.ChannelNonUserModeChangeListener;
27
+import com.dmdirc.parser.interfaces.callbacks.ChannelSingleModeChangeListener;
28
+import com.dmdirc.parser.interfaces.callbacks.ChannelUserModeChangeListener;
29
+import com.dmdirc.parser.interfaces.callbacks.UserModeChangeListener;
30
+import com.dmdirc.parser.interfaces.callbacks.UserModeDiscoveryListener;
25
 import com.dmdirc.parser.irc.callbacks.CallbackObject;
31
 import com.dmdirc.parser.irc.callbacks.CallbackObject;
26
 import java.util.Calendar;
32
 import java.util.Calendar;
27
 
33
 
91
 		CallbackObject cbNonUser = null;
97
 		CallbackObject cbNonUser = null;
92
 
98
 
93
 		if (!sParam.equals("324")) {
99
 		if (!sParam.equals("324")) {
94
-			cbSingle = getCallbackManager().getCallbackType("OnChannelSingleModeChanged");
95
-			cbNonUser = getCallbackManager().getCallbackType("OnChannelNonUserModeChanged");
100
+			cbSingle = getCallbackManager().getCallbackType(ChannelSingleModeChangeListener.class);
101
+			cbNonUser = getCallbackManager().getCallbackType(ChannelNonUserModeChangeListener.class);
96
 		}
102
 		}
97
 		
103
 		
98
 		iChannel = getChannelInfo(sChannelName);
104
 		iChannel = getChannelInfo(sChannelName);
274
 	 * @return true if a method was called, false otherwise
280
 	 * @return true if a method was called, false otherwise
275
 	 */
281
 	 */
276
 	protected boolean callChannelModeChanged(ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sHost, String sModes) {
282
 	protected boolean callChannelModeChanged(ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sHost, String sModes) {
277
-		return getCallbackManager().getCallbackType("OnChannelModeChanged").call(cChannel, cChannelClient, sHost, sModes);
283
+		return getCallbackManager().getCallbackType(ChannelModeChangeListener.class).call(cChannel, cChannelClient, sHost, sModes);
278
 	}
284
 	}
279
 	
285
 	
280
 	/**
286
 	/**
289
 	 * @return true if a method was called, false otherwise
295
 	 * @return true if a method was called, false otherwise
290
 	 */
296
 	 */
291
 	protected boolean callChannelUserModeChanged(ChannelInfo cChannel, ChannelClientInfo cChangedClient, ChannelClientInfo cSetByClient, String sHost, String sMode) {
297
 	protected boolean callChannelUserModeChanged(ChannelInfo cChannel, ChannelClientInfo cChangedClient, ChannelClientInfo cSetByClient, String sHost, String sMode) {
292
-		return getCallbackManager().getCallbackType("OnChannelUserModeChanged").call(cChannel, cChangedClient, cSetByClient, sHost, sMode);
298
+		return getCallbackManager().getCallbackType(ChannelUserModeChangeListener.class).call(cChannel, cChangedClient, cSetByClient, sHost, sMode);
293
 	}
299
 	}
294
 	
300
 	
295
 	/**
301
 	/**
302
 	 * @return true if a method was called, false otherwise
308
 	 * @return true if a method was called, false otherwise
303
 	 */
309
 	 */
304
 	protected boolean callUserModeChanged(ClientInfo cClient, String sSetby, String sModes) {
310
 	protected boolean callUserModeChanged(ClientInfo cClient, String sSetby, String sModes) {
305
-		return getCallbackManager().getCallbackType("OnUserModeChanged").call(cClient, sSetby, sModes);
311
+		return getCallbackManager().getCallbackType(UserModeChangeListener.class).call(cClient, sSetby, sModes);
306
 	}
312
 	}
307
 	
313
 	
308
 	/**
314
 	/**
314
 	 * @return true if a method was called, false otherwise
320
 	 * @return true if a method was called, false otherwise
315
 	 */
321
 	 */
316
 	protected boolean callUserModeDiscovered(ClientInfo cClient, String sModes) {
322
 	protected boolean callUserModeDiscovered(ClientInfo cClient, String sModes) {
317
-		return getCallbackManager().getCallbackType("OnUserModeDiscovered").call(cClient, sModes);
323
+		return getCallbackManager().getCallbackType(UserModeDiscoveryListener.class).call(cClient, sModes);
318
 	}	
324
 	}	
319
 	
325
 	
320
 	/**
326
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/ProcessNames.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelNamesListener;
26
+
25
 /**
27
 /**
26
  * Process a Names reply.
28
  * Process a Names reply.
27
  */
29
  */
106
 	 * @return true if a method was called, false otherwise
108
 	 * @return true if a method was called, false otherwise
107
 	 */
109
 	 */
108
 	protected boolean callChannelGotNames(ChannelInfo cChannel) {
110
 	protected boolean callChannelGotNames(ChannelInfo cChannel) {
109
-		return getCallbackManager().getCallbackType("OnChannelGotNames").call(cChannel);
111
+		return getCallbackManager().getCallbackType(ChannelNamesListener.class).call(cChannel);
110
 	}
112
 	}
111
 	
113
 	
112
 	/**
114
 	/**

+ 5
- 2
src/com/dmdirc/parser/irc/ProcessNick.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelNickChangeListener;
26
+import com.dmdirc.parser.interfaces.callbacks.NickChangeListener;
27
+
25
 /**
28
 /**
26
  * Process a Nick change.
29
  * Process a Nick change.
27
  */
30
  */
88
 	 * @return true if a method was called, false otherwise
91
 	 * @return true if a method was called, false otherwise
89
 	 */
92
 	 */
90
 	protected boolean callChannelNickChanged(ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sOldNick) {
93
 	protected boolean callChannelNickChanged(ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sOldNick) {
91
-		return getCallbackManager().getCallbackType("OnChannelNickChanged").call(cChannel, cChannelClient, sOldNick);
94
+		return getCallbackManager().getCallbackType(ChannelNickChangeListener.class).call(cChannel, cChannelClient, sOldNick);
92
 	}
95
 	}
93
 	
96
 	
94
 	/**
97
 	/**
100
 	 * @return true if a method was called, false otherwise
103
 	 * @return true if a method was called, false otherwise
101
 	 */
104
 	 */
102
 	protected boolean callNickChanged(ClientInfo cClient, String sOldNick) {
105
 	protected boolean callNickChanged(ClientInfo cClient, String sOldNick) {
103
-		return getCallbackManager().getCallbackType("OnNickChanged").call(cClient, sOldNick);
106
+		return getCallbackManager().getCallbackType(NickChangeListener.class).call(cClient, sOldNick);
104
 	}
107
 	}
105
 	
108
 	
106
 	/**
109
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/ProcessNickInUse.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.NickInUseListener;
26
+
25
 /**
27
 /**
26
  * Process a NickInUse message.
28
  * Process a NickInUse message.
27
  * Parser implements handling of this if Pre-001 and no other handler found,
29
  * Parser implements handling of this if Pre-001 and no other handler found,
73
 	 * @return true if a method was called, false otherwise
75
 	 * @return true if a method was called, false otherwise
74
 	 */
76
 	 */
75
 	protected boolean callNickInUse(final String nickname) {
77
 	protected boolean callNickInUse(final String nickname) {
76
-		return getCallbackManager().getCallbackType("OnNickInUse").call(nickname);
78
+		return getCallbackManager().getCallbackType(NickInUseListener.class).call(nickname);
77
 	}
79
 	}
78
 	
80
 	
79
 	/**
81
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/ProcessNoticeAuth.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.AuthNoticeListener;
26
+
25
 /**
27
 /**
26
  * Process a NoticeAuth message.
28
  * Process a NoticeAuth message.
27
  */
29
  */
45
 	 * @return true if a method was called, false otherwise
47
 	 * @return true if a method was called, false otherwise
46
 	 */
48
 	 */
47
 	protected boolean callNoticeAuth(final String data) {
49
 	protected boolean callNoticeAuth(final String data) {
48
-		return getCallbackManager().getCallbackType("OnNoticeAuth").call(data);
50
+		return getCallbackManager().getCallbackType(AuthNoticeListener.class).call(data);
49
 	}
51
 	}
50
 	
52
 	
51
 	/**
53
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/ProcessPart.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelPartListener;
26
+
25
 /**
27
 /**
26
  * Process a channel part.
28
  * Process a channel part.
27
  */
29
  */
84
 	 * @return true if a method was called, false otherwise
86
 	 * @return true if a method was called, false otherwise
85
 	 */
87
 	 */
86
 	protected boolean callChannelPart(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sReason) {
88
 	protected boolean callChannelPart(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sReason) {
87
-		return getCallbackManager().getCallbackType("OnChannelPart").call(cChannel, cChannelClient, sReason);
89
+		return getCallbackManager().getCallbackType(ChannelPartListener.class).call(cChannel, cChannelClient, sReason);
88
 	}
90
 	}
89
 	
91
 	
90
 	/**
92
 	/**

+ 4
- 2
src/com/dmdirc/parser/irc/ProcessQuit.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelQuitListener;
26
+import com.dmdirc.parser.interfaces.callbacks.QuitListener;
25
 import java.util.ArrayList;
27
 import java.util.ArrayList;
26
 
28
 
27
 /**
29
 /**
87
 	 * @return true if a method was called, false otherwise
89
 	 * @return true if a method was called, false otherwise
88
 	 */
90
 	 */
89
 	protected boolean callChannelQuit(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sReason) {
91
 	protected boolean callChannelQuit(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sReason) {
90
-		return getCallbackManager().getCallbackType("OnChannelQuit").call(cChannel, cChannelClient, sReason);
92
+		return getCallbackManager().getCallbackType(ChannelQuitListener.class).call(cChannel, cChannelClient, sReason);
91
 	}
93
 	}
92
 	
94
 	
93
 	/**
95
 	/**
99
 	 * @return true if a method was called, false otherwise
101
 	 * @return true if a method was called, false otherwise
100
 	 */
102
 	 */
101
 	protected boolean callQuit(final ClientInfo cClient, final String sReason) {
103
 	protected boolean callQuit(final ClientInfo cClient, final String sReason) {
102
-		return getCallbackManager().getCallbackType("OnQuit").call(cClient, sReason);
104
+		return getCallbackManager().getCallbackType(QuitListener.class).call(cClient, sReason);
103
 	}
105
 	}
104
 	
106
 	
105
 	/**
107
 	/**

+ 3
- 1
src/com/dmdirc/parser/irc/ProcessTopic.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.ChannelTopicListener;
26
+
25
 /**
27
 /**
26
  * Process a topic change.
28
  * Process a topic change.
27
  */
29
  */
75
 	 * @return true if a method was called, false otherwise
77
 	 * @return true if a method was called, false otherwise
76
 	 */
78
 	 */
77
 	protected boolean callChannelTopic(final ChannelInfo cChannel, final boolean bIsJoinTopic) {
79
 	protected boolean callChannelTopic(final ChannelInfo cChannel, final boolean bIsJoinTopic) {
78
-		return getCallbackManager().getCallbackType("OnChannelTopic").call(cChannel, bIsJoinTopic);
80
+		return getCallbackManager().getCallbackType(ChannelTopicListener.class).call(cChannel, bIsJoinTopic);
79
 	}
81
 	}
80
 	
82
 	
81
 	/**
83
 	/**

+ 7
- 3
src/com/dmdirc/parser/irc/ProcessWallops.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.WallDesyncListener;
26
+import com.dmdirc.parser.interfaces.callbacks.WallopListener;
27
+import com.dmdirc.parser.interfaces.callbacks.WalluserListener;
28
+
25
 /**
29
 /**
26
  * Process a WALLOPS Message.
30
  * Process a WALLOPS Message.
27
  */
31
  */
62
 	 * @return true if a method was called, false otherwise
66
 	 * @return true if a method was called, false otherwise
63
 	 */
67
 	 */
64
 	protected boolean callWallop(final String message, final String host) {
68
 	protected boolean callWallop(final String message, final String host) {
65
-		return getCallbackManager().getCallbackType("OnWallop").call(message, host);
69
+		return getCallbackManager().getCallbackType(WallopListener.class).call(message, host);
66
 	}
70
 	}
67
 	
71
 	
68
 	/**
72
 	/**
74
 	 * @return true if a method was called, false otherwise
78
 	 * @return true if a method was called, false otherwise
75
 	 */
79
 	 */
76
 	protected boolean callWalluser(final String message, final String host) {
80
 	protected boolean callWalluser(final String message, final String host) {
77
-		return getCallbackManager().getCallbackType("OnWalluser").call(message, host);
81
+		return getCallbackManager().getCallbackType(WalluserListener.class).call(message, host);
78
 	}
82
 	}
79
 	
83
 	
80
 	/**
84
 	/**
86
 	 * @return true if a method was called, false otherwise
90
 	 * @return true if a method was called, false otherwise
87
 	 */
91
 	 */
88
 	protected boolean callWallDesync(final String message, final String host) {
92
 	protected boolean callWallDesync(final String message, final String host) {
89
-		return getCallbackManager().getCallbackType("OnWallDesync").call(message, host);
93
+		return getCallbackManager().getCallbackType(WallDesyncListener.class).call(message, host);
90
 	}
94
 	}
91
 	
95
 	
92
 	
96
 	

+ 7
- 3
src/com/dmdirc/parser/irc/ProcessWho.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.AwayStateListener;
26
+import com.dmdirc.parser.interfaces.callbacks.ChannelOtherAwayStateListener;
27
+import com.dmdirc.parser.interfaces.callbacks.OtherAwayStateListener;
28
+
25
 /**
29
 /**
26
  * Process a /who reply.
30
  * Process a /who reply.
27
  */
31
  */
88
 	 * @return true if a method was called, false otherwise
92
 	 * @return true if a method was called, false otherwise
89
 	 */
93
 	 */
90
 	protected boolean callAwayState(boolean currentState, String reason) {
94
 	protected boolean callAwayState(boolean currentState, String reason) {
91
-		return getCallbackManager().getCallbackType("OnAwayState").call(currentState, reason);
95
+		return getCallbackManager().getCallbackType(AwayStateListener.class).call(currentState, reason);
92
 	}
96
 	}
93
 	
97
 	
94
 	/**
98
 	/**
100
 	 * @return true if a method was called, false otherwise
104
 	 * @return true if a method was called, false otherwise
101
 	 */
105
 	 */
102
 	protected boolean callAwayStateOther(final ClientInfo client, final boolean state) {
106
 	protected boolean callAwayStateOther(final ClientInfo client, final boolean state) {
103
-		return getCallbackManager().getCallbackType("OnAwayStateOther").call(client, state);
107
+		return getCallbackManager().getCallbackType(OtherAwayStateListener.class).call(client, state);
104
 	}
108
 	}
105
 	
109
 	
106
 	/**
110
 	/**
113
 	 * @return true if a method was called, false otherwise
117
 	 * @return true if a method was called, false otherwise
114
 	 */
118
 	 */
115
 	protected boolean callChannelAwayStateOther(final ChannelInfo channel, final ChannelClientInfo channelClient, final boolean state) {
119
 	protected boolean callChannelAwayStateOther(final ChannelInfo channel, final ChannelClientInfo channelClient, final boolean state) {
116
-		return getCallbackManager().getCallbackType("OnChannelAwayStateOther").call(channel, channelClient, state);
120
+		return getCallbackManager().getCallbackType(ChannelOtherAwayStateListener.class).call(channel, channelClient, state);
117
 	}
121
 	}
118
 	
122
 	
119
 	/**
123
 	/**

+ 2
- 1
src/com/dmdirc/parser/irc/ProcessingManager.java View File

22
 
22
 
23
 package com.dmdirc.parser.irc;
23
 package com.dmdirc.parser.irc;
24
 
24
 
25
+import com.dmdirc.parser.interfaces.callbacks.NumericListener;
25
 import java.util.Hashtable;
26
 import java.util.Hashtable;
26
 
27
 
27
 /**
28
 /**
213
 	 * @return true if a method was called, false otherwise
214
 	 * @return true if a method was called, false otherwise
214
 	 */
215
 	 */
215
 	protected boolean callNumeric(final int numeric, final String[] token) {
216
 	protected boolean callNumeric(final int numeric, final String[] token) {
216
-		return myParser.getCallbackManager().getCallbackType("OnNumeric").call(numeric, token);
217
+		return myParser.getCallbackManager().getCallbackType(NumericListener.class).call(numeric, token);
217
 	}
218
 	}
218
 
219
 
219
 }
220
 }

+ 184
- 160
src/com/dmdirc/parser/irc/callbacks/CallbackManager.java View File

19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
-
23
 package com.dmdirc.parser.irc.callbacks;
22
 package com.dmdirc.parser.irc.callbacks;
24
 
23
 
25
 import com.dmdirc.parser.interfaces.callbacks.*;
24
 import com.dmdirc.parser.interfaces.callbacks.*;
37
 public final class CallbackManager {
36
 public final class CallbackManager {
38
 
37
 
39
     private static final Class[] CLASSES = {
38
     private static final Class[] CLASSES = {
40
-        AwayStateListener.class, OtherAwayStateListener.class, ChannelOtherAwayStateListener.class,
41
-        ChannelActionListener.class, ChannelCtcpListener.class, ChannelCtcpReplyListener.class,
42
-        ChannelListModeListener.class, ChannelNamesListener.class, ChannelJoinListener.class,
43
-        ChannelKickListener.class, ChannelMessageListener.class, ChannelModeChangeListener.class,
39
+        AwayStateListener.class, OtherAwayStateListener.class,
40
+        ChannelOtherAwayStateListener.class, ChannelActionListener.class,
41
+        ChannelCtcpListener.class, ChannelCtcpReplyListener.class,
42
+        ChannelListModeListener.class, ChannelNamesListener.class,
43
+        ChannelJoinListener.class, ChannelKickListener.class,
44
+        ChannelMessageListener.class, ChannelModeChangeListener.class,
44
         ChannelNickChangeListener.class, ChannelNonUserModeChangeListener.class,
45
         ChannelNickChangeListener.class, ChannelNonUserModeChangeListener.class,
45
 	ChannelModeMessage.class, ChannelModeNotice.class,
46
 	ChannelModeMessage.class, ChannelModeNotice.class,
46
         ChannelNoticeListener.class, ChannelPartListener.class, ChannelQuitListener.class,
47
         ChannelNoticeListener.class, ChannelPartListener.class, ChannelQuitListener.class,
59
         WallDesyncListener.class, WallopListener.class, WalluserListener.class,
60
         WallDesyncListener.class, WallopListener.class, WalluserListener.class,
60
     };
61
     };
61
 
62
 
62
-	/** Reference to the parser object that owns this CallbackManager. */
63
-	IRCParser myParser;
64
-	
65
-	/** Hashtable used to store the different types of callback known. */
66
-	private final Map<String, CallbackObject> callbackHash = new Hashtable<String, CallbackObject>();
67
-	
68
-	/**
69
-	 * Constructor to create a CallbackManager.
70
-	 *
71
-	 * @param parser IRCParser that owns this callback manager.
72
-	 */
73
-	public CallbackManager(final IRCParser parser) {
74
-		myParser = parser;
75
-		
63
+    /** Reference to the parser object that owns this CallbackManager. */
64
+    IRCParser myParser;
65
+    /** Hashtable used to store the different types of callback known. */
66
+    private final Map<Class<? extends CallbackInterface>, CallbackObject> callbackHash
67
+            = new Hashtable<Class<? extends CallbackInterface>, CallbackObject>();
68
+
69
+    /**
70
+     * Constructor to create a CallbackManager.
71
+     *
72
+     * @param parser IRCParser that owns this callback manager.
73
+     */
74
+    public CallbackManager(final IRCParser parser) {
75
+        myParser = parser;
76
+
76
         for (Class<?> type : CLASSES) {
77
         for (Class<?> type : CLASSES) {
77
             if (type.isAnnotationPresent(SpecificCallback.class)) {
78
             if (type.isAnnotationPresent(SpecificCallback.class)) {
78
                 addCallbackType(new CallbackObjectSpecific(myParser, this,
79
                 addCallbackType(new CallbackObjectSpecific(myParser, this,
82
                         type.asSubclass(CallbackInterface.class)));
83
                         type.asSubclass(CallbackInterface.class)));
83
             }
84
             }
84
         }
85
         }
85
-	}
86
-
87
-	/**
88
-	 * Add new callback type.
89
-	 *
90
-	 * @param callback CallbackObject subclass for the callback.
91
-	 * @return if adding succeeded or not.
92
-	 */
93
-	public boolean addCallbackType(final CallbackObject callback) {
94
-		if (!callbackHash.containsKey(callback.getLowerName())) {
95
-			callbackHash.put(callback.getLowerName(), callback);
96
-			return true;
97
-		}
98
-		return false;
99
-	}
100
-	
101
-	/**
102
-	 * Remove a callback type.
103
-	 *
104
-	 * @param callback CallbackObject subclass to remove.
105
-	 * @return if removal succeeded or not.
106
-	 */
107
-	public boolean delCallbackType(final CallbackObject callback) {
108
-		if (callbackHash.containsKey(callback.getLowerName())) {
109
-			callbackHash.remove(callback.getLowerName());
110
-			return true;
111
-		}
112
-		return false;
113
-	}
114
-	
115
-	/**
116
-	 * Get reference to callback object.
117
-	 *
118
-	 * @param callbackName Name of callback object.
119
-	 * @return CallbackObject returns the callback object for this type
120
-	 */
121
-	public CallbackObject getCallbackType(final String callbackName) {
122
-		if (!callbackHash.containsKey(callbackName.toLowerCase())) {
123
-			throw new CallbackNotFoundException("Callback not found: " + callbackName);
124
-		}
125
-		
126
-		return callbackHash.get(callbackName.toLowerCase());
127
-	}
128
-	
129
-	/**
130
-	 * Remove all callbacks associated with a specific object.
131
-	 *
132
-	 * @param o instance of ICallbackInterface to remove.
133
-	 */
134
-	public void delAllCallback(final CallbackInterface o) {
135
-		for (CallbackObject cb : callbackHash.values()) {
136
-			if (cb != null) { cb.del(o); }
137
-		}
138
-	}
139
-	
140
-	/**
141
-	 * Add all callbacks.
142
-	 *
143
-	 * @param o instance of ICallbackInterface to add.
144
-	 */
145
-	public void addAllCallback(final CallbackInterface o) {
146
-		for (CallbackObject cb : callbackHash.values()) {
147
-			if (cb != null) { cb.add(o); }
148
-		}
149
-	}
150
-	
151
-	/**
152
-	 * Add a callback.
153
- 	 * This method will throw a CallbackNotFoundException if the callback does not exist.
154
-	 *
155
-	 * @param callbackName Name of callback object.
156
-	 * @param o instance of ICallbackInterface to add.
157
-	 * @throws CallbackNotFoundException If callback is not found.
158
-	 * @throws NullPointerException If 'o' is null
159
-	 */
160
-	public void addCallback(final String callbackName, final CallbackInterface o) throws CallbackNotFoundException {
161
-		if (o == null) {
162
-			throw new NullPointerException("CallbackInterface is null");
163
-		}
164
-		
165
-		final CallbackObject cb = getCallbackType(callbackName);
166
-		
167
-		if (cb != null) { cb.add(o); }
168
-	}
169
-	
170
-	/**
171
-	 * Add a callback with a specific target.
172
- 	 * This method will throw a CallbackNotFoundException if the callback does not exist.
173
-	 *
174
-	 * @param callbackName Name of callback object.
175
-	 * @param o instance of ICallbackInterface to add.
176
-	 * @param target Parameter to specify that a callback should only fire for specific things
177
-	 * @throws CallbackNotFoundException If callback is not found.
178
-	 * @throws NullPointerException If 'o' is null
179
-	 */
180
-	public void addCallback(final String callbackName, final CallbackInterface o, final String target) throws CallbackNotFoundException {
181
-		if (o == null) { throw new NullPointerException("CallbackInterface is null"); }
182
-		((CallbackObjectSpecific) getCallbackType(callbackName)).add(o,target);
183
-	}
184
-	
185
-	/**
186
-	 * Add a callback without an exception.
187
-	 * This should be used if a callback is not essential for execution (ie the DebugOut callback)
188
-	 *
189
-	 * @param callbackName Name of callback object.
190
-	 * @param o instance of ICallbackInterface to add.
191
-	 * @return true/false if the callback was added or not.
192
-	 */
193
-	public boolean addNonCriticalCallback(final String callbackName, final CallbackInterface o)  {
194
-		try {
195
-			addCallback(callbackName, o);
196
-			return true;
197
-		} catch (CallbackNotFoundException e) { return false; }
198
-	}
199
-	
200
-	/**
201
-	 * Add a callback with a specific target.
202
-	 * This should be used if a callback is not essential for execution
203
-	 *
204
-	 * @param callbackName Name of callback object.
205
-	 * @param o instance of ICallbackInterface to add.
206
-	 * @param target Parameter to specify that a callback should only fire for specific things
207
-	 * @return true/false if the callback was added or not.
208
-	 */
209
-	public boolean addNonCriticalCallback(final String callbackName, final CallbackInterface o, final String target) {
210
-		try {
211
-			addCallback(callbackName, o, target);
212
-			return true;
213
-		} catch (CallbackNotFoundException e) { return false;	}
214
-	}
215
-	
216
-	
217
-	/**
218
-	 * Remove a callback.
219
-	 *
220
-	 * @param callbackName Name of callback object.
221
-	 * @param o instance of ICallbackInterface to remove.
222
-	 */
223
-	public void delCallback(final String callbackName, final CallbackInterface o) {
224
-		getCallbackType(callbackName).del(o);
225
-	}
86
+    }
87
+
88
+    /**
89
+     * Add new callback type.
90
+     *
91
+     * @param callback CallbackObject subclass for the callback.
92
+     * @return if adding succeeded or not.
93
+     */
94
+    public boolean addCallbackType(final CallbackObject callback) {
95
+        if (!callbackHash.containsKey(callback.getType())) {
96
+            callbackHash.put(callback.getType(), callback);
97
+            return true;
98
+        }
99
+
100
+        return false;
101
+    }
102
+
103
+    /**
104
+     * Remove a callback type.
105
+     *
106
+     * @param callback CallbackObject subclass to remove.
107
+     * @return if removal succeeded or not.
108
+     */
109
+    public boolean delCallbackType(final CallbackObject callback) {
110
+        if (callbackHash.containsKey(callback.getType())) {
111
+            callbackHash.remove(callback.getType());
112
+            return true;
113
+        }
114
+
115
+        return false;
116
+    }
117
+
118
+    /**
119
+     * Get reference to callback object.
120
+     *
121
+     * @param callback Name of type of callback object.
122
+     * @return CallbackObject returns the callback object for this type
123
+     */
124
+    public CallbackObject getCallbackType(final Class<? extends CallbackInterface> callback) {
125
+        if (!callbackHash.containsKey(callback)) {
126
+            throw new CallbackNotFoundException("Callback not found: " + callback.getName());
127
+        }
128
+
129
+        return callbackHash.get(callback);
130
+    }
131
+
132
+    /**
133
+     * Remove all callbacks associated with a specific object.
134
+     *
135
+     * @param o instance of ICallbackInterface to remove.
136
+     */
137
+    public void delAllCallback(final CallbackInterface o) {
138
+        for (CallbackObject cb : callbackHash.values()) {
139
+            if (cb != null) {
140
+                cb.del(o);
141
+            }
142
+        }
143
+    }
144
+
145
+    /**
146
+     * Add all callbacks.
147
+     *
148
+     * @param o instance of ICallbackInterface to add.
149
+     */
150
+    public void addAllCallback(final CallbackInterface o) {
151
+        for (CallbackObject cb : callbackHash.values()) {
152
+            if (cb != null) {
153
+                cb.add(o);
154
+            }
155
+        }
156
+    }
157
+
158
+    /**
159
+     * Add a callback.
160
+     * This method will throw a CallbackNotFoundException if the callback does not exist.
161
+     *
162
+     * @param <T> The type of callback
163
+     * @param callback Type of callback object
164
+     * @param o instance of ICallbackInterface to add.
165
+     * @throws CallbackNotFoundException If callback is not found.
166
+     * @throws NullPointerException If 'o' is null
167
+     */
168
+    public <T extends CallbackInterface> void addCallback(
169
+            final Class<T> callback, final T o) throws CallbackNotFoundException {
170
+        if (o == null) {
171
+            throw new NullPointerException("CallbackInterface is null");
172
+        }
173
+
174
+        final CallbackObject cb = getCallbackType(callback);
175
+
176
+        if (cb != null) {
177
+            cb.add(o);
178
+        }
179
+    }
180
+
181
+    /**
182
+     * Add a callback with a specific target.
183
+     * This method will throw a CallbackNotFoundException if the callback does not exist.
184
+     *
185
+     * @param <T> The type of callback
186
+     * @param callback Type of callback object.
187
+     * @param o instance of ICallbackInterface to add.
188
+     * @param target Parameter to specify that a callback should only fire for specific things
189
+     * @throws CallbackNotFoundException If callback is not found.
190
+     * @throws NullPointerException If 'o' is null
191
+     */
192
+    public <T extends CallbackInterface> void addCallback(
193
+            final Class<T> callback,
194
+            final T o, final String target) throws CallbackNotFoundException {
195
+        if (o == null) {
196
+            throw new NullPointerException("CallbackInterface is null");
197
+        }
198
+        
199
+        ((CallbackObjectSpecific) getCallbackType(callback)).add(o, target);
200
+    }
201
+
202
+    /**
203
+     * Add a callback without an exception.
204
+     * This should be used if a callback is not essential for execution (ie the DebugOut callback)
205
+     *
206
+     * @param <T> The type of callback object
207
+     * @param callback Type of callback object.
208
+     * @param o instance of ICallbackInterface to add.
209
+     * @return true/false if the callback was added or not.
210
+     */
211
+    public <T extends CallbackInterface> boolean addNonCriticalCallback(
212
+            final Class<T> callback, final T o) {
213
+        try {
214
+            addCallback(callback, o);
215
+            return true;
216
+        } catch (CallbackNotFoundException e) {
217
+            return false;
218
+        }
219
+    }
220
+
221
+    /**
222
+     * Add a callback with a specific target.
223
+     * This should be used if a callback is not essential for execution
224
+     *
225
+     * @param <T> The type of callback
226
+     * @param callback Type of callback object.
227
+     * @param o instance of ICallbackInterface to add.
228
+     * @param target Parameter to specify that a callback should only fire for specific things
229
+     * @return true/false if the callback was added or not.
230
+     */
231
+    public <T extends CallbackInterface> boolean addNonCriticalCallback(
232
+            final Class<T> callback, final T o, final String target) {
233
+        try {
234
+            addCallback(callback, o, target);
235
+            return true;
236
+        } catch (CallbackNotFoundException e) {
237
+            return false;
238
+        }
239
+    }
226
 
240
 
241
+    /**
242
+     * Remove a callback.
243
+     *
244
+     * @param callback Type of callback object.
245
+     * @param o instance of ICallbackInterface to remove.
246
+     */
247
+    public void delCallback(final Class<? extends CallbackInterface> callback,
248
+            final CallbackInterface o) {
249
+        getCallbackType(callback).del(o);
250
+    }
227
 }
251
 }

+ 12
- 17
src/com/dmdirc/parser/irc/callbacks/CallbackObject.java View File

26
 import com.dmdirc.parser.irc.ParserError;
26
 import com.dmdirc.parser.irc.ParserError;
27
 import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
27
 import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
28
 
28
 
29
+import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
29
 import java.lang.annotation.Annotation;
30
 import java.lang.annotation.Annotation;
30
 import java.lang.reflect.Constructor;
31
 import java.lang.reflect.Constructor;
31
 import java.lang.reflect.InvocationTargetException;
32
 import java.lang.reflect.InvocationTargetException;
96
 	 * @return true if error call succeeded, false otherwise
97
 	 * @return true if error call succeeded, false otherwise
97
 	 */
98
 	 */
98
 	protected final boolean callErrorInfo(final ParserError errorInfo) {
99
 	protected final boolean callErrorInfo(final ParserError errorInfo) {
99
-		return myManager.getCallbackType("OnErrorInfo").call(errorInfo);
100
+		return myManager.getCallbackType(ErrorInfoListener.class).call(errorInfo);
100
 	}
101
 	}
101
 	
102
 	
102
 	/**
103
 	/**
112
 	 * @param eMethod Object to remove callback to.
113
 	 * @param eMethod Object to remove callback to.
113
 	 */
114
 	 */
114
 	public void del(final CallbackInterface eMethod) { delCallback(eMethod); }
115
 	public void del(final CallbackInterface eMethod) { delCallback(eMethod); }
115
-	
116
-	/**
117
-	 * Get the name for this callback.
118
-	 *
119
-	 * @return Name of callback
120
-	 */
121
-	public String getName() {
122
-		return "On" + type.getSimpleName().substring(1); // Trim the 'I'
123
-	}
124
-	
125
-	/**
126
-	 * Get the name for this callback in lowercase.
127
-	 *
128
-	 * @return Name of callback, in lowercase
129
-	 */
130
-	public final String getLowerName() { return this.getName().toLowerCase(); }
131
 
116
 
117
+    /**
118
+     * Retrieves the type of callback that this callback object is for.
119
+     *
120
+     * @return This object's type
121
+     * @since 0.6.3m2
122
+     */
123
+    public Class<? extends CallbackInterface> getType() {
124
+        return type;
125
+    }
126
+	
132
     /**
127
     /**
133
      * Actually calls this callback. The specified arguments must match those
128
      * Actually calls this callback. The specified arguments must match those
134
      * specified in the callback's interface, or an error will be raised.
129
      * specified in the callback's interface, or an error will be raised.

+ 23
- 15
test/com/dmdirc/parser/irc/IRCParserTest.java View File

31
 import com.dmdirc.harness.parser.TestIPost005;
31
 import com.dmdirc.harness.parser.TestIPost005;
32
 import com.dmdirc.harness.parser.TestIPrivateMessage;
32
 import com.dmdirc.harness.parser.TestIPrivateMessage;
33
 import com.dmdirc.harness.parser.TestIPrivateAction;
33
 import com.dmdirc.harness.parser.TestIPrivateAction;
34
+import com.dmdirc.parser.interfaces.callbacks.AuthNoticeListener;
34
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
35
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
35
 import com.dmdirc.parser.interfaces.callbacks.AwayStateListener;
36
 import com.dmdirc.parser.interfaces.callbacks.AwayStateListener;
36
 import com.dmdirc.parser.interfaces.callbacks.ChannelKickListener;
37
 import com.dmdirc.parser.interfaces.callbacks.ChannelKickListener;
37
 
38
 
39
+import com.dmdirc.parser.interfaces.callbacks.ConnectErrorListener;
38
 import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
40
 import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
41
+import com.dmdirc.parser.interfaces.callbacks.NumericListener;
42
+import com.dmdirc.parser.interfaces.callbacks.Post005Listener;
43
+import com.dmdirc.parser.interfaces.callbacks.PrivateActionListener;
44
+import com.dmdirc.parser.interfaces.callbacks.PrivateCtcpListener;
45
+import com.dmdirc.parser.interfaces.callbacks.PrivateMessageListener;
46
+import com.dmdirc.parser.interfaces.callbacks.ServerErrorListener;
39
 import java.util.Arrays;
47
 import java.util.Arrays;
40
 import java.util.List;
48
 import java.util.List;
41
 
49
 
55
 
63
 
56
         try {
64
         try {
57
             final IRCParser myParser = new IRCParser();
65
             final IRCParser myParser = new IRCParser();
58
-            myParser.getCallbackManager().addCallback("non-existant", mock(AwayStateListener.class));
66
+            myParser.getCallbackManager().addCallback(null, mock(AwayStateListener.class));
59
         } catch (CallbackNotFoundException ex) {
67
         } catch (CallbackNotFoundException ex) {
60
             res = true;
68
             res = true;
61
         }
69
         }
69
         final ErrorInfoListener error = mock(ErrorInfoListener.class);
77
         final ErrorInfoListener error = mock(ErrorInfoListener.class);
70
 
78
 
71
         final TestParser myParser = new TestParser();
79
         final TestParser myParser = new TestParser();
72
-        myParser.getCallbackManager().addCallback("onErrorInfo", error);
80
+        myParser.getCallbackManager().addCallback(ErrorInfoListener.class, error);
73
         myParser.injectConnectionStrings();
81
         myParser.injectConnectionStrings();
74
         myParser.nick = "nick2";
82
         myParser.nick = "nick2";
75
         myParser.injectConnectionStrings();
83
         myParser.injectConnectionStrings();
86
         si.setUseSocks(true);
94
         si.setUseSocks(true);
87
         
95
         
88
         final IRCParser myParser = new IRCParser(si);
96
         final IRCParser myParser = new IRCParser(si);
89
-        myParser.getCallbackManager().addCallback("onConnectError", tice);
97
+        myParser.getCallbackManager().addCallback(ConnectErrorListener.class, tice);
90
         myParser.setBindIP("0.0.0.0");
98
         myParser.setBindIP("0.0.0.0");
91
         myParser.run();
99
         myParser.run();
92
         
100
         
168
         final TestIServerError test = new TestIServerError();
176
         final TestIServerError test = new TestIServerError();
169
 
177
 
170
         final TestParser parser = new TestParser();
178
         final TestParser parser = new TestParser();
171
-        parser.getCallbackManager().addCallback("onServerError", test);
179
+        parser.getCallbackManager().addCallback(ServerErrorListener.class, test);
172
         parser.injectLine("ERROR :You smell of cheese");
180
         parser.injectLine("ERROR :You smell of cheese");
173
 
181
 
174
         assertNotNull(test.message);
182
         assertNotNull(test.message);
180
     public void testAuthNotices() throws CallbackNotFoundException {
188
     public void testAuthNotices() throws CallbackNotFoundException {
181
         final TestINoticeAuth test = new TestINoticeAuth();
189
         final TestINoticeAuth test = new TestINoticeAuth();
182
         final TestParser parser = new TestParser();
190
         final TestParser parser = new TestParser();
183
-        parser.getCallbackManager().addCallback("onNoticeAuth", test);
191
+        parser.getCallbackManager().addCallback(AuthNoticeListener.class, test);
184
         parser.sendConnectionStrings();
192
         parser.sendConnectionStrings();
185
         parser.injectLine("NOTICE AUTH :Random auth notice?");
193
         parser.injectLine("NOTICE AUTH :Random auth notice?");
186
 
194
 
199
     public void testPre001NickChange() throws CallbackNotFoundException {
207
     public void testPre001NickChange() throws CallbackNotFoundException {
200
         final TestINoticeAuth test = new TestINoticeAuth();
208
         final TestINoticeAuth test = new TestINoticeAuth();
201
         final TestParser parser = new TestParser();
209
         final TestParser parser = new TestParser();
202
-        parser.getCallbackManager().addCallback("onNoticeAuth", test);
210
+        parser.getCallbackManager().addCallback(AuthNoticeListener.class, test);
203
         parser.sendConnectionStrings();
211
         parser.sendConnectionStrings();
204
         parser.injectLine(":chris!@ NICK :user2");
212
         parser.injectLine(":chris!@ NICK :user2");
205
 
213
 
210
     public void testNumeric() throws CallbackNotFoundException {
218
     public void testNumeric() throws CallbackNotFoundException {
211
         final TestINumeric test = new TestINumeric();
219
         final TestINumeric test = new TestINumeric();
212
         final TestParser parser = new TestParser();
220
         final TestParser parser = new TestParser();
213
-        parser.getCallbackManager().addCallback("onNumeric", test);
221
+        parser.getCallbackManager().addCallback(NumericListener.class, test);
214
 
222
 
215
         parser.injectLine(":server 001 nick :Hi there, nick");
223
         parser.injectLine(":server 001 nick :Hi there, nick");
216
 
224
 
223
     public void testPost005() throws CallbackNotFoundException {
231
     public void testPost005() throws CallbackNotFoundException {
224
         final TestIPost005 test = new TestIPost005();
232
         final TestIPost005 test = new TestIPost005();
225
         final TestParser parser = new TestParser();
233
         final TestParser parser = new TestParser();
226
-        parser.getCallbackManager().addCallback("onPost005", test);
234
+        parser.getCallbackManager().addCallback(Post005Listener.class, test);
227
 
235
 
228
         final String[] strings = {
236
         final String[] strings = {
229
             "NOTICE AUTH :Blah, blah",
237
             "NOTICE AUTH :Blah, blah",
354
 
362
 
355
         parser.injectConnectionStrings();
363
         parser.injectConnectionStrings();
356
 
364
 
357
-        parser.getCallbackManager().addCallback("onPrivateMessage", ipmtest);
358
-        parser.getCallbackManager().addCallback("onPrivateAction", ipatest);
359
-        parser.getCallbackManager().addCallback("onPrivateCTCP", ipctest);
365
+        parser.getCallbackManager().addCallback(PrivateMessageListener.class, ipmtest);
366
+        parser.getCallbackManager().addCallback(PrivateActionListener.class, ipatest);
367
+        parser.getCallbackManager().addCallback(PrivateCtcpListener.class, ipctest);
360
 
368
 
361
         parser.injectLine(":a!b@c PRIVMSG nick :Hello!");
369
         parser.injectLine(":a!b@c PRIVMSG nick :Hello!");
362
         assertNotNull(ipmtest.host);
370
         assertNotNull(ipmtest.host);
459
         parser.injectConnectionStrings();
467
         parser.injectConnectionStrings();
460
 
468
 
461
         parser.injectLine(":nick JOIN #D");
469
         parser.injectLine(":nick JOIN #D");
462
-        parser.getCallbackManager().addCallback("onChannelKick", ick, "#D");
470
+        parser.getCallbackManager().addCallback(ChannelKickListener.class, ick, "#D");
463
         parser.injectLine(":bar!me@moo KICK #D nick :Bye!");
471
         parser.injectLine(":bar!me@moo KICK #D nick :Bye!");
464
 
472
 
465
         verify(ick).onChannelKick(same(parser), (ChannelInfo) anyObject(),
473
         verify(ick).onChannelKick(same(parser), (ChannelInfo) anyObject(),
481
     public void testIllegalPort1() {
489
     public void testIllegalPort1() {
482
         final TestParser tp = new TestParser(new MyInfo(), new ServerInfo("127.0.0.1", 0, ""));
490
         final TestParser tp = new TestParser(new MyInfo(), new ServerInfo("127.0.0.1", 0, ""));
483
         final TestIConnectError tiei = new TestIConnectError();
491
         final TestIConnectError tiei = new TestIConnectError();
484
-        tp.getCallbackManager().addCallback("OnConnectError", tiei);
492
+        tp.getCallbackManager().addCallback(ConnectErrorListener.class, tiei);
485
         tp.runSuper();
493
         tp.runSuper();
486
         assertTrue(tiei.error);
494
         assertTrue(tiei.error);
487
     }
495
     }
490
     public void testIllegalPort2() {
498
     public void testIllegalPort2() {
491
         final TestParser tp = new TestParser(new MyInfo(), new ServerInfo("127.0.0.1", 1, ""));
499
         final TestParser tp = new TestParser(new MyInfo(), new ServerInfo("127.0.0.1", 1, ""));
492
         final TestIConnectError tiei = new TestIConnectError();
500
         final TestIConnectError tiei = new TestIConnectError();
493
-        tp.getCallbackManager().addCallback("OnConnectError", tiei);
501
+        tp.getCallbackManager().addCallback(ConnectErrorListener.class, tiei);
494
         tp.runSuper();
502
         tp.runSuper();
495
         assertTrue(tiei.error);
503
         assertTrue(tiei.error);
496
     }    
504
     }    
499
     public void testIllegalPort3() {
507
     public void testIllegalPort3() {
500
         final TestParser tp = new TestParser(new MyInfo(), new ServerInfo("127.0.0.1", 65570, ""));
508
         final TestParser tp = new TestParser(new MyInfo(), new ServerInfo("127.0.0.1", 65570, ""));
501
         final TestIConnectError tiei = new TestIConnectError();
509
         final TestIConnectError tiei = new TestIConnectError();
502
-        tp.getCallbackManager().addCallback("OnConnectError", tiei);
510
+        tp.getCallbackManager().addCallback(ConnectErrorListener.class, tiei);
503
         tp.runSuper();
511
         tp.runSuper();
504
         assertTrue(tiei.error);
512
         assertTrue(tiei.error);
505
     }
513
     }

+ 2
- 1
test/com/dmdirc/parser/irc/Process004005Test.java View File

24
 
24
 
25
 import com.dmdirc.harness.parser.TestIErrorInfo;
25
 import com.dmdirc.harness.parser.TestIErrorInfo;
26
 import com.dmdirc.harness.parser.TestParser;
26
 import com.dmdirc.harness.parser.TestParser;
27
+import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
27
 import org.junit.Test;
28
 import org.junit.Test;
28
 import static org.junit.Assert.*;
29
 import static org.junit.Assert.*;
29
 
30
 
63
         final TestParser tp = doCaseMappingTest("rfc1459", 4);
64
         final TestParser tp = doCaseMappingTest("rfc1459", 4);
64
         final TestIErrorInfo tiei = new TestIErrorInfo();
65
         final TestIErrorInfo tiei = new TestIErrorInfo();
65
         
66
         
66
-        tp.getCallbackManager().addCallback("OnErrorInfo", tiei);
67
+        tp.getCallbackManager().addCallback(ErrorInfoListener.class, tiei);
67
         
68
         
68
         tp.injectLine(":server 005 nick CASEMAPPING=unknown :are supported by this server");
69
         tp.injectLine(":server 005 nick CASEMAPPING=unknown :are supported by this server");
69
         
70
         

+ 3
- 2
test/com/dmdirc/parser/irc/ProcessJoinTest.java View File

27
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
27
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
28
 import com.dmdirc.parser.interfaces.callbacks.ChannelJoinListener;
28
 import com.dmdirc.parser.interfaces.callbacks.ChannelJoinListener;
29
 
29
 
30
+import com.dmdirc.parser.interfaces.callbacks.ChannelSelfJoinListener;
30
 import org.junit.Test;
31
 import org.junit.Test;
31
 import static org.junit.Assert.*;
32
 import static org.junit.Assert.*;
32
 import static org.mockito.Mockito.*;
33
 import static org.mockito.Mockito.*;
39
         final TestIChannelSelfJoin test = new TestIChannelSelfJoin();
40
         final TestIChannelSelfJoin test = new TestIChannelSelfJoin();
40
 
41
 
41
         parser.injectConnectionStrings();
42
         parser.injectConnectionStrings();
42
-        parser.getCallbackManager().addCallback("onChannelSelfJoin", test);
43
+        parser.getCallbackManager().addCallback(ChannelSelfJoinListener.class, test);
43
         parser.injectLine(":nick JOIN #DMDirc_testing");
44
         parser.injectLine(":nick JOIN #DMDirc_testing");
44
 
45
 
45
         assertNotNull(test.channel);
46
         assertNotNull(test.channel);
57
         final ChannelJoinListener test = mock(ChannelJoinListener.class);
58
         final ChannelJoinListener test = mock(ChannelJoinListener.class);
58
 
59
 
59
         parser.injectConnectionStrings();
60
         parser.injectConnectionStrings();
60
-        parser.getCallbackManager().addCallback("onChannelJoin", test);
61
+        parser.getCallbackManager().addCallback(ChannelJoinListener.class, test);
61
         
62
         
62
         parser.injectLine(":nick JOIN #DMDirc_testing");
63
         parser.injectLine(":nick JOIN #DMDirc_testing");
63
         parser.injectLine(":foo!bar@baz JOIN #DMDirc_testing");
64
         parser.injectLine(":foo!bar@baz JOIN #DMDirc_testing");

+ 1
- 1
test/com/dmdirc/parser/irc/ProcessNamesTest.java View File

36
         final TestParser parser = new TestParser();
36
         final TestParser parser = new TestParser();
37
         final TestIErrorInfo test = new TestIErrorInfo();
37
         final TestIErrorInfo test = new TestIErrorInfo();
38
         parser.injectConnectionStrings();
38
         parser.injectConnectionStrings();
39
-        parser.getCallbackManager().addCallback("OnErrorInfo", test);
39
+        parser.getCallbackManager().addCallback(ErrorInfoListener.class, test);
40
         
40
         
41
         parser.injectLine(":server 366 nick #nonexistant :End of /NAMES list.");
41
         parser.injectLine(":server 366 nick #nonexistant :End of /NAMES list.");
42
         
42
         

+ 5
- 3
test/com/dmdirc/parser/irc/ProcessNickTest.java View File

25
 import com.dmdirc.harness.parser.TestParser;
25
 import com.dmdirc.harness.parser.TestParser;
26
 import com.dmdirc.harness.parser.TestIErrorInfo;
26
 import com.dmdirc.harness.parser.TestIErrorInfo;
27
 import com.dmdirc.harness.parser.TestINickChanged;
27
 import com.dmdirc.harness.parser.TestINickChanged;
28
+import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
29
+import com.dmdirc.parser.interfaces.callbacks.NickChangeListener;
28
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
30
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
29
 import org.junit.Test;
31
 import org.junit.Test;
30
 import static org.junit.Assert.*;
32
 import static org.junit.Assert.*;
36
         final TestParser parser = new TestParser();
38
         final TestParser parser = new TestParser();
37
         final TestINickChanged tinc = new TestINickChanged();
39
         final TestINickChanged tinc = new TestINickChanged();
38
 
40
 
39
-        parser.getCallbackManager().addCallback("OnNickChanged", tinc);
41
+        parser.getCallbackManager().addCallback(NickChangeListener.class, tinc);
40
         
42
         
41
         parser.injectConnectionStrings();
43
         parser.injectConnectionStrings();
42
         parser.injectLine(":nick JOIN #DMDirc_testing");
44
         parser.injectLine(":nick JOIN #DMDirc_testing");
80
         final TestParser parser = new TestParser();
82
         final TestParser parser = new TestParser();
81
         final TestIErrorInfo info = new TestIErrorInfo();
83
         final TestIErrorInfo info = new TestIErrorInfo();
82
         
84
         
83
-        parser.getCallbackManager().addCallback("OnErrorInfo", info);
85
+        parser.getCallbackManager().addCallback(ErrorInfoListener.class, info);
84
         parser.injectConnectionStrings();
86
         parser.injectConnectionStrings();
85
         parser.injectLine(":nick JOIN #DMDirc_testing");
87
         parser.injectLine(":nick JOIN #DMDirc_testing");
86
         parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser @+nick2 nick3");
88
         parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser @+nick2 nick3");
96
         final TestParser parser = new TestParser();
98
         final TestParser parser = new TestParser();
97
         final TestINickChanged tinc = new TestINickChanged();
99
         final TestINickChanged tinc = new TestINickChanged();
98
         
100
         
99
-        parser.getCallbackManager().addCallback("OnNickChanged", tinc);
101
+        parser.getCallbackManager().addCallback(NickChangeListener.class, tinc);
100
         
102
         
101
         parser.injectConnectionStrings();
103
         parser.injectConnectionStrings();
102
         parser.injectLine(":random!lu@ser NICK rand");
104
         parser.injectLine(":random!lu@ser NICK rand");

+ 2
- 4
test/com/dmdirc/parser/irc/ProcessPartTest.java View File

27
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
27
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
28
 
28
 
29
 import com.dmdirc.parser.interfaces.callbacks.ChannelPartListener;
29
 import com.dmdirc.parser.interfaces.callbacks.ChannelPartListener;
30
-import com.dmdirc.parser.interfaces.callbacks.ChannelQuitListener;
31
-import com.dmdirc.parser.interfaces.callbacks.QuitListener;
32
 import org.junit.Test;
30
 import org.junit.Test;
33
 import static org.junit.Assert.*;
31
 import static org.junit.Assert.*;
34
 
32
 
45
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
43
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
46
         
44
         
47
         final TestIChannelPart test = new TestIChannelPart();
45
         final TestIChannelPart test = new TestIChannelPart();
48
-        parser.getCallbackManager().addCallback("OnChannelPart", test);
46
+        parser.getCallbackManager().addCallback(ChannelPartListener.class, test);
49
         
47
         
50
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
48
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
51
         
49
         
73
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
71
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
74
         
72
         
75
         final TestIChannelPart test = new TestIChannelPart();
73
         final TestIChannelPart test = new TestIChannelPart();
76
-        parser.getCallbackManager().addCallback("OnChannelPart", test);
74
+        parser.getCallbackManager().addCallback(ChannelPartListener.class, test);
77
         
75
         
78
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
76
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
79
         
77
         

+ 5
- 5
test/com/dmdirc/parser/irc/ProcessQuitTest.java View File

24
 
24
 
25
 import com.dmdirc.harness.parser.TestParser;
25
 import com.dmdirc.harness.parser.TestParser;
26
 import com.dmdirc.harness.parser.TestIQuit;
26
 import com.dmdirc.harness.parser.TestIQuit;
27
-import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
28
-
29
 import com.dmdirc.parser.interfaces.callbacks.ChannelQuitListener;
27
 import com.dmdirc.parser.interfaces.callbacks.ChannelQuitListener;
30
 import com.dmdirc.parser.interfaces.callbacks.QuitListener;
28
 import com.dmdirc.parser.interfaces.callbacks.QuitListener;
29
+import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
30
+
31
 import org.junit.Test;
31
 import org.junit.Test;
32
 import static org.junit.Assert.*;
32
 import static org.junit.Assert.*;
33
 
33
 
47
         parser.injectLine(":server 366 nick #DMDirc_testing2 :End of /NAMES list.");        
47
         parser.injectLine(":server 366 nick #DMDirc_testing2 :End of /NAMES list.");        
48
         
48
         
49
         final TestIQuit test = new TestIQuit();
49
         final TestIQuit test = new TestIQuit();
50
-        parser.getCallbackManager().addCallback("OnChannelQuit", test);
50
+        parser.getCallbackManager().addCallback(ChannelQuitListener.class, test);
51
         
51
         
52
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
52
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
53
         
53
         
80
         parser.injectLine(":server 366 nick #DMDirc_testing2 :End of /NAMES list.");
80
         parser.injectLine(":server 366 nick #DMDirc_testing2 :End of /NAMES list.");
81
         
81
         
82
         final TestIQuit test = new TestIQuit();
82
         final TestIQuit test = new TestIQuit();
83
-        parser.getCallbackManager().addCallback("OnQuit", test);
83
+        parser.getCallbackManager().addCallback(QuitListener.class, test);
84
         
84
         
85
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
85
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
86
         
86
         
108
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
108
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
109
         
109
         
110
         final TestIQuit test = new TestIQuit();
110
         final TestIQuit test = new TestIQuit();
111
-        parser.getCallbackManager().addCallback("OnQuit", test);
111
+        parser.getCallbackManager().addCallback(QuitListener.class, test);
112
         
112
         
113
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
113
         assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
114
         
114
         

+ 2
- 2
test/com/dmdirc/parser/irc/ProcessTopicTest.java View File

36
         final TestParser parser = new TestParser();
36
         final TestParser parser = new TestParser();
37
         final TestIChannelTopic test = new TestIChannelTopic();
37
         final TestIChannelTopic test = new TestIChannelTopic();
38
         parser.injectConnectionStrings();
38
         parser.injectConnectionStrings();
39
-        parser.getCallbackManager().addCallback("OnChannelTopic", test);
39
+        parser.getCallbackManager().addCallback(ChannelTopicListener.class, test);
40
         
40
         
41
         parser.injectLine(":nick JOIN #DMDirc_testing");
41
         parser.injectLine(":nick JOIN #DMDirc_testing");
42
         parser.injectLine(":server 332 nick #DMDirc_testing :This be a topic");
42
         parser.injectLine(":server 332 nick #DMDirc_testing :This be a topic");
60
         parser.injectLine(":server 332 nick #DMDirc_testing :This be a topic");
60
         parser.injectLine(":server 332 nick #DMDirc_testing :This be a topic");
61
         parser.injectLine(":server 333 nick #DMDirc_testing Q 1207350306");
61
         parser.injectLine(":server 333 nick #DMDirc_testing Q 1207350306");
62
         
62
         
63
-        parser.getCallbackManager().addCallback("OnChannelTopic", test);
63
+        parser.getCallbackManager().addCallback(ChannelTopicListener.class, test);
64
         
64
         
65
         parser.injectLine(":foobar TOPIC #DMDirc_testing :New topic here");
65
         parser.injectLine(":foobar TOPIC #DMDirc_testing :New topic here");
66
         
66
         

+ 1
- 1
test/com/dmdirc/parser/irc/ProcessWhoTest.java View File

35
         final TestParser parser = new TestParser();
35
         final TestParser parser = new TestParser();
36
         final AwayStateListener test = mock(AwayStateListener.class);
36
         final AwayStateListener test = mock(AwayStateListener.class);
37
         parser.injectConnectionStrings();
37
         parser.injectConnectionStrings();
38
-        parser.getCallbackManager().addCallback("OnAwayState", test);
38
+        parser.getCallbackManager().addCallback(AwayStateListener.class, test);
39
 
39
 
40
         parser.injectLine(":nick JOIN #DMDirc_testing");
40
         parser.injectLine(":nick JOIN #DMDirc_testing");
41
 
41
 

Loading…
Cancel
Save