Bladeren bron

Parser base abstraction/tidying

Depends-On: I3bfbb811a5b5055d8dbe511a0390c3413d133292
Depends-On: I4ff484e8a2597017283eea557170c4aeb2029faa
Change-Id: I694d18a653ca8c3e3cad9d0e766e2fd207e615e9
Reviewed-on: http://gerrit.dmdirc.com/1854
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.7rc1
Chris Smith 13 jaren geleden
bovenliggende
commit
8bed9eb8fa

src/com/dmdirc/parser/irc/IRCCallbackObjectSpecific.java → src/com/dmdirc/parser/common/BaseChannelClientInfo.java Bestand weergeven

@@ -20,52 +20,63 @@
20 20
  * SOFTWARE.
21 21
  */
22 22
 
23
-package com.dmdirc.parser.irc;
23
+package com.dmdirc.parser.common;
24 24
 
25
-import com.dmdirc.parser.common.CallbackManager;
26
-import com.dmdirc.parser.common.CallbackObjectSpecific;
27 25
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
28 26
 import com.dmdirc.parser.interfaces.ChannelInfo;
29 27
 import com.dmdirc.parser.interfaces.ClientInfo;
30
-import com.dmdirc.parser.interfaces.LocalClientInfo;
31
-import com.dmdirc.parser.interfaces.Parser;
32
-import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
28
+
33 29
 import java.util.HashMap;
34 30
 import java.util.Map;
35 31
 
36 32
 /**
37
- * A specific callback object for use with the IRC Parser.
38
- *
39
- * @since 0.6.3m2
40
- * @author chris
33
+ * Provides a basic implementation of the {@link ChannelClientInfo} interface.
41 34
  */
