Browse Source

Add protocol description objects (parser information objects)

Fixes issue 3472

Change-Id: If3f401793669e0e309d5841da217f7464958fbac
Reviewed-on: http://gerrit.dmdirc.com/1181
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4
Chris Smith 14 years ago
parent
commit
2d35680c0c

+ 2
- 1
src/com/dmdirc/parser/interfaces/Parser.java View File

@@ -25,8 +25,8 @@ package com.dmdirc.parser.interfaces;
25 25
 import com.dmdirc.parser.common.IgnoreList;
26 26
 import com.dmdirc.parser.common.CallbackManager;
27 27
 import com.dmdirc.parser.common.ChannelJoinRequest;
28
-
29 28
 import com.dmdirc.parser.common.QueuePriority;
29
+
30 30
 import java.net.URI;
31 31
 import java.util.Collection;
32 32
 import java.util.Map;
@@ -199,6 +199,7 @@ public interface Parser extends Runnable {
199 199
      * Extracts any channels present in the specified URI.
200 200
      *
201 201
      * @param uri The URI to extract channels from
202
+     * @return A list of channel join requests extracted from the specified URI
202 203
      * @since 0.6.4
203 204
      */
204 205
     Collection<? extends ChannelJoinRequest> extractChannels(final URI uri);

+ 50
- 0
src/com/dmdirc/parser/interfaces/ProtocolDescription.java View File

@@ -0,0 +1,50 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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;
24
+
25
+/**
26
+ * Describes the default properties a protocol handled by a {@link Parser}
27
+ * instance.
28
+ *
29
+ * @since 0.6.4
30
+ * @author chris
31
+ */
32
+public interface ProtocolDescription {
33
+
34
+    /**
35
+     * Retrieves the default port to use for this protocol if none is specified.
36
+     *
37
+     * @return This protocol's default port
38
+     */
39
+    int getDefaultPort();
40
+
41
+    /**
42
+     * Parses the specified hostmask into an array containing a nickname,
43
+     * username and hostname, in that order.
44
+     *
45
+     * @param hostmask The hostmask to be parsed
46
+     * @return An array containing the nickname, username and hostname
47
+     */
48
+    String[] parseHostmask(String hostmask);
49
+
50
+}

+ 47
- 0
src/com/dmdirc/parser/irc/IRCProtocolDescription.java View File

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.interfaces.ProtocolDescription;
26
+
27
+/**
28
+ * Provides a description of the IRC protocol.
29
+ *
30
+ * @since 0.6.4
31
+ * @author chris
32
+ */
33
+public class IRCProtocolDescription implements ProtocolDescription {
34
+
35
+    /** {@inheritDoc} */
36
+    @Override
37
+    public int getDefaultPort() {
38
+        return 6667;
39
+    }
40
+
41
+    /** {@inheritDoc} */
42
+    @Override
43
+    public String[] parseHostmask(final String hostmask) {
44
+        return IRCClientInfo.parseHostFull(hostmask);
45
+    }
46
+
47
+}

Loading…
Cancel
Save