42
-public class IRCCallbackObjectSpecific extends CallbackObjectSpecific {
35
+public abstract class BaseChannelClientInfo implements ChannelClientInfo {
36
+    
37
+    /** A map for random data associated with the client to be stored in. */
38
+    private final Map<Object, Object> map = new HashMap<Object, Object>();
39
+    
40
+    /** The channel that the client is associated with. */
41
+    private final ChannelInfo channel;
42
+    
43
+    /** The client that is associated with the channel. */
44
+    private final ClientInfo client;
43 45
 
44
-    /** A map of interfaces to the classes which should be instansiated for them. */
45
-    protected static final Map<Class<?>, Class<?>> IMPL_MAP = new HashMap<Class<?>, Class<?>>();
46
+    /**
47
+     * Creates a new BaseChannelClientInfo object for the specified client's
48
+     * association with the specified channel.
49
+     *
50
+     * @param channel The channel the association is with
51
+     * @param client The user that holds the association
52
+     */
53
+    public BaseChannelClientInfo(final ChannelInfo channel, final ClientInfo client) {
54
+        this.channel = channel;
55
+        this.client = client;
56
+    }
46 57
 
47
-    static {
48
-        IMPL_MAP.put(ChannelClientInfo.class, IRCChannelClientInfo.class);
49
-        IMPL_MAP.put(ChannelInfo.class, IRCChannelInfo.class);
50
-        IMPL_MAP.put(ClientInfo.class, IRCClientInfo.class);
51
-        IMPL_MAP.put(LocalClientInfo.class, IRCClientInfo.class);
58
+    /** {@inheritDoc} */
59
+    @Override
60
+    public ChannelInfo getChannel() {
61
+        return channel;
52 62
     }
53 63
 
54
-    public IRCCallbackObjectSpecific(final Parser parser,
55
-            final CallbackManager<?> manager, final Class<? extends CallbackInterface> type) {
56
-        super(parser, manager, type);
64
+    /** {@inheritDoc} */
65
+    @Override
66
+    public ClientInfo getClient() {
67
+        return client;
57 68
     }
58 69
 
59 70
     /** {@inheritDoc} */
60 71
     @Override
61
-    protected String translateHostname(final String hostname) {
62
-        return IRCClientInfo.parseHost(hostname);
72
+    public Map<Object, Object> getMap() {
73
+        return map;
63 74
     }
64 75
 
65 76
     /** {@inheritDoc} */
66 77
     @Override
67
-    protected Class<?> getImplementation(final Class<?> type) {
68
-        return IMPL_MAP.containsKey(type) ? IMPL_MAP.get(type) : type;
78
+    public String toString() {
79
+        return getImportantMode() + client.toString();
69 80
     }
70 81
 
71 82
 }

+ 132
- 0
src/com/dmdirc/parser/common/BaseChannelInfo.java Bestand weergeven

@@ -0,0 +1,132 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+
29
+import java.util.Collection;
30
+import java.util.HashMap;
31
+import java.util.Map;
32
+
33
+/**
34
+ * Provides a basic implementation of the {@link ChannelInfo} interface.
35
+ */
36
+public abstract class BaseChannelInfo implements ChannelInfo {
37
+    
38
+    /** The parser that owns this client. */
39
+    private final Parser parser;
40
+    
41
+    /** A map for random data associated with the client to be stored in. */
42
+    private final Map<Object, Object> map = new HashMap<Object, Object>();
43
+    
44
+    /** The clients in this channel. */
45
+    private final Map<String, ChannelClientInfo> clients = new HashMap<String, ChannelClientInfo>();
46
+    
47
+    /** The name of this channel. */
48
+    private final String name;
49
+
50
+    public BaseChannelInfo(final Parser parser, final String name) {
51
+        this.parser = parser;
52
+        this.name = name;
53
+    }
54
+
55
+    /** {@inheritDoc} */
56
+    @Override
57
+    public Map<Object, Object> getMap() {
58
+        return map;
59
+    }
60
+
61
+    /** {@inheritDoc} */
62
+    @Override
63
+    public String getName() {
64
+        return name;
65
+    }
66
+
67
+    /** {@inheritDoc} */
68
+    @Override
69
+    public Parser getParser() {
70
+        return parser;
71
+    }
72
+    
73
+    /** {@inheritDoc} */
74
+    @Override
75
+    public void sendMessage(final String message) {
76
+        parser.sendMessage(name, message);
77
+    }
78
+
79
+    /** {@inheritDoc} */
80
+    @Override
81
+    public void sendAction(final String action) {
82
+        parser.sendAction(name, action);
83
+    }
84
+    
85
+    /** {@inheritDoc} */
86
+    @Override
87
+    public Collection<ChannelClientInfo> getChannelClients() {
88
+        return clients.values();
89
+    }
90
+
91
+    /** {@inheritDoc} */
92
+    @Override
93
+    public int getChannelClientCount() {
94
+        return clients.size();
95
+    }
96
+    
97
+    /** {@inheritDoc} */
98
+    @Override
99
+    public ChannelClientInfo getChannelClient(final String client) {
100
+        return getChannelClient(client, false);
101
+    }
102
+    
103
+    /**
104
+     * Adds a new client to this channel's user list.
105
+     *
106
+     * @param key The key to identify the client by
107
+     * @param client The client to be added
108
+     */
109
+    protected void addClient(final String key, final ChannelClientInfo client) {
110
+        clients.put(key, client);
111
+    }
112
+    
113
+    /**
114
+     * Removes an existing client from this channel's user list.
115
+     *
116
+     * @param key The key that the client is identified by
117
+     */
118
+    protected void removeClient(final String key) {
119
+        clients.remove(key);
120
+    }
121
+    
122
+    /**
123
+     * Retrieves the client identified by the specified key.
124
+     *
125
+     * @param key The key identifying the client to be retrieved
126
+     * @return The client corresponding to the give key
127
+     */
128
+    protected ChannelClientInfo getClient(final String key) {
129
+        return clients.get(key);
130
+    }
131
+
132
+}

+ 140
- 0
src/com/dmdirc/parser/common/BaseClientInfo.java Bestand weergeven

@@ -0,0 +1,140 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+import com.dmdirc.parser.interfaces.ClientInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+
28
+import java.util.HashMap;
29
+import java.util.Map;
30
+
31
+/**
32
+ * Provides a basic implementation of the {@link ClientInfo} interface.
33
+ */
34
+public abstract class BaseClientInfo implements ClientInfo {
35
+
36
+    /** The parser that owns this client. */
37
+    private final Parser parser;
38
+
39
+    /** A map for random data associated with the client to be stored in. */
40
+    private final Map<Object, Object> map = new HashMap<Object, Object>();
41
+
42
+    /** The user's details. */
43
+    private String nick, user, host, realname = null;
44
+
45
+    /**
46
+     * Creates a new base client info for the specified parser with the
47
+     * specified details.
48
+     *
49
+     * @param parser The parser that owns this client info object
50
+     * @param nick The nickname of the user this object represents
51
+     * @param user The username of the user this object represents
52
+     * @param host The hostname of the user this object represents
53
+     */
54
+    public BaseClientInfo(final Parser parser, final String nick,
55
+            final String user, final String host) {
56
+        this.parser = parser;
57
+        this.nick = nick;
58
+        this.user = user;
59
+        this.host = host;
60
+    }
61
+
62
+    /** {@inheritDoc} */
63
+    @Override
64
+    public String getNickname() {
65
+        return nick;
66
+    }
67
+
68
+    /** {@inheritDoc} */
69
+    @Override
70
+    public String getUsername() {
71
+        return user;
72
+    }
73
+
74
+    /** {@inheritDoc} */
75
+    @Override
76
+    public String getHostname() {
77
+        return host;
78
+    }
79
+
80
+    /** {@inheritDoc} */
81
+    @Override
82
+    public String getRealname() {
83
+        return realname;
84
+    }
85
+
86
+    /**
87
+     * Sets the hostname of this user.
88
+     *
89
+     * @param host The new hostname
90
+     */
91
+    protected void setHostname(final String host) {
92
+        this.host = host;
93
+    }
94
+
95
+    /**
96
+     * Sets the nickname of this user.
97
+     *
98
+     * @param nick The new nickname
99
+     */
100
+    protected void setLocalNickname(final String nick) {
101
+        this.nick = nick;
102
+    }
103
+
104
+    /**
105
+     * Sets the realname of this user.
106
+     *
107
+     * @param realname The new realname
108
+     */
109
+    protected void setRealname(final String realname) {
110
+        this.realname = realname;
111
+    }
112
+
113
+    /**
114
+     * Sets the username of this user.
115
+     *
116
+     * @param user The new username
117
+     */
118
+    protected void setUsername(final String user) {
119
+        this.user = user;
120
+    }
121
+
122
+    /** {@inheritDoc} */
123
+    @Override
124
+    public Map<Object, Object> getMap() {
125
+        return map;
126
+    }
127
+
128
+    /** {@inheritDoc} */
129
+    @Override
130
+    public Parser getParser() {
131
+        return parser;
132
+    }
133
+
134
+    /** {@inheritDoc} */
135
+    @Override
136
+    public String toString() {
137
+        return getNickname();
138
+    }
139
+
140
+}

+ 131
- 0
src/com/dmdirc/parser/common/BaseParser.java Bestand weergeven

@@ -0,0 +1,131 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+import java.net.URI;
28
+import java.util.HashMap;
29
+import java.util.Map;
30
+
31
+/**
32
+ * Implements common base functionality for parsers.
33
+ */
34
+public abstract class BaseParser implements Parser {
35
+
36
+    /** The URI that this parser was constructed for. */
37
+    private final URI uri;
38
+
39
+    /** The ignore list for this parser. */
40
+    private IgnoreList ignoreList;
41
+
42
+    /** The ping timer interval for this parser. */
43
+    private long pingTimerInterval;
44
+
45
+    /** The ping timer fraction for this parser. */
46
+    private int pingTimerFraction;
47
+
48
+    /** The callback manager to use for this parser. */
49
+    private final CallbackManager callbackManager;
50
+
51
+    /** A map for callers to use to store things for no sane reason. */
52
+    private final Map<Object, Object> map = new HashMap<Object, Object>();
53
+
54
+    /**
55
+     * Creates a new base parser for the specified URI.
56
+     *
57
+     * @param uri The URI this parser will connect to.
58
+     * @param implementations A map of interface implementations for this parser
59
+     */
60
+    public BaseParser(final URI uri, final Map<Class<?>, Class<?>> implementations) {
61
+        this.uri = uri;
62
+        this.callbackManager = new CallbackManager(this, implementations);
63
+    }
64
+
65
+    /** {@inheritDoc} */
66
+    @Override
67
+    public URI getURI() {
68
+        return uri;
69
+    }
70
+
71
+    /** {@inheritDoc} */
72
+    @Override
73
+    public IgnoreList getIgnoreList() {
74
+        return ignoreList;
75
+    }
76
+
77
+    /** {@inheritDoc} */
78
+    @Override
79
+    public void setIgnoreList(final IgnoreList ignoreList) {
80
+        this.ignoreList = ignoreList;
81
+    }
82
+
83
+    /** {@inheritDoc} */
84
+    @Override
85
+    public long getPingTimerInterval() {
86
+        return pingTimerInterval;
87
+    }
88
+
89
+    /** {@inheritDoc} */
90
+    @Override
91
+    public void setPingTimerInterval(final long newValue) {
92
+        pingTimerInterval = newValue;
93
+    }
94
+
95
+    /** {@inheritDoc} */
96
+    @Override
97
+    public int getPingTimerFraction() {
98
+        return pingTimerFraction;
99
+    }
100
+
101
+    /** {@inheritDoc} */
102
+    @Override
103
+    public void setPingTimerFraction(final int newValue) {
104
+        pingTimerFraction = newValue;
105
+    }
106
+
107
+    /** {@inheritDoc} */
108
+    @Override
109
+    public CallbackManager getCallbackManager() {
110
+        return callbackManager;
111
+    }
112
+
113
+    /** {@inheritDoc} */
114
+    @Override
115
+    public Map<Object, Object> getMap() {
116
+        return map;
117
+    }
118
+
119
+    /** {@inheritDoc} */
120
+    @Override
121
+    public void joinChannel(final String channel) {
122
+        joinChannels(new ChannelJoinRequest(channel));
123
+    }
124
+
125
+    /** {@inheritDoc} */
126
+    @Override
127
+    public void joinChannel(final String channel, final String key) {
128
+        joinChannels(new ChannelJoinRequest(channel, key));
129
+    }
130
+
131
+}

+ 143
- 0
src/com/dmdirc/parser/common/BaseSocketAwareParser.java Bestand weergeven

@@ -0,0 +1,143 @@
1
+/*
2
+ * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+import java.io.IOException;
26
+import java.net.InetAddress;
27
+import java.net.Socket;
28
+import java.net.URI;
29
+import java.util.Map;
30
+
31
+import javax.net.SocketFactory;
32
+
33
+/**
34
+ * A base parser which can construct a SocketFactory given socket-related
35
+ * options.
36
+ */
37
+public abstract class BaseSocketAwareParser extends BaseParser {
38
+    
39
+    /** The IP address or hostname that this parser's sockets should bind to. */
40
+    private String bindIp = null;
41
+    
42
+    /** The socket that was most recently created by this parser. */
43
+    private Socket socket;
44
+    
45
+    /** The local port that this parser's *most recently created* socket bound to. */
46
+    private int localPort = -1;
47
+
48
+    /**
49
+     * Creates a new base parser for the specified URI.
50
+     *
51
+     * @param uri The URI this parser will connect to.
52
+     * @param implementations A map of interface implementations for this parser
53
+     */
54
+    public BaseSocketAwareParser(final URI uri, final Map<Class<?>, Class<?>> implementations) {
55
+        super(uri, implementations);
56
+    }
57
+
58
+    /** {@inheritDoc} */
59
+    @Override
60
+    public String getBindIP() {
61
+        return bindIp;
62
+    }
63
+    
64
+    /** {@inheritDoc} */
65
+    @Override
66
+    public void setBindIP(final String ip) {
67
+        bindIp = ip;
68
+    }
69
+    
70
+    /** {@inheritDoc} */
71
+    @Override
72
+    public int getLocalPort() {
73
+        if (localPort == -1 && socket != null) {
74
+            // Try to update the local port from the socket, as it may have
75
+            // bound since the last time we tried
76
+            localPort = socket.getLocalPort();
77
+        }
78
+
79
+        return localPort;
80
+    }
81
+    
82
+    /**
83
+     * Convenience method to record the local port of the specified socket.
84
+     *
85
+     * @param socket The socket whose port is being recorded
86
+     * @return The socket reference passed in, for convenience
87
+     */
88
+    private Socket handleSocket(final Socket socket) {
89
+        // Store the socket as it might not have been bound yet
90
+        this.socket = socket;
91
+        this.localPort = socket.getLocalPort();
92
+
93
+        return socket;
94
+    }
95
+
96
+    /**
97
+     * Creates a socket factory that can be used by this parser.
98
+     *
99
+     * @return An appropriately configured socket factory
100
+     */
101
+    protected SocketFactory getSocketFactory() {
102
+        return new SocketFactory() {
103
+
104
+            /** {@inheritDoc} */
105
+            @Override
106
+            public Socket createSocket(final String host, final int port) throws IOException {
107
+                if (bindIp == null) {
108
+                    return handleSocket(new Socket(host, port));
109
+                } else {
110
+                    return handleSocket(new Socket(host, port, InetAddress.getByName(bindIp), 0));
111
+                }
112
+            }
113
+            
114
+            /** {@inheritDoc} */
115
+            @Override
116
+            public Socket createSocket(final InetAddress host, final int port) throws IOException {
117
+                if (bindIp == null) {
118
+                    return handleSocket(new Socket(host, port));
119
+                } else {
120
+                    return handleSocket(new Socket(host, port, InetAddress.getByName(bindIp), 0));
121
+                }
122
+            }
123
+
124
+            /** {@inheritDoc} */
125
+            @Override
126
+            public Socket createSocket(final String host, final int port,
127
+                    final InetAddress localHost, final int localPort) throws IOException {
128
+                return handleSocket(new Socket(host, port,
129
+                        bindIp == null ? localHost : InetAddress.getByName(bindIp), localPort));
130
+            }
131
+
132
+            /** {@inheritDoc} */
133
+            @Override
134
+            public Socket createSocket(final InetAddress address,
135
+                    final int port, final InetAddress localAddress,
136
+                    final int localPort) throws IOException {
137
+                return handleSocket(new Socket(address, port,
138
+                        bindIp == null ? localAddress : InetAddress.getByName(bindIp), localPort));
139
+            }
140
+            
141
+        };
142
+    }
143
+}

+ 17
- 11
src/com/dmdirc/parser/common/CallbackManager.java Bestand weergeven

@@ -30,15 +30,12 @@ import java.util.HashMap;
30 30
 import java.util.Map;
31 31
 
32 32
 /**
33
- * IRC Parser Callback Manager.
33
+ * Parser Callback Manager.
34 34
  * Manages adding/removing/calling callbacks.
35
- *
36
- * @param <T> The type of parser which this manager managers callbacks for
37
- * @author            Shane Mc Cormack
38 35
  */
39
-public abstract class CallbackManager<T extends Parser> {
36
+public class CallbackManager {
40 37
 
41
-    static final Class[] CLASSES = {
38
+    private static final Class[] CLASSES = {
42 39
         AwayStateListener.class, OtherAwayStateListener.class,
43 40
         ChannelOtherAwayStateListener.class, ChannelActionListener.class,
44 41
         ChannelCtcpListener.class, ChannelCtcpReplyListener.class,
@@ -60,7 +57,7 @@ public abstract class CallbackManager<T extends Parser> {
60 57
         PingSuccessListener.class, PingSentListener.class,
61 58
         PrivateActionListener.class, PrivateCtcpListener.class,
62 59
         PrivateCtcpReplyListener.class, PrivateMessageListener.class,
63
-        PrivateNoticeListener.class, Post005Listener.class, QuitListener.class,
60
+        PrivateNoticeListener.class, QuitListener.class,
64 61
         ServerErrorListener.class, ServerReadyListener.class,
65 62
         SocketCloseListener.class, UnknownActionListener.class,
66 63
         UnknownCtcpListener.class, UnknownCtcpReplyListener.class,
@@ -74,12 +71,17 @@ public abstract class CallbackManager<T extends Parser> {
74 71
     private final Map<Class<? extends CallbackInterface>, CallbackObject> callbackHash
75 72
             = new HashMap<Class<? extends CallbackInterface>, CallbackObject>();
76 73
 
74
+    private final Map<Class<?>, Class<?>> implementationMap;
75
+
77 76
     /**
78 77
      * Constructor to create a CallbackManager.
79 78
      *
80 79
      * @param parser Parser that owns this callback manager.
80
+     * @param implementationMap A map of implementations to use
81 81
      */
82
-    protected CallbackManager(final T parser) {
82
+    public CallbackManager(final Parser parser, final Map<Class<?>, Class<?>> implementationMap) {
83
+        this.implementationMap = implementationMap;
84
+
83 85
         initialise(parser);
84 86
     }
85 87
 
@@ -88,7 +90,7 @@ public abstract class CallbackManager<T extends Parser> {
88 90
      *
89 91
      * @param parser The parser associated with this CallbackManager
90 92
      */
91
-    protected void initialise(final T parser) {
93
+    protected void initialise(final Parser parser) {
92 94
         for (Class<?> type : CLASSES) {
93 95
             if (type.isAnnotationPresent(SpecificCallback.class)) {
94 96
                 addCallbackType(getSpecificCallbackObject(parser, type));
@@ -105,7 +107,9 @@ public abstract class CallbackManager<T extends Parser> {
105 107
      * @param type The type of callback to create an object for
106 108
      * @return The relevant CallbackObject
107 109
      */
108
-    protected abstract CallbackObject getCallbackObject(T parser, Class<?> type);
110
+    protected CallbackObject getCallbackObject(final Parser parser, final Class<?> type) {
111
+        return new CallbackObject(parser, this, type.asSubclass(CallbackInterface.class), implementationMap);
112
+    }
109 113
 
110 114
     /**
111 115
      * Retrieves a relevant {@link CallbackObjectSpecific} for the specified type.
@@ -114,7 +118,9 @@ public abstract class CallbackManager<T extends Parser> {
114 118
      * @param type The type of callback to create an object for
115 119
      * @return The relevant CallbackObject
116 120
      */
117
-    protected abstract CallbackObjectSpecific getSpecificCallbackObject(T parser, Class<?> type);
121
+    protected CallbackObjectSpecific getSpecificCallbackObject(final Parser parser, final Class<?> type) {
122
+        return new CallbackObjectSpecific(parser, this, type.asSubclass(CallbackInterface.class), implementationMap);
123
+    }
118 124
 
119 125
     /**
120 126
      * Add new callback type.

+ 15
- 9
src/com/dmdirc/parser/common/CallbackObject.java Bestand weergeven

@@ -39,12 +39,9 @@ import java.util.Map;
39 39
 import java.util.concurrent.CopyOnWriteArrayList;
40 40
 
41 41
 /**
42
- * CallbackObject.
43 42
  * Superclass for all callback types.
44
- *
45
- * @author            Shane Mc Cormack
46 43
  */
47
-public abstract class CallbackObject {
44
+public class CallbackObject {
48 45
 
49 46
     /** The type of callback that this object is operating with. */
50 47
     protected final Class<? extends CallbackInterface> type;
@@ -57,7 +54,10 @@ public abstract class CallbackObject {
57 54
     protected Parser myParser;
58 55
 
59 56
     /** Reference to the CallbackManager in charge of this callback. */
60
-    protected CallbackManager<?> myManager;
57
+    protected CallbackManager myManager;
58
+    
59
+    /** A map of interfaces to their concrete implementations. */
60
+    private final Map<Class<?>, Class<?>> implementationMap;
61 61
 
62 62
     /**
63 63
      * Create a new instance of the Callback Object.
@@ -65,13 +65,17 @@ public abstract class CallbackObject {
65 65
      * @param parser Parser That owns this callback
66 66
      * @param manager CallbackManager that is in charge of this callback
67 67
      * @param type The type of callback to use
68
-     * @since 0.6.3m1
68
+     * @param implementationMap A map of interfaces to their parser-specific
69
+     * implementations
70
+     * @since 0.6.6
69 71
      */
70
-    public CallbackObject(final Parser parser, final CallbackManager<?> manager,
71
-            final Class<? extends CallbackInterface> type) {
72
+    public CallbackObject(final Parser parser, final CallbackManager manager,
73
+            final Class<? extends CallbackInterface> type,
74
+            final Map<Class<?>, Class<?>> implementationMap) {
72 75
         this.myParser = parser;
73 76
         this.myManager = manager;
74 77
         this.type = type;
78
+        this.implementationMap = implementationMap;
75 79
     }
76 80
 
77 81
     /**
@@ -305,6 +309,8 @@ public abstract class CallbackObject {
305 309
      * @param type The type to be instansiated
306 310
      * @return A concrete implementation of that type
307 311
      */
308
-    protected abstract Class<?> getImplementation(final Class<?> type);
312
+    protected Class<?> getImplementation(final Class<?> type) {
313
+        return implementationMap.containsKey(type) ? implementationMap.get(type) : type;
314
+    }
309 315
 
310 316
 }

+ 9
- 8
src/com/dmdirc/parser/common/CallbackObjectSpecific.java Bestand weergeven

@@ -33,12 +33,9 @@ import java.util.HashMap;
33 33
 import java.util.Map;
34 34
 
35 35
 /**
36
- * CallbackObjectSpecific.
37 36
  * Superclass for all callback types that have a "specific" target.
38
- *
39
- * @author            Shane Mc Cormack
40 37
  */
41
-public abstract class CallbackObjectSpecific extends CallbackObject {
38
+public class CallbackObjectSpecific extends CallbackObject {
42 39
 
43 40
     /** Hashtable for storing specific information for callback. */
44 41
     protected final Map<CallbackInterface, String> specificData
@@ -50,11 +47,13 @@ public abstract class CallbackObjectSpecific extends CallbackObject {
50 47
      * @param parser Parser That owns this callback
51 48
      * @param manager CallbackManager that is in charge of this callback
52 49
      * @param type The type of callback to use
50
+     * @param implementationMap A map of interfaces to their parser-specific
53 51
      * @since 0.6.3m1
54 52
      */
55
-    public CallbackObjectSpecific(final Parser parser, final CallbackManager<?> manager,
56
-            final Class<? extends CallbackInterface> type) {
57
-        super(parser, manager, type);
53
+    public CallbackObjectSpecific(final Parser parser, final CallbackManager manager,
54
+            final Class<? extends CallbackInterface> type,
55
+            final Map<Class<?>, Class<?>> implementationMap) {
56
+        super(parser, manager, type, implementationMap);
58 57
     }
59 58
 
60 59
     /**
@@ -91,7 +90,9 @@ public abstract class CallbackObjectSpecific extends CallbackObject {
91 90
      * @param hostname The hostname to be parsed
92 91
      * @return The translated hostname
93 92
      */
94
-    protected abstract String translateHostname(final String hostname);
93
+    protected String translateHostname(final String hostname) {
94
+        return myParser.parseHostmask(hostname)[0];
95
+    }
95 96
 
96 97
     // We override the default add method to make sure that any add with no
97 98
     // specifics will have the specific data removed.

+ 1
- 1
src/com/dmdirc/parser/interfaces/Parser.java Bestand weergeven

@@ -332,7 +332,7 @@ public interface Parser extends Runnable {
332 332
      *
333 333
      * @return This parser's callback manager
334 334
      */
335
-    CallbackManager<? extends Parser> getCallbackManager();
335
+    CallbackManager getCallbackManager();
336 336
 
337 337
     /**
338 338
      * Retrieves the latency between the parser and the server in milliseconds.

+ 0
- 42
src/com/dmdirc/parser/interfaces/callbacks/Post005Listener.java Bestand weergeven

@@ -1,42 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.parser.interfaces.callbacks;
24
-
25
-import com.dmdirc.parser.interfaces.Parser;
26
-import java.util.Date;
27
-
28
-/**
29
- * Called after 001.
30
- */
31
-public interface Post005Listener extends CallbackInterface {
32
-
33
-    /**
34
-     * Called after 005.
35
-     *
36
-     * @param parser Reference to the parser object that made the callback.
37
-     * @param date The date/time at which the event occured
38
-     * @see com.dmdirc.parser.irc.Process001#callPost005
39
-     */
40
-    void onPost005(Parser parser, Date date);
41
-
42
-}

+ 0
- 55
src/com/dmdirc/parser/irc/IRCCallbackManager.java Bestand weergeven

@@ -1,55 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.parser.irc;
24
-
25
-import com.dmdirc.parser.common.CallbackManager;
26
-import com.dmdirc.parser.common.CallbackObject;
27
-import com.dmdirc.parser.common.CallbackObjectSpecific;
28
-import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
29
-
30
-/**
31
- * Handles callbacks for the IRC Parser.
32
- *
33
- * @author chris
34
- */
35
-public class IRCCallbackManager extends CallbackManager<IRCParser> {
36
-
37
-    public IRCCallbackManager(final IRCParser parser) {
38
-        super(parser);
39
-    }
40
-
41
-    /** {@inheritDoc} */
42
-    @Override
43
-    protected CallbackObject getCallbackObject(final IRCParser parser, final Class<?> type) {
44
-        return new IRCCallbackObject(parser, this, type.asSubclass(CallbackInterface.class));
45
-    }
46
-
47
-    /** {@inheritDoc} */
48
-    @Override
49
-    protected CallbackObjectSpecific getSpecificCallbackObject(final IRCParser parser,
50
-            final Class<?> type) {
51
-        return new IRCCallbackObjectSpecific(parser, this,
52
-                type.asSubclass(CallbackInterface.class));
53
-    }
54
-
55
-}

+ 0
- 76
src/com/dmdirc/parser/irc/IRCCallbackObject.java Bestand weergeven

@@ -1,76 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.parser.irc;
24
-
25
-import com.dmdirc.parser.common.CallbackManager;
26
-import com.dmdirc.parser.common.CallbackObject;
27
-import com.dmdirc.parser.interfaces.ChannelClientInfo;
28
-import com.dmdirc.parser.interfaces.ChannelInfo;
29
-import com.dmdirc.parser.interfaces.ClientInfo;
30
-import com.dmdirc.parser.interfaces.LocalClientInfo;
31
-import com.dmdirc.parser.interfaces.Parser;
32
-import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
33
-import java.util.HashMap;
34
-import java.util.Map;
35
-
36
-/**
37
- * A callback object for the IRC parser.
38
- *
39
- * @since 0.6.3m2
40
- * @author chris
41
- */
42
-public class IRCCallbackObject extends CallbackObject {
43
-
44
-    /**
45
-     * A map of interfaces to the classes which should be instansiated for them.
46
-     */
47
-    protected static final Map<Class<?>, Class<?>> IMPL_MAP
48
-            = new HashMap<Class<?>, Class<?>>();
49
-
50
-    static {
51
-        IMPL_MAP.put(ChannelClientInfo.class, IRCChannelClientInfo.class);
52
-        IMPL_MAP.put(ChannelInfo.class, IRCChannelInfo.class);
53
-        IMPL_MAP.put(ClientInfo.class, IRCClientInfo.class);
54
-        IMPL_MAP.put(LocalClientInfo.class, IRCClientInfo.class);
55
-    }
56
-
57
-    /**
58
-     * Creates a new IRC parser callback object.
59
-     *
60
-     * @param parser Parser this callback is owned by
61
-     * @param manager Manager callback is owned by
62
-     * @param type Callback type
63
-     */
64
-    public IRCCallbackObject(final Parser parser,
65
-            final CallbackManager<?> manager,
66
-            final Class<? extends CallbackInterface> type) {
67
-        super(parser, manager, type);
68
-    }
69
-
70
-    /** {@inheritDoc} */
71
-    @Override
72
-    protected Class<?> getImplementation(final Class<?> type) {
73
-        return IMPL_MAP.containsKey(type) ? IMPL_MAP.get(type) : type;
74
-    }
75
-
76
-}

+ 19
- 3
src/com/dmdirc/parser/irc/IRCParser.java Bestand weergeven

@@ -29,8 +29,12 @@ import com.dmdirc.parser.common.MyInfo;
29 29
 import com.dmdirc.parser.common.ParserError;
30 30
 import com.dmdirc.parser.common.QueuePriority;
31 31
 import com.dmdirc.parser.common.SystemEncoder;
32
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
33
+import com.dmdirc.parser.interfaces.ChannelInfo;
34
+import com.dmdirc.parser.interfaces.ClientInfo;
32 35
 import com.dmdirc.parser.interfaces.Encoder;
33 36
 import com.dmdirc.parser.interfaces.EncodingParser;
37
+import com.dmdirc.parser.interfaces.LocalClientInfo;
34 38
 import com.dmdirc.parser.interfaces.SecureParser;
35 39
 import com.dmdirc.parser.interfaces.callbacks.*; //NOPMD
36 40
 import com.dmdirc.parser.irc.IRCReader.ReadLine;
@@ -85,6 +89,16 @@ public class IRCParser implements SecureParser, EncodingParser, Runnable {
85 89
     /** List Mode Queue Debug Information. */
86 90
     public static final int DEBUG_LMQ = 8;
87 91
     //public static final int DEBUG_SOMETHING = 16; //Next thingy
92
+    
93
+    /** A map of this parser's implementations of common interfaces. */
94
+    public static final Map<Class<?>, Class<?>> IMPL_MAP = new HashMap<Class<?>, Class<?>>();
95
+
96
+    static {
97
+        IMPL_MAP.put(ChannelClientInfo.class, IRCChannelClientInfo.class);
98
+        IMPL_MAP.put(ChannelInfo.class, IRCChannelInfo.class);
99
+        IMPL_MAP.put(ClientInfo.class, IRCClientInfo.class);
100
+        IMPL_MAP.put(LocalClientInfo.class, IRCClientInfo.class);
101
+    }
88 102
 
89 103
     /** Attempt to update user host all the time, not just on Who/Add/NickChange. */
90 104
     static final boolean ALWAYS_UPDATECLIENT = true;
@@ -218,7 +232,7 @@ public class IRCParser implements SecureParser, EncodingParser, Runnable {
218 232
     private IgnoreList myIgnoreList = new IgnoreList();
219 233
 
220 234
     /** Reference to the callback Manager. */
221
-    private final CallbackManager<IRCParser> myCallbackManager = new IRCCallbackManager(this);
235
+    private final CallbackManager myCallbackManager = new CallbackManager(this, IMPL_MAP);
222 236
     /** Reference to the Processing Manager. */
223 237
     private final ProcessingManager myProcessingManager = new ProcessingManager(this);
224 238
 
@@ -485,7 +499,9 @@ public class IRCParser implements SecureParser, EncodingParser, Runnable {
485 499
 
486 500
     /** {@inheritDoc} */
487 501
     @Override
488
-    public CallbackManager<IRCParser> getCallbackManager() { return myCallbackManager;    }
502
+    public CallbackManager getCallbackManager() {
503
+        return myCallbackManager;
504
+    }
489 505
 
490 506
     /**
491 507
      * Get a reference to the default TrustManager for SSL Sockets.
@@ -656,7 +672,7 @@ public class IRCParser implements SecureParser, EncodingParser, Runnable {
656 672
         if (!h005Info.containsKey("USERMODES")) { parseUserModes(); }
657 673
         if (!h005Info.containsKey("CHANMODES")) { parseChanModes(); }
658 674
 
659
-        return getCallbackManager().getCallbackType(Post005Listener.class).call();
675
+        return getCallbackManager().getCallbackType(ServerReadyListener.class).call();
660 676
     }
661 677
 
662 678
     //---------------------------------------------------------------------------

+ 1
- 1
src/com/dmdirc/parser/irc/IRCProcessor.java Bestand weergeven

@@ -123,7 +123,7 @@ public abstract class IRCProcessor {
123 123
      *
124 124
      * @return Reference to the CallbackManager
125 125
      */
126
-    protected final CallbackManager<?> getCallbackManager() {
126
+    protected final CallbackManager getCallbackManager() {
127 127
         return myParser.getCallbackManager();
128 128
     }
129 129
 

+ 0
- 12
src/com/dmdirc/parser/irc/Process001.java Bestand weergeven

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.parser.irc;
24 24
 
25 25
 import com.dmdirc.parser.common.ParserError;
26
-import com.dmdirc.parser.interfaces.callbacks.ServerReadyListener;
27 26
 
28 27
 /**
29 28
  * Process a 001 message.
@@ -66,7 +65,6 @@ public class Process001 extends IRCProcessor {
66 65
             }
67 66
         }
68 67
 
69
-        callServerReady();
70 68
         myParser.startPingTimer();
71 69
 
72 70
         final String channels = myParser.server.getChannels();
@@ -75,16 +73,6 @@ public class Process001 extends IRCProcessor {
75 73
         }
76 74
     }
77 75
 
78
-    /**
79
-     * Callback to all objects implementing the ServerReady Callback.
80
-     *
81
-     * @see IServerReady
82
-     * @return true if a method was called, false otherwise
83
-     */
84
-    protected boolean callServerReady() {
85
-        return getCallbackManager().getCallbackType(ServerReadyListener.class).call();
86
-    }
87
-
88 76
     /**
89 77
      * What does this IRCProcessor handle.
90 78
      *

+ 6
- 6
test/com/dmdirc/parser/irc/IRCParserTest.java Bestand weergeven

@@ -33,8 +33,8 @@ import com.dmdirc.parser.interfaces.callbacks.ChannelKickListener;
33 33
 import com.dmdirc.parser.interfaces.callbacks.ConnectErrorListener;
34 34
 import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
35 35
 import com.dmdirc.parser.interfaces.callbacks.NumericListener;
36
-import com.dmdirc.parser.interfaces.callbacks.Post005Listener;
37 36
 import com.dmdirc.parser.interfaces.callbacks.ServerErrorListener;
37
+import com.dmdirc.parser.interfaces.callbacks.ServerReadyListener;
38 38
 
39 39
 import java.net.URI;
40 40
 import java.net.URISyntaxException;
@@ -198,10 +198,10 @@ public class IRCParserTest {
198 198
     }
199 199
 
200 200
     @Test
201
-    public void testPost005() throws CallbackNotFoundException {
202
-        final Post005Listener test = mock(Post005Listener.class);
201
+    public void testServerReady() throws CallbackNotFoundException {
202
+        final ServerReadyListener test = mock(ServerReadyListener.class);
203 203
         final TestParser parser = new TestParser();
204
-        parser.getCallbackManager().addCallback(Post005Listener.class, test);
204
+        parser.getCallbackManager().addCallback(ServerReadyListener.class, test);
205 205
 
206 206
         final String[] strings = {
207 207
             "NOTICE AUTH :Blah, blah",
@@ -218,11 +218,11 @@ public class IRCParserTest {
218 218
         };
219 219
 
220 220
         for (String string : strings) {
221
-            verify(test, never()).onPost005((Parser) anyObject(), (Date) anyObject());
221
+            verify(test, never()).onServerReady((Parser) anyObject(), (Date) anyObject());
222 222
             parser.injectLine(string);
223 223
         }
224 224
 
225
-        verify(test).onPost005(same(parser), (Date) anyObject());
225
+        verify(test).onServerReady(same(parser), (Date) anyObject());
226 226
     }
227 227
 
228 228
     @Test

Laden…
Annuleren
Opslaan