Browse Source

Merge branch 'command-abstraction'

Fixes issue 2209
Fixes issue 2210
Fixes issue 1453
Fixes issue 1975
tags/0.6.3m1rc1
Chris Smith 15 years ago
parent
commit
c79410ce36
100 changed files with 895 additions and 658 deletions
  1. 5
    9
      src/com/dmdirc/addons/audio/AudioCommand.java
  2. 4
    8
      src/com/dmdirc/addons/audio/BeepCommand.java
  3. 2
    1
      src/com/dmdirc/addons/dcc/DCCChatWindow.java
  4. 12
    16
      src/com/dmdirc/addons/dcc/DCCCommand.java
  5. 2
    57
      src/com/dmdirc/addons/dcc/DCCFrame.java
  6. 6
    11
      src/com/dmdirc/addons/dcop/DcopCommand.java
  7. 11
    6
      src/com/dmdirc/addons/dns/DNSCommand.java
  8. 9
    14
      src/com/dmdirc/addons/logging/LoggingCommand.java
  9. 8
    5
      src/com/dmdirc/addons/nowplaying/NowPlayingCommand.java
  10. 5
    3
      src/com/dmdirc/addons/osd/OsdCommand.java
  11. 3
    2
      src/com/dmdirc/addons/redirect/RedirectCommand.java
  12. 3
    2
      src/com/dmdirc/addons/systray/PopupCommand.java
  13. 6
    5
      src/com/dmdirc/addons/time/TimerCommand.java
  14. 2
    1
      src/com/dmdirc/addons/urlcatcher/UrlListCommand.java
  15. 193
    0
      src/com/dmdirc/commandparser/CommandArguments.java
  16. 9
    5
      src/com/dmdirc/commandparser/CommandInfo.java
  17. 82
    121
      src/com/dmdirc/commandparser/CommandManager.java
  18. 18
    0
      src/com/dmdirc/commandparser/CommandType.java
  19. 14
    2
      src/com/dmdirc/commandparser/commands/ChannelCommand.java
  20. 12
    2
      src/com/dmdirc/commandparser/commands/ChatCommand.java
  21. 8
    17
      src/com/dmdirc/commandparser/commands/Command.java
  22. 3
    1
      src/com/dmdirc/commandparser/commands/ExternalCommand.java
  23. 14
    2
      src/com/dmdirc/commandparser/commands/GlobalCommand.java
  24. 14
    2
      src/com/dmdirc/commandparser/commands/QueryCommand.java
  25. 14
    2
      src/com/dmdirc/commandparser/commands/ServerCommand.java
  26. 6
    5
      src/com/dmdirc/commandparser/commands/channel/Ban.java
  27. 2
    1
      src/com/dmdirc/commandparser/commands/channel/ChannelSettings.java
  28. 3
    2
      src/com/dmdirc/commandparser/commands/channel/Cycle.java
  29. 8
    5
      src/com/dmdirc/commandparser/commands/channel/KickReason.java
  30. 7
    6
      src/com/dmdirc/commandparser/commands/channel/Mode.java
  31. 3
    2
      src/com/dmdirc/commandparser/commands/channel/Names.java
  32. 3
    2
      src/com/dmdirc/commandparser/commands/channel/Part.java
  33. 9
    8
      src/com/dmdirc/commandparser/commands/channel/SetNickColour.java
  34. 7
    6
      src/com/dmdirc/commandparser/commands/channel/ShowTopic.java
  35. 4
    3
      src/com/dmdirc/commandparser/commands/chat/Me.java
  36. 3
    2
      src/com/dmdirc/commandparser/commands/global/Active.java
  37. 9
    8
      src/com/dmdirc/commandparser/commands/global/AliasCommand.java
  38. 3
    2
      src/com/dmdirc/commandparser/commands/global/AllServers.java
  39. 2
    1
      src/com/dmdirc/commandparser/commands/global/Clear.java
  40. 22
    21
      src/com/dmdirc/commandparser/commands/global/Debug.java
  41. 11
    9
      src/com/dmdirc/commandparser/commands/global/Echo.java
  42. 3
    2
      src/com/dmdirc/commandparser/commands/global/Exit.java
  43. 21
    20
      src/com/dmdirc/commandparser/commands/global/Help.java
  44. 7
    6
      src/com/dmdirc/commandparser/commands/global/Ifplugin.java
  45. 6
    4
      src/com/dmdirc/commandparser/commands/global/LoadPlugin.java
  46. 9
    8
      src/com/dmdirc/commandparser/commands/global/NewServer.java
  47. 4
    3
      src/com/dmdirc/commandparser/commands/global/Notify.java
  48. 11
    10
      src/com/dmdirc/commandparser/commands/global/OpenWindow.java
  49. 2
    1
      src/com/dmdirc/commandparser/commands/global/ReloadActions.java
  50. 3
    1
      src/com/dmdirc/commandparser/commands/global/ReloadIdentities.java
  51. 4
    3
      src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java
  52. 9
    4
      src/com/dmdirc/commandparser/commands/global/SaveConfig.java
  53. 18
    12
      src/com/dmdirc/commandparser/commands/global/Set.java
  54. 5
    3
      src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java
  55. 3
    2
      src/com/dmdirc/commandparser/commands/server/AllChannels.java
  56. 3
    2
      src/com/dmdirc/commandparser/commands/server/Away.java
  57. 2
    1
      src/com/dmdirc/commandparser/commands/server/Back.java
  58. 9
    8
      src/com/dmdirc/commandparser/commands/server/ChangeServer.java
  59. 7
    5
      src/com/dmdirc/commandparser/commands/server/Ctcp.java
  60. 4
    3
      src/com/dmdirc/commandparser/commands/server/Disconnect.java
  61. 13
    7
      src/com/dmdirc/commandparser/commands/server/Ignore.java
  62. 13
    11
      src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java
  63. 7
    5
      src/com/dmdirc/commandparser/commands/server/Message.java
  64. 12
    13
      src/com/dmdirc/commandparser/commands/server/Nick.java
  65. 7
    5
      src/com/dmdirc/commandparser/commands/server/Notice.java
  66. 12
    10
      src/com/dmdirc/commandparser/commands/server/OpenQuery.java
  67. 11
    12
      src/com/dmdirc/commandparser/commands/server/Raw.java
  68. 3
    2
      src/com/dmdirc/commandparser/commands/server/RawServerCommand.java
  69. 4
    3
      src/com/dmdirc/commandparser/commands/server/Reconnect.java
  70. 3
    2
      src/com/dmdirc/commandparser/commands/server/Umode.java
  71. 10
    5
      src/com/dmdirc/commandparser/parsers/ChannelCommandParser.java
  72. 35
    53
      src/com/dmdirc/commandparser/parsers/CommandParser.java
  73. 7
    2
      src/com/dmdirc/commandparser/parsers/GlobalCommandParser.java
  74. 8
    4
      src/com/dmdirc/commandparser/parsers/QueryCommandParser.java
  75. 7
    3
      src/com/dmdirc/commandparser/parsers/ServerCommandParser.java
  76. 4
    0
      src/com/dmdirc/config/defaults/default/defaults
  77. 3
    3
      src/com/dmdirc/config/prefs/PreferencesManager.java
  78. 3
    6
      src/com/dmdirc/config/prefs/PreferencesSetting.java
  79. 1
    1
      test/com/dmdirc/IgnoreListTest.java
  80. 1
    1
      test/com/dmdirc/ProgramErrorTest.java
  81. 1
    1
      test/com/dmdirc/StringTranscoderTest.java
  82. 1
    1
      test/com/dmdirc/WritableFrameContainerTest.java
  83. 0
    4
      test/com/dmdirc/actions/ActionComparisonNamesTest.java
  84. 4
    5
      test/com/dmdirc/actions/ActionComponentChainTest.java
  85. 7
    3
      test/com/dmdirc/actions/ActionConditionTest.java
  86. 1
    1
      test/com/dmdirc/actions/ActionGroupTest.java
  87. 5
    3
      test/com/dmdirc/actions/ActionManagerTest.java
  88. 8
    1
      test/com/dmdirc/actions/ActionModelTest.java
  89. 4
    3
      test/com/dmdirc/actions/ActionTest.java
  90. 1
    1
      test/com/dmdirc/actions/ActionTypeComparatorTest.java
  91. 1
    1
      test/com/dmdirc/actions/ConditionTreeTest.java
  92. 1
    1
      test/com/dmdirc/actions/CoreActionComparisonTest.java
  93. 1
    1
      test/com/dmdirc/actions/CoreActionTypeTest.java
  94. 0
    4
      test/com/dmdirc/actions/StringComponentsTest.java
  95. 1
    1
      test/com/dmdirc/actions/metatypes/ActionEventsTest.java
  96. 1
    1
      test/com/dmdirc/actions/metatypes/ChannelEventsTest.java
  97. 1
    1
      test/com/dmdirc/actions/metatypes/ClientEventsTest.java
  98. 1
    1
      test/com/dmdirc/actions/metatypes/PluginEventsTest.java
  99. 1
    1
      test/com/dmdirc/actions/metatypes/QueryEventsTest.java
  100. 0
    0
      test/com/dmdirc/actions/metatypes/ServerEventsTest.java

+ 5
- 9
src/com/dmdirc/addons/audio/AudioCommand.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.audio;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -43,16 +44,11 @@ public final class AudioCommand extends GlobalCommand {
43 44
 		CommandManager.registerCommand(this);
44 45
 	}
45 46
 		
46
-	/**
47
-	 * Executes this command.
48
-	 *
49
-	 * @param origin The frame in which this command was issued
50
-	 * @param isSilent Whether this command is silenced or not
51
-	 * @param args The user supplied arguments
52
-	 */
47
+	/** {@inheritDoc} */
53 48
     @Override
54
-	public void execute(final InputWindow origin, final boolean isSilent, final String... args) {
55
-		final String filename = implodeArgs(args);
49
+	public void execute(final InputWindow origin, final boolean isSilent,
50
+            final CommandArguments args) {
51
+		final String filename = args.getArgumentsAsString();
56 52
 		final File file = new File(filename);
57 53
 		if (file.exists()) {
58 54
 			if (AudioPlayer.isValid(file)) {

+ 4
- 8
src/com/dmdirc/addons/audio/BeepCommand.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.audio;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -43,15 +44,10 @@ public final class BeepCommand extends GlobalCommand {
43 44
 		CommandManager.registerCommand(this);
44 45
 	}
45 46
 		
46
-	/**
47
-	 * Executes this command.
48
-	 *
49
-	 * @param origin The frame in which this command was issued
50
-	 * @param isSilent Whether this command is silenced or not
51
-	 * @param args The user supplied arguments
52
-	 */
47
+	/** {@inheritDoc} */
53 48
     @Override
54
-	public void execute(final InputWindow origin, final boolean isSilent, final String... args) {
49
+	public void execute(final InputWindow origin, final boolean isSilent,
50
+            final CommandArguments args) {
55 51
 		Toolkit.getDefaultToolkit().beep();
56 52
 	}
57 53
 

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

@@ -25,6 +25,7 @@ package com.dmdirc.addons.dcc;
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.addons.dcc.actions.DCCActions;
27 27
 import com.dmdirc.Main;
28
+import com.dmdirc.commandparser.parsers.GlobalCommandParser;
28 29
 
29 30
 /**
30 31
  * This class links DCC Chat objects to a window.
@@ -57,7 +58,7 @@ public class DCCChatWindow extends DCCFrame implements DCCChatInterface {
57 58
 		nickname = nick;
58 59
 		otherNickname = targetNick;
59 60
 		
60
-		myWindow = Main.getUI().getInputWindow(this, getDCCCommandParser());
61
+		myWindow = Main.getUI().getInputWindow(this, GlobalCommandParser.getGlobalCommandParser());
61 62
 		plugin.addWindow(this);
62 63
 		
63 64
 		myWindow.setTitle(title);

+ 12
- 16
src/com/dmdirc/addons/dcc/DCCCommand.java View File

@@ -37,6 +37,7 @@ import com.dmdirc.actions.ActionManager;
37 37
 import com.dmdirc.addons.dcc.kde.KFileChooser;
38 38
 import com.dmdirc.addons.dcc.actions.DCCActions;
39 39
 
40
+import com.dmdirc.commandparser.CommandArguments;
40 41
 import javax.swing.JFileChooser;
41 42
 import javax.swing.JFrame;
42 43
 import javax.swing.JOptionPane;
@@ -66,19 +67,13 @@ public final class DCCCommand extends ServerCommand implements IntelligentComman
66 67
 		CommandManager.registerCommand(this);
67 68
 	}
68 69
 		
69
-	/**
70
-	 * Executes this command.
71
-	 *
72
-	 * @param origin The frame in which this command was issued
73
-	 * @param server The server instance that this command is being executed on
74
-	 * @param isSilent Whether this command is silenced or not
75
-	 * @param args The user supplied arguments
76
-	 */
70
+	/** {@inheritDoc} */
77 71
 	@Override
78
-	public void execute(final InputWindow origin, final Server server, final boolean isSilent, final String... args) {
79
-		if (args.length > 1) {
80
-			final String type = args[0];
81
-			final String target = args[1];
72
+	public void execute(final InputWindow origin, final Server server,
73
+            final boolean isSilent, final CommandArguments args) {
74
+		if (args.getArguments().length > 1) {
75
+			final String type = args.getArguments()[0];
76
+			final String target = args.getArguments()[1];
82 77
 			final IRCParser parser = server.getParser();
83 78
 			final String myNickname = parser.getMyNickname();
84 79
 				
@@ -112,7 +107,7 @@ public final class DCCCommand extends ServerCommand implements IntelligentComman
112 107
 					sendLine(origin, isSilent, "DCCChatError", "Unable to start chat with "+target+" - unable to create listen socket");
113 108
 				}
114 109
 			} else if (type.equalsIgnoreCase("send")) {
115
-				sendFile(target, origin, server, isSilent, args);
110
+				sendFile(target, origin, server, isSilent, args.getArgumentsAsString(2));
116 111
 			} else {
117 112
 				sendLine(origin, isSilent, FORMAT_ERROR, "Unknown DCC Type: '"+type+"'");
118 113
 			}
@@ -128,11 +123,12 @@ public final class DCCCommand extends ServerCommand implements IntelligentComman
128 123
 	 * @param origin The InputWindow this command was issued on
129 124
 	 * @param server The server instance that this command is being executed on
130 125
 	 * @param isSilent Whether this command is silenced or not
131
-	 * @param args Arguments passed.
126
+	 * @param filename The file to send
127
+     * @since 0.6.3
132 128
 	 */
133
-	public void sendFile(final String target, final InputWindow origin, final Server server, final boolean isSilent, final String... args) {
129
+	public void sendFile(final String target, final InputWindow origin, final Server server, final boolean isSilent, final String filename) {
134 130
 		// New thread to ask the user what file to send
135
-		final File givenFile = new File(implodeArgs(2, args));
131
+		final File givenFile = new File(filename);
136 132
 		final Thread dccThread = new Thread(new Runnable() {
137 133
 			/** {@inheritDoc} */
138 134
 			@Override

+ 2
- 57
src/com/dmdirc/addons/dcc/DCCFrame.java View File

@@ -24,10 +24,7 @@ package com.dmdirc.addons.dcc;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.WritableFrameContainer;
27
-import com.dmdirc.commandparser.CommandManager;
28 27
 import com.dmdirc.commandparser.PopupType;
29
-import com.dmdirc.commandparser.commands.Command;
30
-import com.dmdirc.commandparser.commands.GlobalCommand;
31 28
 import com.dmdirc.commandparser.parsers.CommandParser;
32 29
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
33 30
 import com.dmdirc.config.IdentityManager;
@@ -69,10 +66,11 @@ public abstract class DCCFrame extends WritableFrameContainer {
69 66
 			 *
70 67
 			 * @return This window's command parser
71 68
 			 */
72
-        @Override
69
+            @Override
73 70
 			public final CommandParser getCommandParser() {
74 71
 				return GlobalCommandParser.getGlobalCommandParser();
75 72
 			}
73
+            
76 74
 			/** {@inheritDoc} */
77 75
 			@Override
78 76
 			public PopupType getNicknamePopupType() {
@@ -103,47 +101,6 @@ public abstract class DCCFrame extends WritableFrameContainer {
103 101
 				//Add no custom popup items
104 102
 			}
105 103
 	}
106
-	
107
-	/**
108
-	 * DCC CommandParser
109
-	 */
110
-	private static class DCCCommandParser extends CommandParser {
111
-		/** A version number for this class. */
112
-		private static final long serialVersionUID = 200711271;
113
-		
114
-		/** Loads the relevant commands into the parser. */
115
-		@Override
116
-		protected void loadCommands() { CommandManager.loadGlobalCommands(this); }
117
-		
118
-		/**
119
-		 * Executes the specified command with the given arguments.
120
-		 *
121
-		 * @param origin The window in which the command was typed
122
-		 * @param isSilent Whether the command is being silenced or not
123
-		 * @param command The command to be executed
124
-		 * @param args The arguments to the command
125
-		 */
126
-		@Override
127
-		protected void executeCommand(final InputWindow origin, final boolean isSilent, final Command command, final String... args) {
128
-			((GlobalCommand) command).execute(origin, isSilent, args);
129
-		}
130
-		
131
-		/**
132
-		 * Called when the input was a line of text that was not a command.
133
-		 * This normally means it is sent to the server/channel/user as-is, with
134
-		 * no further processing.
135
-		 *
136
-		 * @param origin The window in which the command was typed
137
-		 * @param line The line input by the user
138
-		 */
139
-		@Override
140
-		protected void handleNonCommand(final InputWindow origin, final String line) {
141
-			origin.getContainer().sendLine(line);
142
-		}
143
-	}
144
-	
145
-	/** The singleton instance of the DCC command parser. */
146
-	private static DCCCommandParser myDCCCommandParser;
147 104
 
148 105
 	/** The window title. */
149 106
 	protected final String title;
@@ -185,18 +142,6 @@ public abstract class DCCFrame extends WritableFrameContainer {
185 142
 		}
186 143
 	}
187 144
 	
188
-	/**
189
-	 * Retrieves a singleton instance of the DCC command parser.
190
-	 *
191
-	 * @return A DCCCommandParser
192
-	 */
193
-	static synchronized DCCCommandParser getDCCCommandParser() {
194
-		if (myDCCCommandParser == null) {
195
-			myDCCCommandParser = new DCCCommandParser();
196
-		}
197
-		return myDCCCommandParser;
198
-	}
199
-	
200 145
 	/**
201 146
 	 * Sends a line of text to this container's source.
202 147
 	 *

+ 6
- 11
src/com/dmdirc/addons/dcop/DcopCommand.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.dcop;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.ServerCommand;
28 29
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -43,23 +44,17 @@ public final class DcopCommand extends ServerCommand {
43 44
         
44 45
         CommandManager.registerCommand(this);
45 46
     }
46
-    
47
-    /**
48
-     * Executes this command.
49
-     * @param origin The frame in which this command was issued
50
-     * @param server The server object that this command is associated with
51
-     * @param isSilent Whether this command is silenced or not
52
-     * @param args The user supplied arguments
53
-     */
47
+
48
+    /** {@inheritDoc} */
54 49
     @Override
55 50
     public void execute(final InputWindow origin, final Server server,
56
-            final boolean isSilent, final String... args) {
57
-        if (args.length != 3) {
51
+            final boolean isSilent, final CommandArguments args) {
52
+        if (args.getArguments().length != 3) {
58 53
             showUsage(origin, isSilent, "dcop", "<app> <object> <function>");
59 54
             return;
60 55
         }
61 56
         
62
-        final List<String> res = DcopPlugin.getDcopResult("dcop " + implodeArgs(args));
57
+        final List<String> res = DcopPlugin.getDcopResult("dcop " + args.getArgumentsAsString());
63 58
         for (String line : res) {
64 59
             sendLine(origin, isSilent, FORMAT_OUTPUT, line);
65 60
         }

+ 11
- 6
src/com/dmdirc/addons/dns/DNSCommand.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.dns;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -44,21 +45,25 @@ public final class DNSCommand extends GlobalCommand {
44 45
     /** {@inheritDoc} */
45 46
     @Override
46 47
     public void execute(final InputWindow origin, final boolean isSilent,
47
-            final String... args) {
48
-        if (args.length == 0) {
48
+            final CommandArguments args) {
49
+        if (args.getArguments().length == 0) {
49 50
             showUsage(origin, isSilent, "dns", "<IP|hostname>");
50 51
             return;
51 52
         }
52 53
         
53
-        sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolving: " + args[0]);
54
+        sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolving: " + args.getArguments()[0]);
54 55
         new Timer("DNS Command Timer").schedule(new TimerTask() {
55 56
             /** {@inheritDoc} */
56 57
             @Override
57 58
             public void run() {
58
-                if (args[0].matches("\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b")) {
59
-                    sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: " + args[0] + ": " + DNSPlugin.getHostname(args[0]));
59
+                if (args.getArguments()[0].matches("\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b")) {
60
+                    sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: "
61
+                            + args.getArguments()[0] + ": "
62
+                            + DNSPlugin.getHostname(args.getArguments()[0]));
60 63
                 } else {
61
-                    sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: " + args[0] + ": " + DNSPlugin.getIPs(args[0]));
64
+                    sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: "
65
+                            + args.getArguments()[0] + ": "
66
+                            + DNSPlugin.getIPs(args.getArguments()[0]));
62 67
                 }
63 68
             }
64 69
         }, 0);

+ 9
- 14
src/com/dmdirc/addons/logging/LoggingCommand.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.logging;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28 29
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -48,16 +49,10 @@ public final class LoggingCommand extends ServerCommand implements IntelligentCo
48 49
 		CommandManager.registerCommand(this);
49 50
 	}
50 51
 		
51
-	/**
52
-	 * Executes this command.
53
-	 *
54
-	 * @param origin The frame in which this command was issued
55
-	 * @param server The server object that this command is associated with
56
-	 * @param isSilent Whether this command is silenced or not
57
-	 * @param args The user supplied arguments
58
-	 */
52
+    /** {@inheritDoc} */
59 53
     @Override
60
-	public void execute(final InputWindow origin, final Server server, final boolean isSilent, final String... args) {
54
+	public void execute(final InputWindow origin, final Server server,
55
+            final boolean isSilent, final CommandArguments args) {
61 56
 		final PluginInfo pluginInfo = PluginManager.getPluginManager().getPluginInfoByName("logging");
62 57
 		if (pluginInfo == null) { 
63 58
 			sendLine(origin, isSilent, FORMAT_ERROR, "Logging Plugin is not loaded.");
@@ -72,23 +67,23 @@ public final class LoggingCommand extends ServerCommand implements IntelligentCo
72 67
 		
73 68
 		final LoggingPlugin plugin = (LoggingPlugin) gotPlugin;
74 69
 		
75
-		if (args.length > 0) {
76
-			if (args[0].equalsIgnoreCase("reload")) {
70
+		if (args.getArguments().length > 0) {
71
+			if (args.getArguments()[0].equalsIgnoreCase("reload")) {
77 72
 				if (PluginManager.getPluginManager().reloadPlugin(pluginInfo.getFilename())) {
78 73
 					sendLine(origin, isSilent, FORMAT_OUTPUT, "Plugin reloaded.");
79 74
 				} else {
80 75
 					sendLine(origin, isSilent, FORMAT_ERROR, "Plugin failed to reload.");
81 76
 				}
82
-			} else if (args[0].equalsIgnoreCase("history")) {
77
+			} else if (args.getArguments()[0].equalsIgnoreCase("history")) {
83 78
 				if (!plugin.showHistory(origin)) {
84 79
 					sendLine(origin, isSilent, FORMAT_ERROR, "Unable to open history for this window.");
85 80
     		}
86
-			} else if (args[0].equalsIgnoreCase("help")) {
81
+			} else if (args.getArguments()[0].equalsIgnoreCase("help")) {
87 82
 				sendLine(origin, isSilent, FORMAT_OUTPUT, getName() + " reload           - Reload the logging plugin.");
88 83
 				sendLine(origin, isSilent, FORMAT_OUTPUT, getName() + " history          - Open the history of this window, if available.");
89 84
 				sendLine(origin, isSilent, FORMAT_OUTPUT, getName() + " help             - Show this help.");
90 85
 			} else {
91
-				sendLine(origin, isSilent, FORMAT_ERROR, "Unknown command '" + args[0] + "'. Use " + getName() + " help for a list of commands.");
86
+				sendLine(origin, isSilent, FORMAT_ERROR, "Unknown command '" + args.getArguments()[0] + "'. Use " + getName() + " help for a list of commands.");
92 87
 			}
93 88
 		} else {
94 89
 			sendLine(origin, isSilent, FORMAT_ERROR, "Use " + getName() + " help for a list of commands.");

+ 8
- 5
src/com/dmdirc/addons/nowplaying/NowPlayingCommand.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.addons.nowplaying;
24 24
 
25 25
 import com.dmdirc.MessageTarget;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChatCommand;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -59,12 +60,14 @@ public final class NowPlayingCommand extends ChatCommand implements IntelligentC
59 60
     /** {@inheritDoc} */
60 61
     @Override
61 62
     public void execute(final InputWindow origin, final Server server,
62
-            final MessageTarget target, final boolean isSilent, final String ... args) {
63
-        if (args.length > 0 && args[0].equalsIgnoreCase("--sources")) {
63
+            final MessageTarget target, final boolean isSilent, final CommandArguments args) {
64
+        if (args.getArguments().length > 0 && args.getArguments()[0]
65
+                .equalsIgnoreCase("--sources")) {
64 66
             doSourceList(origin, isSilent);
65
-        } else if (args.length > 0 && args[0].equalsIgnoreCase("--source")) {
66
-            if (args.length > 1) {
67
-                final String sourceName = args[1];
67
+        } else if (args.getArguments().length > 0 && args.getArguments()[0]
68
+                .equalsIgnoreCase("--source")) {
69
+            if (args.getArguments().length > 1) {
70
+                final String sourceName = args.getArguments()[1];
68 71
                 final MediaSource source = parent.getSource(sourceName);
69 72
                 
70 73
                 if (source == null) {

+ 5
- 3
src/com/dmdirc/addons/osd/OsdCommand.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.osd;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -49,11 +50,12 @@ public final class OsdCommand extends GlobalCommand implements IntelligentComman
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
53
-        if (args.length > 0 && "--close".equalsIgnoreCase(args[0])) {
53
+            final CommandArguments args) {
54
+        if (args.getArguments().length > 0
55
+                && "--close".equalsIgnoreCase(args.getArguments()[0])) {
54 56
             OsdWindow.closeAll();
55 57
         } else {
56
-            new OsdWindow(Styliser.stipControlCodes(implodeArgs(args)), false);
58
+            new OsdWindow(Styliser.stipControlCodes(args.getArgumentsAsString()), false);
57 59
         }
58 60
     }
59 61
     

+ 3
- 2
src/com/dmdirc/addons/redirect/RedirectCommand.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.addons.redirect;
24 24
 
25 25
 import com.dmdirc.MessageTarget;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChatCommand;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
29 30
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -46,9 +47,9 @@ public class RedirectCommand extends ChatCommand implements IntelligentCommand {
46 47
     /** {@inheritDoc} */
47 48
     @Override
48 49
     public void execute(final InputWindow origin, final Server server,
49
-            final MessageTarget target, final boolean isSilent, final String... args) {
50
+            final MessageTarget target, final boolean isSilent, final CommandArguments args) {
50 51
         target.getFrame().getCommandParser().parseCommand(new FakeInputWindow(target),
51
-                implodeArgs(args));
52
+                args.getArgumentsAsString());
52 53
     }
53 54
     
54 55
     /** {@inheritDoc} */

+ 3
- 2
src/com/dmdirc/addons/systray/PopupCommand.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.systray;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.ServerCommand;
28 29
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -52,8 +53,8 @@ public final class PopupCommand extends ServerCommand {
52 53
     /** {@inheritDoc} */
53 54
     @Override
54 55
     public void execute(final InputWindow origin, final Server server,
55
-            final boolean isSilent, final String ... args) {
56
-        parent.notify("DMDirc", implodeArgs(args));
56
+            final boolean isSilent, final CommandArguments args) {
57
+        parent.notify("DMDirc", args.getArgumentsAsString());
57 58
     }
58 59
 
59 60
     /** {@inheritDoc} */

+ 6
- 5
src/com/dmdirc/addons/time/TimerCommand.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.time;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -47,17 +48,17 @@ public final class TimerCommand extends GlobalCommand implements IntelligentComm
47 48
     /** {@inheritDoc} */
48 49
     @Override
49 50
     public void execute(final InputWindow origin, final boolean isSilent, 
50
-            final String... args) {
51
-        if (args.length < 3) {
51
+            final CommandArguments args) {
52
+        if (args.getArguments().length < 3) {
52 53
             doUsage(origin, isSilent);
53 54
         } else {
54 55
             int repetitions = 0;
55 56
             int interval = 0;
56
-            final String command = implodeArgs(2, args);
57
+            final String command = args.getArgumentsAsString(2);
57 58
             
58 59
             try {
59
-                repetitions = Integer.parseInt(args[0]);
60
-                interval = Integer.parseInt(args[1]);
60
+                repetitions = Integer.parseInt(args.getArguments()[0]);
61
+                interval = Integer.parseInt(args.getArguments()[1]);
61 62
             } catch (NumberFormatException ex) {
62 63
                 doUsage(origin, isSilent);
63 64
                 return;

+ 2
- 1
src/com/dmdirc/addons/urlcatcher/UrlListCommand.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.urlcatcher;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.commands.GlobalCommand;
26 27
 import com.dmdirc.commandparser.commands.IntelligentCommand;
27 28
 import com.dmdirc.ui.input.AdditionalTabTargets;
@@ -44,7 +45,7 @@ public class UrlListCommand extends GlobalCommand implements IntelligentCommand
44 45
     /** {@inheritDoc} */
45 46
     @Override
46 47
     public void execute(final InputWindow origin, final boolean isSilent,
47
-            final String... args) {
48
+            final CommandArguments args) {
48 49
         final String[] headers = {"URL", "Count"};
49 50
         final Map<String, Integer> map = plugin.getURLS();
50 51
         final String[][] data = new String[map.size()][];

+ 193
- 0
src/com/dmdirc/commandparser/CommandArguments.java View File

@@ -0,0 +1,193 @@
1
+/*
2
+ * Copyright (c) 2006-2009 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.commandparser;
24
+
25
+import java.util.Arrays;
26
+import java.util.regex.Matcher;
27
+import java.util.regex.Pattern;
28
+
29
+/**
30
+ * Represents a command and its arguments. In this class, input is split into
31
+ * 'words' which are separated by any number of whitespace characters;
32
+ * 'arguments' are the same but exclude the first word, which will normally be
33
+ * the command name.
34
+ *
35
+ * @since 0.6.3
36
+ * @author chris
37
+ */
38
+public class CommandArguments {
39
+
40
+    /** The raw line that was input. */
41
+    private final String line;
42
+
43
+    /** The line split into whitespace-delimited words. */
44
+    private String[] words;
45
+
46
+    /**
47
+     * Creates a new command arguments parser for the specified line.
48
+     *
49
+     * @param line The line to be parsed
50
+     */
51
+    public CommandArguments(final String line) {
52
+        this.line = line;
53
+    }
54
+
55
+    /**
56
+     * Retrieves the raw line that was input, including any command character(s)
57
+     * and names.
58
+     *
59
+     * @return The raw line entered
60
+     */
61
+    public String getLine() {
62
+        return line;
63
+    }
64
+
65
+    /**
66
+     * Retrieves the raw line that was input, including the command name but
67
+     * stripped of any command characters.
68
+     *
69
+     * @return The raw line entered, without command chars
70
+     */
71
+    public String getStrippedLine() {
72
+        final int offset = isCommand() ? isSilent() ? 2 : 1 : 0;
73
+
74
+        return line.substring(offset);
75
+    }
76
+
77
+    /**
78
+     * Retrieves the input split into distinct, whitespace-separated words. The
79
+     * first item in the array will be the command name complete with any
80
+     * command characters.
81
+     *
82
+     * @return An array of 'words' that make up the input
83
+     */
84
+    public String[] getWords() {
85
+        parse();
86
+        
87
+        return words;
88
+    }
89
+
90
+    /**
91
+     * Retrieves the arguments to the command split into disticnt,
92
+     * whitespace-separated words.
93
+     *
94
+     * @return An array of 'words' that make up the command's arguments
95
+     */
96
+    public String[] getArguments() {
97
+        parse();
98
+
99
+        return Arrays.copyOfRange(words, 1, words.length);
100
+    }
101
+
102
+    /**
103
+     * Retrieves all the arguments to the command (i.e., not including the
104
+     * command name) with their original whitespace separation preserved.
105
+     *
106
+     * @return A String representation of the command arguments
107
+     */
108
+    public String getArgumentsAsString() {
109
+        parse();
110
+        
111
+        return getArgumentsAsString(0);
112
+    }
113
+
114
+    /**
115
+     * Retrieves arguments to the command (i.e., not including the
116
+     * command name) starting with the specified argument, with their original
117
+     * whitespace separation preserved.
118
+     *
119
+     * @param start The index of the first argument to include
120
+     * @return A String representation of the command arguments
121
+     */
122
+    public String getArgumentsAsString(final int start) {
123
+        parse();
124
+
125
+        return getWordsAsString(start + 1);
126
+    }
127
+
128
+    /**
129
+     * Retrieves the specified words with their original whitespace separation
130
+     * preserved.
131
+     *
132
+     * @param start The index of the first word to include (starting at 0)
133
+     * @return A String representation of the requested words
134
+     */
135
+    public String getWordsAsString(final int start) {
136
+        return getWordsAsString(start, words.length);
137
+    }
138
+
139
+    /**
140
+     * Retrieves the specified words with their original whitespace separation
141
+     * preserved.
142
+     *
143
+     * @param start The index of the first word to include (starting at 0)
144
+     * @param end The index of the last word to include
145
+     * @return A String representation of the requested words
146
+     */
147
+    public String getWordsAsString(final int start, final int end) {
148
+        final Pattern pattern = Pattern.compile("(\\S+\\s*){" + (start) + "}"
149
+                + "((\\S+\\s*){" + (end - start) + "}).*?");
150
+        final Matcher matcher = pattern.matcher(line);
151
+
152
+        return matcher.matches() ? matcher.group(2) : "";
153
+    }
154
+
155
+    /**
156
+     * Parses the input into a set of words, if it has not been done before.
157
+     */
158
+    protected synchronized void parse() {
159
+        if (words == null) {
160
+            words = line.split("\\s+");
161
+        }
162
+    }
163
+
164
+    /**
165
+     * Determines if the input was a command or not.
166
+     *
167
+     * @return True if the input was a command, false otherwise
168
+     */
169
+    public boolean isCommand() {
170
+        return !line.isEmpty() && line.charAt(0) == CommandManager.getCommandChar();
171
+    }
172
+
173
+    /**
174
+     * Determines if the input was a silenced command or not.
175
+     *
176
+     * @return True if the input was a silenced command, false otherwise
177
+     */
178
+    public boolean isSilent() {
179
+        return isCommand() && line.length() >= 2 &&
180
+                line.charAt(1) == CommandManager.getSilenceChar();
181
+    }
182
+
183
+    /**
184
+     * Retrieves the name of the command that was used.
185
+     *
186
+     * @return The command name used
187
+     */
188
+    public String getCommandName() {
189
+        final int offset = isCommand() ? isSilent() ? 2 : 1 : 0;
190
+        return getWords()[0].substring(offset);
191
+    }
192
+
193
+}

+ 9
- 5
src/com/dmdirc/commandparser/CommandInfo.java View File

@@ -27,30 +27,34 @@ package com.dmdirc.commandparser;
27 27
  * 
28 28
  * @author chris
29 29
  */
30
-public abstract class CommandInfo {
30
+public interface CommandInfo {
31 31
           
32 32
     /**
33 33
      * Returns this command's name.
34
+     *
34 35
      * @return The name of this command
35 36
      */
36
-    public abstract String getName();
37
+    String getName();
37 38
     
38 39
     /**
39 40
      * Returns whether or not this command should be shown in help messages.
41
+     *
40 42
      * @return True iff the command should be shown, false otherwise
41 43
      */
42
-    public abstract boolean showInHelp();
44
+    boolean showInHelp();
43 45
     
44 46
     /**
45 47
      * Returns a string representing the help message for this command.
48
+     *
46 49
      * @return the help message for this command
47 50
      */
48
-    public abstract String getHelp();
51
+    String getHelp();
49 52
     
50 53
     /**
51 54
      * Retrieves the type of this command.
55
+     *
52 56
      * @return This command's type
53 57
      */
54
-    public abstract CommandType getType();
58
+    CommandType getType();
55 59
 
56 60
 }

+ 82
- 121
src/com/dmdirc/commandparser/CommandManager.java View File

@@ -25,12 +25,7 @@ package com.dmdirc.commandparser;
25 25
 import com.dmdirc.Query;
26 26
 import com.dmdirc.Server;
27 27
 import com.dmdirc.ServerManager;
28
-import com.dmdirc.commandparser.commands.ChannelCommand;
29
-import com.dmdirc.commandparser.commands.ChatCommand;
30 28
 import com.dmdirc.commandparser.commands.Command;
31
-import com.dmdirc.commandparser.commands.GlobalCommand;
32
-import com.dmdirc.commandparser.commands.QueryCommand;
33
-import com.dmdirc.commandparser.commands.ServerCommand;
34 29
 import com.dmdirc.commandparser.commands.channel.*;
35 30
 import com.dmdirc.commandparser.commands.chat.*;
36 31
 import com.dmdirc.commandparser.commands.global.*;
@@ -39,8 +34,6 @@ import com.dmdirc.commandparser.commands.server.*;
39 34
 import com.dmdirc.commandparser.parsers.CommandParser;
40 35
 import com.dmdirc.interfaces.ConfigChangeListener;
41 36
 import com.dmdirc.config.IdentityManager;
42
-import com.dmdirc.logger.ErrorLevel;
43
-import com.dmdirc.logger.Logger;
44 37
 import com.dmdirc.ui.input.TabCompleter;
45 38
 import com.dmdirc.ui.input.TabCompletionType;
46 39
 import com.dmdirc.util.MapList;
@@ -78,7 +71,7 @@ public final class CommandManager {
78 71
      * Prevents creation of a new command manager.
79 72
      */
80 73
     private CommandManager() {
81
-        //do nothing
74
+        // Do nothing
82 75
     }
83 76
     
84 77
     /**
@@ -103,76 +96,75 @@ public final class CommandManager {
103 96
      * Registers a command with the command manager.
104 97
      * 
105 98
      * @param command The command to be registered
99
+     * @param info The information about the command
100
+     * @since 0.6.3
106 101
      */
107
-    public static void registerCommand(final Command command) {
108
-        registerCommand(command, true);
102
+    public static void registerCommand(final Command command, final CommandInfo info) {
103
+        registerCommand(info, command, true);
104
+    }
105
+
106
+    /**
107
+     * Registers a {@link Command} which also implements the {@link CommandInfo}
108
+     * interface with the command manager.
109
+     *
110
+     * @param <T> The type of object that's being registered
111
+     * @param command An object that extends {@link Command} and implements
112
+     * {@link CommandInfo} to be registered.
113
+     * @since 0.6.3
114
+     */
115
+    public static <T extends Command & CommandInfo> void registerCommand(final T command) {
116
+        registerCommand(command, command);
109 117
     }
110 118
     
111 119
     /**
112 120
      * Unregisters a command with the command manager.
113 121
      * 
114
-     * @param command The command to be unregistered
122
+     * @param info The information object for the command that should be unregistered
123
+     * @since 0.6.3
115 124
      */
116
-    public static void unregisterCommand(final Command command) {
117
-        registerCommand(command, false);
125
+    public static void unregisterCommand(final CommandInfo info) {
126
+        registerCommand(info, commands.get(info), false);
118 127
     }
119 128
     
120 129
     /**
121 130
      * Registers or unregisters a command.
122 131
      *
132
+     * @param info The information about the command
123 133
      * @param command The command to be (un)registered
124 134
      * @param register True if the command should be registered, false if it
125 135
      * should be unregistered.
136
+     * @since 0.6.3
126 137
      */
127
-    private static void registerCommand(final Command command, final boolean register) {
128
-        boolean canContinue = true;
129
-        
130
-        if (command instanceof ChannelCommand) {
131
-            registerCommand(command, parsers.get(CommandType.TYPE_CHANNEL), register);
132
-        } else if (command instanceof ServerCommand) {
133
-            registerCommand(command, parsers.get(CommandType.TYPE_SERVER), register);
134
-        } else if (command instanceof QueryCommand) {
135
-            registerCommand(command, parsers.get(CommandType.TYPE_QUERY), register);
136
-        } else if (command instanceof GlobalCommand) {
137
-            registerCommand(command, parsers.get(CommandType.TYPE_GLOBAL), register);
138
-        } else if (command instanceof ChatCommand) {
139
-            registerCommand(command, parsers.get(CommandType.TYPE_QUERY), register);
140
-            registerCommand(command, parsers.get(CommandType.TYPE_CHANNEL), register);
141
-        } else {
142
-            canContinue = false;
143
-            
144
-            Logger.userError(ErrorLevel.HIGH, "Attempted to (un)register an invalid command: "
145
-                    + command.getClass().getName());
138
+    private static void registerCommand(final CommandInfo info, final Command command,
139
+            final boolean register) {
140
+        if (parsers.containsKey(info.getType())) {
141
+            registerCommand(info, command, parsers.get(info.getType()), register);
146 142
         }
147 143
         
148
-        if (canContinue) {
149
-            if (register) {
150
-                commands.put(command, command);
151
-            } else {
152
-                commands.remove(command);
153
-            }
154
-            
155
-            registerCommandName(command, register);
144
+        if (register) {
145
+            commands.put(info, command);
146
+        } else {
147
+            commands.remove(info);
156 148
         }
149
+
150
+        registerCommandName(info, register);
157 151
     }
158 152
     
159 153
     /**
160 154
      * Registers the specified command with all of the specified parsers.
161 155
      *
156
+     * @param info The command information object
162 157
      * @param command The command to be reigstered
163 158
      * @param parsers The parsers to register the command with
159
+     * @since 0.6.3
164 160
      */
165
-    private static void registerCommand(final Command command,
166
-            final List<? extends CommandParser> parsers, final boolean register) {
167
-        if (parsers == null) {
168
-            return;
169
-        }
170
-        
171
-        for (CommandParser parser : parsers) {
161
+    private static void registerCommand(final CommandInfo info, final Command command,
162
+            final List<? extends CommandParser> myParsers, final boolean register) {
163
+        for (CommandParser parser : myParsers) {
172 164
             if (register) {
173
-                parser.registerCommand(command);
165
+                parser.registerCommand(command, info);
174 166
             } else {
175
-                parser.unregisterCommand(command);
167
+                parser.unregisterCommand(info);
176 168
             }
177 169
         }
178 170
     }
@@ -184,25 +176,30 @@ public final class CommandManager {
184 176
      * @param command The command to be registered
185 177
      * @param register True if the command should be registered, false if it
186 178
      * should be unregistered.
179
+     * @since 0.6.3
187 180
      */
188
-    private static void registerCommandName(final Command command,
181
+    private static void registerCommandName(final CommandInfo command,
189 182
             final boolean register) {
190 183
         // Do tab completion
191 184
         final String commandName = getCommandChar() + command.getName();
192
-        
185
+
186
+        // TODO: This logic is probably in two places. Abstract it.
193 187
         for (Server server : ServerManager.getServerManager().getServers()) {
194
-            if (command instanceof ServerCommand || command instanceof GlobalCommand) {
188
+            if (command.getType() == CommandType.TYPE_SERVER ||
189
+                    command.getType() == CommandType.TYPE_GLOBAL) {
195 190
                 registerCommandName(server.getTabCompleter(), commandName, register);
196 191
             }
197 192
             
198
-            if (command instanceof ChannelCommand || command instanceof ChatCommand) {
193
+            if (command.getType() == CommandType.TYPE_CHANNEL
194
+                    || command.getType() == CommandType.TYPE_CHAT) {
199 195
                 for (String channelName : server.getChannels()) {
200 196
                     registerCommandName(server.getChannel(channelName).getTabCompleter(),
201 197
                             commandName, register);
202 198
                 }
203 199
             }
204 200
             
205
-            if (command instanceof QueryCommand || command instanceof ChatCommand) {
201
+            if (command.getType() == CommandType.TYPE_QUERY
202
+                    || command.getType() == CommandType.TYPE_CHAT) {
206 203
                 for (Query query : server.getQueries()) {
207 204
                     registerCommandName(query.getTabCompleter(),
208 205
                             commandName, register);
@@ -309,65 +306,26 @@ public final class CommandManager {
309 306
         IdentityManager.getGlobalConfig().addChangeListener("general", "commandchar", listener);
310 307
         IdentityManager.getGlobalConfig().addChangeListener("general", "silencechar", listener);
311 308
     }
312
-    
313
-    /**
314
-     * Loads all channel commands into the specified parser.
315
-     * 
316
-     * @param parser The parser to load commands into
317
-     */
318
-    public static void loadChannelCommands(final CommandParser parser) {
319
-        for (Command com : getCommands(CommandType.TYPE_CHANNEL, null)) {
320
-            parser.registerCommand(com);
321
-        }
322
-        
323
-        for (Command com : getCommands(CommandType.TYPE_CHAT, null)) {
324
-            parser.registerCommand(com);
325
-        }
326
-        
327
-        parsers.add(CommandType.TYPE_CHANNEL, parser);
328
-    }
329
-    
330
-    /**
331
-     * Loads all server commands into the specified parser.
332
-     * 
333
-     * @param parser The parser to load commands into
334
-     */
335
-    public static void loadServerCommands(final CommandParser parser) {
336
-        for (Command command : getCommands(CommandType.TYPE_SERVER, null)) {
337
-            parser.registerCommand(command);
338
-        }
339
-        
340
-        parsers.add(CommandType.TYPE_SERVER, parser);
341
-    }
342
-    
343
-    /**
344
-     * Loads all global commands into the specified parser.
345
-     * 
346
-     * @param parser The parser to load commands into
347
-     */
348
-    public static void loadGlobalCommands(final CommandParser parser) {
349
-        for (Command com : getCommands(CommandType.TYPE_GLOBAL, null)) {
350
-            parser.registerCommand(com);
351
-        }
352
-        
353
-        parsers.add(CommandType.TYPE_GLOBAL, parser);
354
-    }
355
-    
309
+
356 310
     /**
357
-     * Loads all query commands into the specified parser.
358
-     * 
359
-     * @param parser The parser to load commands into
311
+     * Loads all commands of the specified types into the specified parser.
312
+     *
313
+     * @see CommandType#getComponentTypes()
314
+     * @since 0.6.3
315
+     * @param parser The {@link CommandParser} to load commands in to
316
+     * @param supertypes The types of commands that should be loaded
360 317
      */
361
-    public static void loadQueryCommands(final CommandParser parser) {
362
-        for (Command com : getCommands(CommandType.TYPE_QUERY, null)) {
363
-            parser.registerCommand(com);
364
-        }
365
-        
366
-        for (Command com : getCommands(CommandType.TYPE_CHAT, null)) {
367
-            parser.registerCommand(com);
318
+    public static void loadCommands(final CommandParser parser,
319
+            final CommandType ... supertypes) {
320
+        for (CommandType supertype : supertypes) {
321
+            for (CommandType type : supertype.getComponentTypes()) {
322
+                for (Map.Entry<CommandInfo, Command> pair : getCommands(type, null).entrySet()) {
323
+                    parser.registerCommand(pair.getValue(), pair.getKey());
324
+                }
325
+
326
+                parsers.add(type, parser);
327
+            }
368 328
         }
369
-        
370
-        parsers.add(CommandType.TYPE_QUERY, parser);
371 329
     }
372 330
     
373 331
     /**
@@ -389,9 +347,9 @@ public final class CommandManager {
389 347
      * @return A command with a matching signature, or null if none were found
390 348
      */
391 349
     public static Command getCommand(final CommandType type, final String name) {
392
-        final List<Command> res = getCommands(type, name);
350
+        final Map<CommandInfo, Command> res = getCommands(type, name);
393 351
         
394
-        return res.isEmpty() ? null : res.get(0);
352
+        return res.isEmpty() ? null : res.values().iterator().next();
395 353
     }    
396 354
      
397 355
     /**
@@ -414,7 +372,7 @@ public final class CommandManager {
414 372
     public static List<String> getCommandNames(final CommandType type) {
415 373
         final List<String> res = new ArrayList<String>();
416 374
         
417
-        for (Command command : getCommands(type)) {
375
+        for (CommandInfo command : getCommands(type).keySet()) {
418 376
             res.add(getCommandChar() + command.getName());
419 377
         }
420 378
         
@@ -422,31 +380,34 @@ public final class CommandManager {
422 380
     }
423 381
     
424 382
     /**
425
-     * Retrieves a list of all commands of the specified type.
383
+     * Retrieves a map of all {@link CommandInfo}s and their associated
384
+     * {@link Command}s of the specified type.
426 385
      * 
427 386
      * @param type The type of command to list
428
-     * @return A list of commands
387
+     * @return A map of commands
388
+     * @since 0.6.3
429 389
      */    
430
-    public static List<Command> getCommands(final CommandType type) {    
390
+    public static Map<CommandInfo, Command> getCommands(final CommandType type) {
431 391
         return getCommands(type, null);
432 392
     }
433 393
     
434 394
     /**
435
-     * Retrieves a list of all commands of the specified type, with the
395
+     * Retrieves a map of all commands of the specified type, with the
436 396
      * specified name.
437 397
      * 
438 398
      * @param type The type of command to list, or null for all types
439 399
      * @param name The name of the command to look for, or null for any name
440
-     * @return A list of matching commands
400
+     * @return A map of {@link CommandInfo}s and their associated {@link Command}.
401
+     * @since 0.6.3
441 402
      */    
442
-    private static List<Command> getCommands(final CommandType type,
403
+    private static Map<CommandInfo, Command> getCommands(final CommandType type,
443 404
             final String name) {
444
-        final List<Command> res = new ArrayList<Command>();
405
+        final Map<CommandInfo, Command> res = new HashMap<CommandInfo, Command>();
445 406
         
446 407
         for (Map.Entry<CommandInfo, Command> entry : commands.entrySet()) {
447 408
             if ((type == null || type.equals(entry.getKey().getType()))
448 409
                     && (name == null || name.equals(entry.getKey().getName()))) {
449
-                res.add(entry.getValue());
410
+                res.put(entry.getKey(), entry.getValue());
450 411
             }
451 412
         }
452 413
         

+ 18
- 0
src/com/dmdirc/commandparser/CommandType.java View File

@@ -70,6 +70,24 @@ public enum CommandType {
70 70
         }
71 71
     }
72 72
 
73
+    /**
74
+     * Retrieves an array of component types that make up this command type.
75
+     * Generally this will only contain the type itself, but some commands may
76
+     * be registered in multiple queues (such as CHANNEL commands going into
77
+     * both CHAT and CHANNEL queues). Note that for obvious reasons there is
78
+     * no recursion done on the values returned here.
79
+     *
80
+     * @since 0.6.3
81
+     * @return An array of types which this type should be registered as.
82
+     */
83
+    public CommandType[] getComponentTypes() {
84
+        if (this == TYPE_CHANNEL || this == TYPE_QUERY) {
85
+            return new CommandType[]{this, TYPE_CHAT};
86
+        } else {
87
+            return new CommandType[]{this};
88
+        }
89
+    }
90
+
73 91
     /** {@inheritDoc} */
74 92
     @Override
75 93
     public String toString() {

+ 14
- 2
src/com/dmdirc/commandparser/commands/ChannelCommand.java View File

@@ -24,22 +24,34 @@ package com.dmdirc.commandparser.commands;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
29
+import com.dmdirc.commandparser.CommandType;
27 30
 import com.dmdirc.ui.interfaces.InputWindow;
28 31
 
29 32
 /**
30 33
  * Represents a command which can be performed only in the context of a channel.
31 34
  * @author chris
32 35
  */
33
-public abstract class ChannelCommand extends Command {
36
+public abstract class ChannelCommand extends Command implements CommandInfo {
34 37
     
35 38
     /**
36 39
      * Executes this command.
40
+     *
37 41
      * @param origin The window in which the command was typed
38 42
      * @param server The server instance that this command is being executed on
39 43
      * @param channel The channel instance that this command is being executed on
40 44
      * @param isSilent Whether this command is silenced or not
41 45
      * @param args Arguments passed to this command
46
+     * @since 0.6.3
42 47
      */
43 48
     public abstract void execute(InputWindow origin, Server server, Channel channel,
44
-            boolean isSilent, String... args);
49
+            boolean isSilent, CommandArguments args);
50
+
51
+    /** {@inheritDoc} */
52
+    @Override
53
+    public CommandType getType() {
54
+        return CommandType.TYPE_CHANNEL;
55
+    }
56
+    
45 57
 }

+ 12
- 2
src/com/dmdirc/commandparser/commands/ChatCommand.java View File

@@ -24,6 +24,9 @@ package com.dmdirc.commandparser.commands;
24 24
 
25 25
 import com.dmdirc.MessageTarget;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
29
+import com.dmdirc.commandparser.CommandType;
27 30
 import com.dmdirc.ui.interfaces.InputWindow;
28 31
 
29 32
 /**
@@ -32,7 +35,7 @@ import com.dmdirc.ui.interfaces.InputWindow;
32 35
  *
33 36
  * @author Chris
34 37
  */
35
-public abstract class ChatCommand extends Command {
38
+public abstract class ChatCommand extends Command implements CommandInfo {
36 39
     
37 40
     /**
38 41
      * Executes this command.
@@ -42,7 +45,14 @@ public abstract class ChatCommand extends Command {
42 45
      * @param target The target of this command
43 46
      * @param isSilent Whether this command is silenced or not
44 47
      * @param args Arguments passed to this command
48
+     * @since 0.6.3
45 49
      */
46 50
     public abstract void execute(InputWindow origin, Server server, MessageTarget target,
47
-            boolean isSilent, String... args);
51
+            boolean isSilent, CommandArguments args);
52
+
53
+    /** {@inheritDoc} */
54
+    @Override
55
+    public CommandType getType() {
56
+        return CommandType.TYPE_CHAT;
57
+    }
48 58
 }

+ 8
- 17
src/com/dmdirc/commandparser/commands/Command.java View File

@@ -22,17 +22,16 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25
-import com.dmdirc.commandparser.CommandInfo;
26 25
 import com.dmdirc.commandparser.CommandManager;
27
-import com.dmdirc.commandparser.CommandType;
28 26
 import com.dmdirc.ui.interfaces.InputWindow;
29 27
 import com.dmdirc.ui.messages.Styliser;
30 28
 
31 29
 /**
32 30
  * Represents a generic command.
31
+ *
33 32
  * @author chris
34 33
  */
35
-public abstract class Command extends CommandInfo implements Comparable<Command> {
34
+public abstract class Command {
36 35
     
37 36
     /** The format name used for command output. */
38 37
     protected static final String FORMAT_OUTPUT = "commandOutput";
@@ -45,8 +44,10 @@ public abstract class Command extends CommandInfo implements Comparable<Command>
45 44
      * @param offset The index to start at
46 45
      * @param args The arguments to implode
47 46
      * @return A string containing each argument seperated by a space
47
+     * @deprecated Should be no need for this now
48 48
      */
49
-    protected final String implodeArgs(final int offset, final String... args) {
49
+    @Deprecated
50
+    protected static final String implodeArgs(final int offset, final String... args) {
50 51
         String res = "";
51 52
         for (int i = offset; i < args.length; i++) {
52 53
             if (res.isEmpty()) {
@@ -62,8 +63,10 @@ public abstract class Command extends CommandInfo implements Comparable<Command>
62 63
      * Implodes the given list of arguments.
63 64
      * @param args The arguments to implode
64 65
      * @return A string containing each argument seperated by a space
66
+     * @deprecated Should be no need for this now
65 67
      */
66
-    protected final String implodeArgs(final String... args) {
68
+    @Deprecated
69
+    protected static final String implodeArgs(final String... args) {
67 70
         return implodeArgs(0, args);
68 71
     } 
69 72
     
@@ -148,18 +151,6 @@ public abstract class Command extends CommandInfo implements Comparable<Command>
148 151
         for (int i = 0; i < size - data.length(); i++) {
149 152
             builder.append(' ');
150 153
         }
151
-    }    
152
-    
153
-    /** {@inheritDoc} */
154
-    @Override
155
-    public final int compareTo(final Command o) {
156
-        return getName().compareTo(o.getName());
157
-    }
158
-
159
-    /** {@inheritDoc} */
160
-    @Override
161
-    public CommandType getType() {
162
-        return CommandType.fromCommand(this);
163 154
     }
164 155
 
165 156
 }

+ 3
- 1
src/com/dmdirc/commandparser/commands/ExternalCommand.java View File

@@ -22,6 +22,7 @@
22 22
 package com.dmdirc.commandparser.commands;
23 23
 
24 24
 import com.dmdirc.Server;
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.ui.interfaces.InputWindow;
26 27
 
27 28
 /**
@@ -40,8 +41,9 @@ public interface ExternalCommand {
40 41
      * @param channel The name of the channel the command is being executed for
41 42
      * @param isSilent Whether this command is silenced or not
42 43
      * @param args Arguments passed to this command
44
+     * @since 0.6.3
43 45
      */
44 46
     void execute(InputWindow origin, Server server, String channel,
45
-            boolean isSilent, String... args);    
47
+            boolean isSilent, CommandArguments args);
46 48
 
47 49
 }

+ 14
- 2
src/com/dmdirc/commandparser/commands/GlobalCommand.java View File

@@ -22,21 +22,33 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
26
+import com.dmdirc.commandparser.CommandInfo;
27
+import com.dmdirc.commandparser.CommandType;
25 28
 import com.dmdirc.ui.interfaces.InputWindow;
26 29
 
27 30
 /**
28 31
  * Represents a generic global command. Global commands are associated with
29 32
  * no servers.
33
+ *
30 34
  * @author chris
31 35
  */
32
-public abstract class GlobalCommand extends Command {
36
+public abstract class GlobalCommand extends Command implements CommandInfo {
33 37
         
34 38
     /**
35 39
      * Executes this command. Note that for global commands, origin may be
36 40
      * null.
41
+     *
37 42
      * @param origin The window in which the command was typed
38 43
      * @param isSilent Whether this command is silenced or not
39 44
      * @param args Arguments passed to this command
45
+     * @since 0.6.3
40 46
      */
41
-    public abstract void execute(InputWindow origin, boolean isSilent, String ... args);
47
+    public abstract void execute(InputWindow origin, boolean isSilent, CommandArguments args);
48
+
49
+    /** {@inheritDoc} */
50
+    @Override
51
+    public CommandType getType() {
52
+        return CommandType.TYPE_GLOBAL;
53
+    }
42 54
 }

+ 14
- 2
src/com/dmdirc/commandparser/commands/QueryCommand.java View File

@@ -24,22 +24,34 @@ package com.dmdirc.commandparser.commands;
24 24
 
25 25
 import com.dmdirc.Query;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.commandparser.CommandInfo;
29
+import com.dmdirc.commandparser.CommandType;
27 30
 import com.dmdirc.ui.interfaces.InputWindow;
28 31
 
29 32
 /**
30 33
  * Represents a command which can be performed only in the context of a query.
34
+ *
31 35
  * @author chris
32 36
  */
33
-public abstract class QueryCommand extends Command {
37
+public abstract class QueryCommand extends Command implements CommandInfo {
34 38
         
35 39
     /**
36 40
      * Executes this command.
41
+     *
37 42
      * @param origin The window in which the command was typed
38 43
      * @param server The server instance that this command is being executed on
39 44
      * @param query The query object that the commadparser is associated with
40 45
      * @param isSilent Whether this command is silenced or not
41 46
      * @param args Arguments passed to this command
47
+     * @since 0.6.3
42 48
      */
43 49
     public abstract void execute(InputWindow origin, Server server, Query query,
44
-            boolean isSilent, String... args);
50
+            boolean isSilent, CommandArguments args);
51
+
52
+    /** {@inheritDoc} */
53
+    @Override
54
+    public CommandType getType() {
55
+        return CommandType.TYPE_QUERY;
56
+    }
45 57
 }

+ 14
- 2
src/com/dmdirc/commandparser/commands/ServerCommand.java View File

@@ -23,22 +23,34 @@
23 23
 package com.dmdirc.commandparser.commands;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
27
+import com.dmdirc.commandparser.CommandInfo;
28
+import com.dmdirc.commandparser.CommandType;
26 29
 import com.dmdirc.ui.interfaces.InputWindow;
27 30
 
28 31
 /**
29 32
  * Represents a generic server command. Server commands are associated with
30 33
  * a server instance.
34
+ *
31 35
  * @author chris
32 36
  */
33
-public abstract class ServerCommand extends Command {
37
+public abstract class ServerCommand extends Command implements CommandInfo {
34 38
     
35 39
     /**
36 40
      * Executes this command.
41
+     *
37 42
      * @param origin The window in which the command was typed
38 43
      * @param server The server instance that this command is being executed on
39 44
      * @param isSilent Whether this command is silenced or not
40 45
      * @param args Arguments passed to this command
46
+     * @since 0.6.3
41 47
      */
42 48
     public abstract void execute(InputWindow origin, Server server,
43
-            boolean isSilent, String ... args);
49
+            boolean isSilent, CommandArguments args);
50
+
51
+    /** {@inheritDoc} */
52
+    @Override
53
+    public CommandType getType() {
54
+        return CommandType.TYPE_SERVER;
55
+    }
44 56
 }

+ 6
- 5
src/com/dmdirc/commandparser/commands/channel/Ban.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChannelCommand;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -51,14 +52,14 @@ public final class Ban extends ChannelCommand implements IntelligentCommand {
51 52
     /** {@inheritDoc} */
52 53
     @Override
53 54
     public void execute(final InputWindow origin, final Server server,
54
-            final Channel channel, final boolean isSilent, final String... args) {
55
-        if (args.length == 0) {
55
+            final Channel channel, final boolean isSilent, final CommandArguments args) {
56
+        if (args.getArguments().length == 0) {
56 57
             showUsage(origin, isSilent, "ban", "<user|host>");
57 58
             return;
58 59
         }
59 60
         
60
-        String host = args[0];
61
-        final ChannelClientInfo user = channel.getChannelInfo().getUser(args[0]);
61
+        String host = args.getArguments()[0];
62
+        final ChannelClientInfo user = channel.getChannelInfo().getUser(host);
62 63
         if (user != null && !user.getClient().getHost().isEmpty()) {
63 64
             // TODO: Customisable ban masks, somehow.
64 65
             host = "*!*@" + user.getClient().getHost();
@@ -95,6 +96,6 @@ public final class Ban extends ChannelCommand implements IntelligentCommand {
95 96
         }
96 97
         
97 98
         return res;
98
-    } 
99
+    }
99 100
     
100 101
 }

+ 2
- 1
src/com/dmdirc/commandparser/commands/channel/ChannelSettings.java View File

@@ -25,6 +25,7 @@ package com.dmdirc.commandparser.commands.channel;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Main;
27 27
 import com.dmdirc.Server;
28
+import com.dmdirc.commandparser.CommandArguments;
28 29
 import com.dmdirc.commandparser.commands.ChannelCommand;
29 30
 import com.dmdirc.commandparser.CommandManager;
30 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -49,7 +50,7 @@ public final class ChannelSettings extends ChannelCommand implements Intelligent
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final Server server,
52
-            final Channel channel, final boolean isSilent, final String... args) {
53
+            final Channel channel, final boolean isSilent, final CommandArguments args) {
53 54
         Main.getUI().showChannelSettingsDialog(channel);
54 55
     }
55 56
     

+ 3
- 2
src/com/dmdirc/commandparser/commands/channel/Cycle.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChannelCommand;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -45,8 +46,8 @@ public final class Cycle extends ChannelCommand {
45 46
     /** {@inheritDoc} */
46 47
     @Override
47 48
     public void execute(final InputWindow origin, final Server server,
48
-            final Channel channel, final boolean isSilent, final String... args) {
49
-        channel.part(args.length > 0 ? implodeArgs(args)
49
+            final Channel channel, final boolean isSilent, final CommandArguments args) {
50
+        channel.part(args.getArguments().length > 0 ? args.getArgumentsAsString()
50 51
                 : origin.getConfigManager().getOption("general", "cyclemessage"));
51 52
         channel.join();
52 53
     }

+ 8
- 5
src/com/dmdirc/commandparser/commands/channel/KickReason.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChannelCommand;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -51,18 +52,20 @@ public final class KickReason extends ChannelCommand implements IntelligentComma
51 52
     /** {@inheritDoc} */
52 53
     @Override
53 54
     public void execute(final InputWindow origin, final Server server,
54
-            final Channel channel, final boolean isSilent, final String... args) {
55
-        if (args.length == 0) {
55
+            final Channel channel, final boolean isSilent, final CommandArguments args) {
56
+        if (args.getArguments().length == 0) {
56 57
             showUsage(origin, isSilent, "kick", "<user> [reason]");
57 58
             return;
58 59
         }
59 60
         
60
-        final ChannelClientInfo victim = channel.getChannelInfo().getUser(args[0]);
61
+        final ChannelClientInfo victim = channel.getChannelInfo().getUser(args
62
+                .getArguments()[0]);
61 63
         
62 64
         if (victim == null) {
63
-            sendLine(origin, isSilent, FORMAT_ERROR, "User not found: " + args[0]);
65
+            sendLine(origin, isSilent, FORMAT_ERROR, "User not found: "
66
+                    + args.getArguments()[0]);
64 67
         } else {
65
-            victim.kick(args.length > 1 ? implodeArgs(1, args) :
68
+            victim.kick(args.getArguments().length > 1 ? args.getArgumentsAsString(1) :
66 69
                 origin.getConfigManager().getOption("general", "kickmessage"));
67 70
         }
68 71
     }

+ 7
- 6
src/com/dmdirc/commandparser/commands/channel/Mode.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChannelCommand;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.commands.ExternalCommand;
@@ -52,24 +53,24 @@ public final class Mode extends ChannelCommand implements IntelligentCommand,
52 53
     /** {@inheritDoc} */
53 54
     @Override
54 55
     public void execute(final InputWindow origin, final Server server,
55
-            final Channel channel, final boolean isSilent, final String... args) {
56
+            final Channel channel, final boolean isSilent, final CommandArguments args) {
56 57
         final ChannelInfo cChannel = channel.getChannelInfo();
57 58
 
58
-        if (args.length == 0) {
59
+        if (args.getArguments().length == 0) {
59 60
             sendLine(origin, isSilent, "channelModeDiscovered", cChannel.getModeStr(), cChannel);
60 61
         } else {
61
-            server.getParser().sendLine("MODE " + cChannel + " " + implodeArgs(args));
62
+            server.getParser().sendLine("MODE " + cChannel + " " + args.getArgumentsAsString());
62 63
         }
63 64
     }
64 65
 
65 66
     /** {@inheritDoc} */
66 67
     @Override
67 68
     public void execute(final InputWindow origin, final Server server,
68
-            final String channel, final boolean isSilent, final String ... args) {
69
-        if (args.length == 0) {
69
+            final String channel, final boolean isSilent, final CommandArguments args) {
70
+        if (args.getArguments().length == 0) {
70 71
             server.getParser().sendLine("MODE " + channel);
71 72
         } else {
72
-            server.getParser().sendLine("MODE " + channel + " " + implodeArgs(args));
73
+            server.getParser().sendLine("MODE " + channel + " " + args.getArgumentsAsString());
73 74
         }
74 75
     }
75 76
 

+ 3
- 2
src/com/dmdirc/commandparser/commands/channel/Names.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.ChannelCommand;
29 30
 import com.dmdirc.commandparser.commands.ExternalCommand;
@@ -52,7 +53,7 @@ public class Names extends ChannelCommand implements IntelligentCommand, Externa
52 53
     /** {@inheritDoc} */
53 54
     @Override
54 55
     public void execute(final InputWindow origin, final Server server, 
55
-            final Channel channel, final boolean isSilent, final String... args) {
56
+            final Channel channel, final boolean isSilent, final CommandArguments args) {
56 57
         server.getParser().sendLine("NAMES " + channel.getChannelInfo().getName());
57 58
     }
58 59
     
@@ -60,7 +61,7 @@ public class Names extends ChannelCommand implements IntelligentCommand, Externa
60 61
     /** {@inheritDoc} */
61 62
     @Override
62 63
     public void execute(final InputWindow origin, final Server server,
63
-            final String channel, final boolean isSilent, final String ... args) {
64
+            final String channel, final boolean isSilent, final CommandArguments args) {
64 65
         server.getParser().sendLine("NAMES " + channel);
65 66
     }    
66 67
 

+ 3
- 2
src/com/dmdirc/commandparser/commands/channel/Part.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChannelCommand;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -44,8 +45,8 @@ public final class Part extends ChannelCommand {
44 45
     /** {@inheritDoc} */
45 46
     @Override
46 47
     public void execute(final InputWindow origin, final Server server,
47
-            final Channel channel, final boolean isSilent, final String... args) {
48
-        channel.part(args.length > 0 ? implodeArgs(args)
48
+            final Channel channel, final boolean isSilent, final CommandArguments args) {
49
+        channel.part(args.getArguments().length > 0 ? args.getArgumentsAsString()
49 50
                 : origin.getConfigManager().getOption("general", "partmessage"));
50 51
         channel.close();
51 52
     }

+ 9
- 8
src/com/dmdirc/commandparser/commands/channel/SetNickColour.java View File

@@ -25,6 +25,7 @@ package com.dmdirc.commandparser.commands.channel;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.ChannelClientProperty;
27 27
 import com.dmdirc.Server;
28
+import com.dmdirc.commandparser.CommandArguments;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.commands.ChannelCommand;
30 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -54,31 +55,31 @@ public final class SetNickColour extends ChannelCommand implements IntelligentCo
54 55
     /** {@inheritDoc} */
55 56
     @SuppressWarnings("unchecked") @Override
56 57
     public void execute(final InputWindow origin, final Server server,
57
-            final Channel channel, final boolean isSilent, final String... args) {
58
+            final Channel channel, final boolean isSilent, final CommandArguments args) {
58 59
         
59 60
         int offset = 0;
60 61
         boolean nicklist = true;
61 62
         boolean text = true;
62 63
         
63
-        if (args.length > offset && args[offset].equalsIgnoreCase("--nicklist")) {
64
+        if (args.getArguments().length > offset && args.getArguments()[offset].equalsIgnoreCase("--nicklist")) {
64 65
             text = false;
65 66
             offset++;
66
-        } else if (args.length > offset && args[offset].equalsIgnoreCase("--text")) {
67
+        } else if (args.getArguments().length > offset && args.getArguments()[offset].equalsIgnoreCase("--text")) {
67 68
             nicklist = false;
68 69
             offset++;
69 70
         }
70 71
         
71
-        if (args.length <= offset) {
72
+        if (args.getArguments().length <= offset) {
72 73
             showUsage(origin, isSilent, "setnickcolour", "[--nicklist|--text] <nick> [colour]");
73 74
             return;
74 75
         }
75 76
         
76
-        final ChannelClientInfo target = channel.getChannelInfo().getUser(args[offset]);
77
+        final ChannelClientInfo target = channel.getChannelInfo().getUser(args.getArguments()[offset]);
77 78
         offset++;
78 79
         
79 80
         if (target == null) {
80
-            sendLine(origin, isSilent, FORMAT_ERROR, "No such nickname (" + args[offset - 1] + ")!");
81
-        } else if (args.length <= offset) {
81
+            sendLine(origin, isSilent, FORMAT_ERROR, "No such nickname (" + args.getArguments()[offset - 1] + ")!");
82
+        } else if (args.getArguments().length <= offset) {
82 83
             // We're removing the colour
83 84
             if (nicklist) {
84 85
                 target.getMap().remove(ChannelClientProperty.NICKLIST_FOREGROUND);
@@ -89,7 +90,7 @@ public final class SetNickColour extends ChannelCommand implements IntelligentCo
89 90
             ((ChannelWindow) channel.getFrame()).redrawNicklist();
90 91
         } else {
91 92
             // We're setting the colour
92
-            final Color newColour = ColourManager.parseColour(args[offset], null);
93
+            final Color newColour = ColourManager.parseColour(args.getArguments()[offset], null);
93 94
             if (newColour == null) {
94 95
                 sendLine(origin, isSilent, FORMAT_ERROR, "Invalid colour specified.");
95 96
                 return;

+ 7
- 6
src/com/dmdirc/commandparser/commands/channel/ShowTopic.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChannelCommand;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.commands.ExternalCommand;
@@ -47,8 +48,8 @@ public final class ShowTopic extends ChannelCommand implements ExternalCommand {
47 48
     /** {@inheritDoc} */
48 49
     @Override
49 50
     public void execute(final InputWindow origin, final Server server,
50
-            final Channel channel, final boolean isSilent, final String... args) {
51
-        if (args.length == 0) {
51
+            final Channel channel, final boolean isSilent, final CommandArguments args) {
52
+        if (args.getArguments().length == 0) {
52 53
             final ChannelInfo cChannel = channel.getChannelInfo();
53 54
 
54 55
             if (cChannel.getTopic().isEmpty()) {
@@ -61,18 +62,18 @@ public final class ShowTopic extends ChannelCommand implements ExternalCommand {
61 62
                         1000 * cChannel.getTopicTime(), cChannel);
62 63
             }
63 64
         } else {
64
-            channel.setTopic(implodeArgs(args));
65
+            channel.setTopic(args.getArgumentsAsString());
65 66
         }
66 67
     }
67 68
 
68 69
     /** {@inheritDoc} */
69 70
     @Override
70 71
     public void execute(final InputWindow origin, final Server server,
71
-            final String channel, final boolean isSilent, final String ... args) {
72
-        if (args.length == 0) {
72
+            final String channel, final boolean isSilent, final CommandArguments args) {
73
+        if (args.getArguments().length == 0) {
73 74
             server.getParser().sendLine("TOPIC " + channel);
74 75
         } else {
75
-            server.getParser().sendLine("TOPIC " + channel + " :" + implodeArgs(args));
76
+            server.getParser().sendLine("TOPIC " + channel + " :" + args.getArgumentsAsString());
76 77
         }
77 78
     }
78 79
 

+ 4
- 3
src/com/dmdirc/commandparser/commands/chat/Me.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.chat;
24 24
 
25 25
 import com.dmdirc.MessageTarget;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChatCommand;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.commands.ValidatingCommand;
@@ -48,11 +49,11 @@ public final class Me extends ChatCommand implements ValidatingCommand {
48 49
     /** {@inheritDoc} */
49 50
     @Override
50 51
     public void execute(final InputWindow origin, final Server server,
51
-            final MessageTarget target, final boolean isSilent, final String... args) {
52
-        if (args.length == 0) {
52
+            final MessageTarget target, final boolean isSilent, final CommandArguments args) {
53
+        if (args.getArguments().length == 0) {
53 54
             showUsage(origin, isSilent, "me", "<action>");
54 55
         } else {
55
-            target.sendAction(implodeArgs(args));
56
+            target.sendAction(args.getArgumentsAsString());
56 57
         }
57 58
     }
58 59
     

+ 3
- 2
src/com/dmdirc/commandparser/commands/global/Active.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Main;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -50,8 +51,8 @@ public final class Active extends GlobalCommand implements IntelligentCommand {
50 51
     /** {@inheritDoc} */
51 52
     @Override
52 53
     public void execute(final InputWindow origin, final boolean isSilent,
53
-            final String... args) {
54
-        final String command = implodeArgs(args);
54
+            final CommandArguments args) {
55
+        final String command = args.getArgumentsAsString();
55 56
         
56 57
         final InputWindow window = (InputWindow) Main.getUI().getActiveWindow();
57 58
         

+ 9
- 8
src/com/dmdirc/commandparser/commands/global/AliasCommand.java View File

@@ -26,6 +26,7 @@ import com.dmdirc.actions.Action;
26 26
 import com.dmdirc.actions.ActionManager;
27 27
 import com.dmdirc.actions.wrappers.Alias;
28 28
 import com.dmdirc.actions.wrappers.AliasWrapper;
29
+import com.dmdirc.commandparser.CommandArguments;
29 30
 import com.dmdirc.commandparser.CommandManager;
30 31
 import com.dmdirc.commandparser.commands.GlobalCommand;
31 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -55,15 +56,15 @@ public final class AliasCommand extends GlobalCommand implements
55 56
     /** {@inheritDoc} */
56 57
     @Override
57 58
     public void execute(final InputWindow origin, final boolean isSilent,
58
-                        final String... args) {
59
-        if (args.length < 2) {
59
+                        final CommandArguments args) {
60
+        if (args.getArguments().length < 2) {
60 61
             showUsage(origin, isSilent, "alias", "[--remove] <name> [command]");
61 62
             return;
62 63
         }
63 64
 
64
-        if (args[0].equalsIgnoreCase("--remove")) {
65
-            final String name = args[1].charAt(0) == CommandManager.getCommandChar()
66
-                ? args[1].substring(1) : args[1];
65
+        if (args.getArguments()[0].equalsIgnoreCase("--remove")) {
66
+            final String name = args.getArguments()[1].charAt(0) == CommandManager.getCommandChar()
67
+                ? args.getArguments()[1].substring(1) : args.getArguments()[1];
67 68
 
68 69
             if (doRemove(name)) {
69 70
                 sendLine(origin, isSilent, FORMAT_OUTPUT, "Alias '" + name +
@@ -76,8 +77,8 @@ public final class AliasCommand extends GlobalCommand implements
76 77
             return;
77 78
         }
78 79
 
79
-        final String name = args[0].charAt(0) == CommandManager.getCommandChar()
80
-                ? args[0].substring(0) : args[1];
80
+        final String name = args.getArguments()[0].charAt(0) == CommandManager.getCommandChar()
81
+                ? args.getArguments()[0].substring(0) : args.getArguments()[1];
81 82
 
82 83
         for (Action alias : AliasWrapper.getAliasWrapper()) {
83 84
             if (AliasWrapper.getCommandName(alias).substring(1).equalsIgnoreCase(
@@ -89,7 +90,7 @@ public final class AliasCommand extends GlobalCommand implements
89 90
         }
90 91
 
91 92
         final Alias myAlias = new Alias(name);
92
-        myAlias.setResponse(new String[]{implodeArgs(1, args)});
93
+        myAlias.setResponse(new String[]{args.getArgumentsAsString(1)});
93 94
         myAlias.createAction().save();
94 95
 
95 96
         sendLine(origin, isSilent, FORMAT_OUTPUT, "Alias '" + name +

+ 3
- 2
src/com/dmdirc/commandparser/commands/global/AllServers.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerManager;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.GlobalCommand;
29 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -49,8 +50,8 @@ public final class AllServers extends GlobalCommand implements IntelligentComman
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
53
-        final String command = implodeArgs(args);
53
+            final CommandArguments args) {
54
+        final String command = args.getArgumentsAsString();
54 55
         InputWindow window;
55 56
         
56 57
         for (Server target : ServerManager.getServerManager().getServers()) {

+ 2
- 1
src/com/dmdirc/commandparser/commands/global/Clear.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -49,7 +50,7 @@ public final class Clear extends GlobalCommand implements IntelligentCommand {
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final boolean isSilent, 
52
-            final String... args) {
53
+            final CommandArguments args) {
53 54
         origin.clear();
54 55
     }
55 56
     

+ 22
- 21
src/com/dmdirc/commandparser/commands/global/Debug.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.GlobalCommand;
29 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -64,42 +65,42 @@ public class Debug extends GlobalCommand implements IntelligentCommand {
64 65
     /** {@inheritDoc} */
65 66
     @Override
66 67
     public void execute(final InputWindow origin, final boolean isSilent,
67
-            final String ... args) {
68
-        if (args.length == 0) {
68
+            final CommandArguments args) {
69
+        if (args.getArguments().length == 0) {
69 70
             showUsage(origin, isSilent, "debug", "<debug command> [options]");
70
-        } else if ("error".equals(args[0])) {
71
-            doError(args);
72
-        } else if ("showraw".equals(args[0])) {
71
+        } else if ("error".equals(args.getArguments()[0])) {
72
+            doError(args.getArguments());
73
+        } else if ("showraw".equals(args.getArguments()[0])) {
73 74
             doShowRaw(origin, isSilent);
74
-        } else if ("configstats".equals(args[0])) {
75
+        } else if ("configstats".equals(args.getArguments()[0])) {
75 76
             doConfigStats(origin, isSilent);
76
-        } else if ("configinfo".equals(args[0])) {
77
+        } else if ("configinfo".equals(args.getArguments()[0])) {
77 78
             doConfigInfo(origin, isSilent);
78
-        } else if ("globalconfiginfo".equals(args[0])) {
79
+        } else if ("globalconfiginfo".equals(args.getArguments()[0])) {
79 80
             doGlobalConfigInfo(origin, isSilent);
80
-        } else if ("colourspam".equals(args[0])) {
81
+        } else if ("colourspam".equals(args.getArguments()[0])) {
81 82
             doColourSpam(origin, isSilent);
82
-        } else if ("meminfo".equals(args[0])) {
83
+        } else if ("meminfo".equals(args.getArguments()[0])) {
83 84
             doMemInfo(origin, isSilent);
84
-        } else if ("rungc".equals(args[0])) {
85
+        } else if ("rungc".equals(args.getArguments()[0])) {
85 86
             doGarbage(origin, isSilent);
86
-        } else if ("threads".equals(args[0])) {
87
+        } else if ("threads".equals(args.getArguments()[0])) {
87 88
             doThreads(origin, isSilent);
88
-        } else if ("forceupdate".equals(args[0])) {
89
+        } else if ("forceupdate".equals(args.getArguments()[0])) {
89 90
             doForceUpdate();
90
-        } else if ("serverinfo".equals(args[0])) {
91
+        } else if ("serverinfo".equals(args.getArguments()[0])) {
91 92
             doServerInfo(origin, isSilent);
92
-        } else if ("serverstate".equals(args[0])) {
93
+        } else if ("serverstate".equals(args.getArguments()[0])) {
93 94
             doServerState(origin, isSilent);
94
-        } else if ("benchmark".equals(args[0])) {
95
+        } else if ("benchmark".equals(args.getArguments()[0])) {
95 96
             doBenchmark(origin);
96
-        } else if ("services".equals(args[0])) {
97
-            doServices(origin, isSilent, args);
98
-        } else if ("firstrun".equals(args[0])) {
97
+        } else if ("services".equals(args.getArguments()[0])) {
98
+            doServices(origin, isSilent, args.getArguments());
99
+        } else if ("firstrun".equals(args.getArguments()[0])) {
99 100
             Main.getUI().showFirstRunWizard();
100
-        } else if ("migration".equals(args[0])) {
101
+        } else if ("migration".equals(args.getArguments()[0])) {
101 102
             Main.getUI().showMigrationWizard();
102
-        } else if ("notify".equals(args[0])) {
103
+        } else if ("notify".equals(args.getArguments()[0])) {
103 104
             sendLine(origin, isSilent, FORMAT_OUTPUT, "Current notification colour is: "
104 105
                     + origin.getContainer().getNotification());
105 106
         } else {

+ 11
- 9
src/com/dmdirc/commandparser/commands/global/Echo.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Main;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -52,35 +53,36 @@ public final class Echo extends GlobalCommand implements IntelligentCommand {
52 53
     /** {@inheritDoc} */
53 54
     @Override
54 55
     public void execute(final InputWindow origin, final boolean isSilent,
55
-            final String... args) {
56
-        if (args.length > 0 && args[0].equalsIgnoreCase("--active")) {
56
+            final CommandArguments args) {
57
+        if (args.getArguments().length > 0
58
+                && args.getArguments()[0].equalsIgnoreCase("--active")) {
57 59
             final Window frame = Main.getUI().getActiveWindow();
58 60
             if (frame instanceof InputWindow) {
59
-                ((InputWindow) frame).addLine(FORMAT_OUTPUT, implodeArgs(1,
60
-                        args));
61
+                ((InputWindow) frame).addLine(FORMAT_OUTPUT, args.getArgumentsAsString(1));
61 62
             }
62
-        } else if (args.length > 1 && args[0].equalsIgnoreCase("--target")) {
63
+        } else if (args.getArguments().length > 1
64
+                && args.getArguments()[0].equalsIgnoreCase("--target")) {
63 65
             Window frame = null;
64 66
             Window target = origin;
65 67
 
66 68
             while (frame == null && target != null) {
67
-                frame = WindowManager.findCustomWindow(target, args[1]);
69
+                frame = WindowManager.findCustomWindow(target, args.getArguments()[1]);
68 70
                 target = WindowManager.getParent(target);
69 71
             }
70 72
 
71 73
             if (frame == null) {
72
-                frame = WindowManager.findCustomWindow(args[1]);
74
+                frame = WindowManager.findCustomWindow(args.getArguments()[1]);
73 75
             }
74 76
 
75 77
             if (frame == null) {
76 78
                 sendLine(origin, isSilent, FORMAT_ERROR,
77 79
                         "Unable to find target window");
78 80
             } else {
79
-                frame.addLine(FORMAT_OUTPUT, implodeArgs(2, args));
81
+                frame.addLine(FORMAT_OUTPUT, args.getArgumentsAsString(2));
80 82
             }
81 83
 
82 84
         } else {
83
-            sendLine(origin, isSilent, FORMAT_OUTPUT, implodeArgs(args));
85
+            sendLine(origin, isSilent, FORMAT_OUTPUT, args.getArgumentsAsString());
84 86
         }
85 87
     }
86 88
 

+ 3
- 2
src/com/dmdirc/commandparser/commands/global/Exit.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Main;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -47,8 +48,8 @@ public final class Exit extends GlobalCommand {
47 48
     /** {@inheritDoc} */
48 49
     @Override
49 50
     public void execute(final InputWindow origin, final boolean isSilent,
50
-            final String... args) {                
51
-        Main.quit(args.length > 0 ? implodeArgs(args)
51
+            final CommandArguments args) {
52
+        Main.quit(args.getArguments().length > 0 ? args.getArgumentsAsString()
52 53
                 : origin.getConfigManager().getOption("general", "closemessage"));
53 54
     }
54 55
     

+ 21
- 20
src/com/dmdirc/commandparser/commands/global/Help.java View File

@@ -22,7 +22,8 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
-import com.dmdirc.commandparser.commands.Command;
25
+import com.dmdirc.commandparser.CommandArguments;
26
+import com.dmdirc.commandparser.CommandInfo;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.CommandType;
28 29
 import com.dmdirc.commandparser.commands.GlobalCommand;
@@ -33,10 +34,9 @@ import com.dmdirc.ui.interfaces.ChannelWindow;
33 34
 import com.dmdirc.ui.interfaces.InputWindow;
34 35
 import com.dmdirc.ui.interfaces.QueryWindow;
35 36
 import com.dmdirc.ui.interfaces.ServerWindow;
36
-
37 37
 import com.dmdirc.ui.messages.Styliser;
38
+
38 39
 import java.util.ArrayList;
39
-import java.util.Collections;
40 40
 import java.util.List;
41 41
 
42 42
 /**
@@ -59,11 +59,11 @@ public final class Help extends GlobalCommand implements IntelligentCommand {
59 59
     /** {@inheritDoc} */
60 60
     @Override
61 61
     public void execute(final InputWindow origin, final boolean isSilent,
62
-            final String... args) {
63
-        if (args.length == 0) {
62
+            final CommandArguments args) {
63
+        if (args.getArguments().length == 0) {
64 64
             showAllCommands(origin, isSilent);
65 65
         } else {
66
-            showCommand(origin, isSilent, args[0]);
66
+            showCommand(origin, isSilent, args.getArguments()[0]);
67 67
         }
68 68
     }
69 69
     
@@ -74,30 +74,30 @@ public final class Help extends GlobalCommand implements IntelligentCommand {
74 74
      * @param isSilent Whether this command has been silenced or not
75 75
      */
76 76
     private void showAllCommands(final InputWindow origin, final boolean isSilent) {
77
-        final List<Command> commands = new ArrayList<Command>();
77
+        final List<CommandInfo> commands = new ArrayList<CommandInfo>();
78 78
 
79
-        commands.addAll(CommandManager.getCommands(CommandType.TYPE_GLOBAL));
79
+        commands.addAll(CommandManager.getCommands(CommandType.TYPE_GLOBAL).keySet());
80 80
         
81 81
         if (origin instanceof ServerWindow) {
82
-            commands.addAll(CommandManager.getCommands(CommandType.TYPE_SERVER));
82
+            commands.addAll(CommandManager.getCommands(CommandType.TYPE_SERVER).keySet());
83 83
         } else if (origin instanceof ChannelWindow) {
84
-            commands.addAll(CommandManager.getCommands(CommandType.TYPE_CHANNEL));
85
-            commands.addAll(CommandManager.getCommands(CommandType.TYPE_CHAT));
86
-            commands.addAll(CommandManager.getCommands(CommandType.TYPE_SERVER));
84
+            commands.addAll(CommandManager.getCommands(CommandType.TYPE_CHANNEL).keySet());
85
+            commands.addAll(CommandManager.getCommands(CommandType.TYPE_CHAT).keySet());
86
+            commands.addAll(CommandManager.getCommands(CommandType.TYPE_SERVER).keySet());
87 87
         } else if (origin instanceof QueryWindow) {
88
-            commands.addAll(CommandManager.getCommands(CommandType.TYPE_QUERY));
89
-            commands.addAll(CommandManager.getCommands(CommandType.TYPE_CHAT));
90
-            commands.addAll(CommandManager.getCommands(CommandType.TYPE_SERVER));
88
+            commands.addAll(CommandManager.getCommands(CommandType.TYPE_QUERY).keySet());
89
+            commands.addAll(CommandManager.getCommands(CommandType.TYPE_CHAT).keySet());
90
+            commands.addAll(CommandManager.getCommands(CommandType.TYPE_SERVER).keySet());
91 91
         }
92 92
         
93
-        Collections.sort(commands);
93
+        //Collections.sort(commands);
94 94
         
95 95
         sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
96 96
                 + "----------------------- Available commands -------");
97 97
         
98 98
         final StringBuilder builder = new StringBuilder();
99 99
         
100
-        for (Command command : commands) {
100
+        for (CommandInfo command : commands) {
101 101
             if (builder.length() + command.getName().length() + 1 > 50) {
102 102
                 sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED + builder.toString());
103 103
                 builder.delete(0, builder.length());
@@ -125,13 +125,14 @@ public final class Help extends GlobalCommand implements IntelligentCommand {
125 125
      */
126 126
     private void showCommand(final InputWindow origin, final boolean isSilent,
127 127
             final String name) {
128
-        Command command;
129
-        
128
+        CommandInfo command = null;
129
+
130
+        /* TODO: Add methods to enable this to work and uncomment
130 131
         if (name.length() > 0 && name.charAt(0) == CommandManager.getCommandChar()) {
131 132
             command = CommandManager.getCommand(name.substring(1));
132 133
         } else {
133 134
             command = CommandManager.getCommand(name);
134
-        }
135
+        }*/
135 136
         
136 137
         if (command == null) {
137 138
             sendLine(origin, isSilent, FORMAT_ERROR, "Command '" + name + "' not found.");

+ 7
- 6
src/com/dmdirc/commandparser/commands/global/Ifplugin.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
@@ -54,15 +55,15 @@ public final class Ifplugin extends GlobalCommand implements IntelligentCommand
54 55
     /** {@inheritDoc} */
55 56
     @Override
56 57
     public void execute(final InputWindow origin, final boolean isSilent,
57
-            final String... args) {
58
-        if (args.length <= 1) {
58
+            final CommandArguments args) {
59
+        if (args.getArguments().length <= 1) {
59 60
             showUsage(origin, isSilent, "ifplugin", "<[!]plugin> <command>");
60 61
             return;
61 62
         }
62 63
         
63
-        final boolean negative = args[0].charAt(0) == '!';
64
+        final boolean negative = args.getArguments()[0].charAt(0) == '!';
64 65
         
65
-        final String pname = args[0].substring(negative ? 1 : 0);
66
+        final String pname = args.getArguments()[0].substring(negative ? 1 : 0);
66 67
         
67 68
         final PluginInfo pluginInfo = PluginManager.getPluginManager().getPluginInfoByName(pname);
68 69
         
@@ -75,9 +76,9 @@ public final class Ifplugin extends GlobalCommand implements IntelligentCommand
75 76
         if (result != negative) {
76 77
             if (origin == null) {
77 78
                 GlobalCommandParser.getGlobalCommandParser().parseCommand(null,
78
-                        implodeArgs(1, args));
79
+                        args.getArgumentsAsString(1));
79 80
             } else {
80
-                origin.getCommandParser().parseCommand(origin, implodeArgs(1, args));
81
+                origin.getCommandParser().parseCommand(origin, args.getArgumentsAsString(1));
81 82
             }
82 83
         }
83 84
     }

+ 6
- 4
src/com/dmdirc/commandparser/commands/global/LoadPlugin.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -50,15 +51,16 @@ public final class LoadPlugin extends GlobalCommand implements IntelligentComman
50 51
     /** {@inheritDoc} */
51 52
     @Override
52 53
     public void execute(final InputWindow origin, final boolean isSilent,
53
-            final String... args) {
54
-        if (args.length == 0) {
54
+            final CommandArguments args) {
55
+        if (args.getArguments().length == 0) {
55 56
             showUsage(origin, isSilent, "loadplugin", "<plugin>");
56 57
             return;
57 58
         }
58 59
 
59 60
         // Add previously unknown plugin to plugin manager
60
-        PluginManager.getPluginManager().addPlugin(args[0]);
61
-        final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfo(args[0]);
61
+        PluginManager.getPluginManager().addPlugin(args.getArguments()[0]);
62
+        final PluginInfo plugin = PluginManager.getPluginManager()
63
+                .getPluginInfo(args.getArguments()[0]);
62 64
         
63 65
         if (plugin == null) {
64 66
             sendLine(origin, isSilent, FORMAT_ERROR, "Plugin loading failed");

+ 9
- 8
src/com/dmdirc/commandparser/commands/global/NewServer.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.config.IdentityManager;
@@ -49,8 +50,8 @@ public final class NewServer extends GlobalCommand {
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
53
-        if (args.length == 0) {
53
+            final CommandArguments args) {
54
+        if (args.getArguments().length == 0) {
54 55
             showUsage(origin, isSilent, "newserver", "<host[:[+]port]> [password]");
55 56
             return;
56 57
         }
@@ -62,7 +63,7 @@ public final class NewServer extends GlobalCommand {
62 63
         int offset = 0;
63 64
         
64 65
         // Check for SSL
65
-        if (args[offset].equalsIgnoreCase("--ssl")) {
66
+        if (args.getArguments()[offset].equalsIgnoreCase("--ssl")) {
66 67
             Logger.userError(ErrorLevel.LOW, 
67 68
                     "Using /newserver --ssl is deprecated, and may be removed in the future."
68 69
                     + " Use /newserver <host>:+<port> instead.");
@@ -72,8 +73,8 @@ public final class NewServer extends GlobalCommand {
72 73
         }
73 74
         
74 75
         // Check for port
75
-        if (args[offset].indexOf(':') > -1) {
76
-            final String[] parts = args[offset].split(":");
76
+        if (args.getArguments()[offset].indexOf(':') > -1) {
77
+            final String[] parts = args.getArguments()[offset].split(":");
77 78
             host = parts[0];
78 79
             
79 80
             if (parts[1].length() > 0 && parts[1].charAt(0) == '+') {
@@ -93,12 +94,12 @@ public final class NewServer extends GlobalCommand {
93 94
                 return;
94 95
             }            
95 96
         } else {
96
-            host = args[offset];
97
+            host = args.getArguments()[offset];
97 98
         }
98 99
         
99 100
         // Check for password
100
-        if (args.length > ++offset) {
101
-            pass = implodeArgs(offset, args);
101
+        if (args.getArguments().length > ++offset) {
102
+            pass = args.getArgumentsAsString(offset);
102 103
         }
103 104
         
104 105
         new Server(host, port, pass, ssl, IdentityManager.getProfiles().get(0));

+ 4
- 3
src/com/dmdirc/commandparser/commands/global/Notify.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -52,13 +53,13 @@ public final class Notify extends GlobalCommand implements IntelligentCommand {
52 53
     /** {@inheritDoc} */
53 54
     @Override
54 55
     public void execute(final InputWindow origin, final boolean isSilent,
55
-            final String... args) {
56
-        if (args.length == 0) {
56
+            final CommandArguments args) {
57
+        if (args.getArguments().length == 0) {
57 58
             showUsage(origin, isSilent, "notify", "<colour>");
58 59
             return;
59 60
         }
60 61
         
61
-        final Color colour = ColourManager.parseColour(args[0], null);
62
+        final Color colour = ColourManager.parseColour(args.getArguments()[0], null);
62 63
         
63 64
         if (colour == null) {
64 65
             showUsage(origin, isSilent, "notify",

+ 11
- 10
src/com/dmdirc/commandparser/commands/global/OpenWindow.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.CustomWindow;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -49,11 +50,11 @@ public class OpenWindow extends GlobalCommand implements IntelligentCommand {
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
53
+            final CommandArguments args) {
53 54
         int start = 0;
54 55
         Window parent = null;
55 56
 
56
-        if (args.length > 0 && "--server".equals(args[0])) {
57
+        if (args.getArguments().length > 0 && "--server".equals(args.getArguments()[0])) {
57 58
             if (origin.getContainer().getServer() == null) {
58 59
                 sendLine(origin, isSilent, FORMAT_ERROR,
59 60
                         "This window doesn't have an associated server.");
@@ -62,31 +63,31 @@ public class OpenWindow extends GlobalCommand implements IntelligentCommand {
62 63
 
63 64
             parent = origin.getContainer().getServer().getFrame();
64 65
             start = 1;
65
-        } else if (args.length > 0 && "--child".equals(args[0])) {
66
+        } else if (args.getArguments().length > 0 && "--child".equals(args.getArguments()[0])) {
66 67
             parent = origin;
67 68
             start = 1;
68 69
         }
69 70
 
70
-        if (args.length == start || args[start].isEmpty()) {
71
+        if (args.getArguments().length == start || args.getArguments()[start].isEmpty()) {
71 72
             showUsage(origin, isSilent, "openwindow",
72 73
                     "[--server|--child] <name> [title]");
73 74
         } else {
74 75
             Window window;
75 76
             
76 77
             if (parent == null) {
77
-                window = WindowManager.findCustomWindow(args[start]);
78
+                window = WindowManager.findCustomWindow(args.getArguments()[start]);
78 79
             } else {
79
-                window = WindowManager.findCustomWindow(parent, args[start]);
80
+                window = WindowManager.findCustomWindow(parent, args.getArguments()[start]);
80 81
             }
81 82
             
82
-            final String title = args.length > start + 1 ? implodeArgs(
83
-                    start + 1, args) : args[start];
83
+            final String title = args.getArguments().length > start + 1 ?
84
+                args.getArgumentsAsString(start + 1): args.getArguments()[start];
84 85
 
85 86
             if (window == null) {
86 87
                 if (parent == null) {
87
-                    new CustomWindow(args[start], title);
88
+                    new CustomWindow(args.getArguments()[start], title);
88 89
                 } else {
89
-                    new CustomWindow(args[start], title, parent);
90
+                    new CustomWindow(args.getArguments()[start], title, parent);
90 91
                 }
91 92
             } else {
92 93
                 sendLine(origin, isSilent, FORMAT_ERROR,

+ 2
- 1
src/com/dmdirc/commandparser/commands/global/ReloadActions.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -48,7 +49,7 @@ public final class ReloadActions extends GlobalCommand implements IntelligentCom
48 49
     
49 50
     /** {@inheritDoc} */
50 51
     public void execute(final InputWindow origin, final boolean isSilent,
51
-            final String... args) {
52
+            final CommandArguments args) {
52 53
         ActionManager.loadActions();
53 54
         sendLine(origin, isSilent, FORMAT_OUTPUT, "Actions reloaded.");
54 55
     }

+ 3
- 1
src/com/dmdirc/commandparser/commands/global/ReloadIdentities.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -47,7 +48,8 @@ public class ReloadIdentities extends GlobalCommand implements IntelligentComman
47 48
 
48 49
     /** {@inheritDoc} */
49 50
     @Override    
50
-    public void execute(final InputWindow origin, final boolean isSilent, final String... args) {
51
+    public void execute(final InputWindow origin, final boolean isSilent,
52
+            final CommandArguments args) {
51 53
         IdentityManager.loadUser();
52 54
         
53 55
         sendLine(origin, isSilent, FORMAT_OUTPUT, "Identities reloaded.");

+ 4
- 3
src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -51,13 +52,13 @@ public final class ReloadPlugin extends GlobalCommand implements IntelligentComm
51 52
     /** {@inheritDoc} */
52 53
     @Override
53 54
     public void execute(final InputWindow origin, final boolean isSilent,
54
-            final String... args) {
55
-        if (args.length == 0) {
55
+            final CommandArguments args) {
56
+        if (args.getArguments().length == 0) {
56 57
             showUsage(origin, isSilent, "reloadplugin", "<plugin>");
57 58
             return;
58 59
         }
59 60
         
60
-        final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfoByName(args[0]);
61
+        final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfoByName(args.getArguments()[0]);
61 62
         if (plugin == null) {
62 63
             sendLine(origin, isSilent, FORMAT_ERROR, "Plugin Reloading failed - Plugin not loaded");
63 64
         } else if (PluginManager.getPluginManager().reloadPlugin(plugin.getRelativeFilename())) {

+ 9
- 4
src/com/dmdirc/commandparser/commands/global/SaveConfig.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -48,25 +49,29 @@ public final class SaveConfig extends GlobalCommand implements IntelligentComman
48 49
     }
49 50
     
50 51
     /** {@inheritDoc} */
52
+    @Override
51 53
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
54
+            final CommandArguments args) {
53 55
         IdentityManager.save();
54 56
         
55 57
         sendLine(origin, isSilent, FORMAT_OUTPUT, "Configuration file saved.");
56 58
     }
57 59
     
58 60
     
59
-    /** {@inheritDoc}. */
61
+    /** {@inheritDoc} */
62
+    @Override
60 63
     public String getName() {
61 64
         return "saveconfig";
62 65
     }
63 66
     
64
-    /** {@inheritDoc}. */
67
+    /** {@inheritDoc} */
68
+    @Override
65 69
     public boolean showInHelp() {
66 70
         return true;
67 71
     }
68 72
     
69
-    /** {@inheritDoc}. */
73
+    /** {@inheritDoc} */
74
+    @Override
70 75
     public String getHelp() {
71 76
         return "saveconfig - force the client to save its configuration to disk";
72 77
     }

+ 18
- 12
src/com/dmdirc/commandparser/commands/global/Set.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -52,38 +53,43 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
52 53
     /** {@inheritDoc} */
53 54
     @Override
54 55
     public void execute(final InputWindow origin, final boolean isSilent,
55
-            final String... args) {
56
+            final CommandArguments args) {
56 57
         int i = 0;
57 58
         
58 59
         Identity identity = IdentityManager.getConfigIdentity();
59 60
         ConfigManager manager = IdentityManager.getGlobalConfig();
60 61
         
61
-        if (args.length > 0 && "--server".equalsIgnoreCase(args[0]) && origin != null
62
+        if (args.getArguments().length > 0
63
+                && "--server".equalsIgnoreCase(args.getArguments()[0]) && origin != null
62 64
                 && origin.getContainer().getServer() != null) {
63 65
             i = 1;
64 66
             identity = origin.getContainer().getServer().getServerIdentity();
65 67
             manager = origin.getContainer().getServer().getConfigManager();
66 68
         }
67 69
         
68
-        switch (args.length - i) {
70
+        switch (args.getArguments().length - i) {
69 71
         case 0:
70 72
             doDomainList(origin, isSilent, manager);
71 73
             break;
72 74
         case 1:
73
-            doOptionsList(origin, isSilent, manager, args[i]);
75
+            doOptionsList(origin, isSilent, manager, args.getArguments()[i]);
74 76
             break;
75 77
         case 2:
76
-            doShowOption(origin, isSilent, manager, args[i], args[1 + i]);
78
+            doShowOption(origin, isSilent, manager, args.getArguments()[i],
79
+                    args.getArguments()[1 + i]);
77 80
             break;
78 81
         default:
79
-            if (args[i].equalsIgnoreCase("--unset")) {
80
-                doUnsetOption(origin, isSilent, identity, args[1 + i], args[2 + i]);
81
-            } else if (args[i].equalsIgnoreCase("--append") && args.length > 3 + i) {
82
-                doAppendOption(origin, isSilent, identity, manager, args[1 + i], args[2 + i],
83
-                        implodeArgs(3 + i, args));
82
+            if (args.getArguments()[i].equalsIgnoreCase("--unset")) {
83
+                doUnsetOption(origin, isSilent, identity, args.getArguments()[1 + i],
84
+                        args.getArguments()[2 + i]);
85
+            } else if (args.getArguments()[i].equalsIgnoreCase("--append")
86
+                    && args.getArguments().length > 3 + i) {
87
+                doAppendOption(origin, isSilent, identity, manager, 
88
+                        args.getArguments()[1 + i], args.getArguments()[2 + i],
89
+                        args.getArgumentsAsString(3 + i));
84 90
             } else {
85
-                doSetOption(origin, isSilent, identity, args[i], args[1 + i],
86
-                        implodeArgs(2 + i, args));
91
+                doSetOption(origin, isSilent, identity, args.getArguments()[i],
92
+                        args.getArguments()[1 + i], args.getArgumentsAsString(2 + i));
87 93
             }
88 94
         }
89 95
     }

+ 5
- 3
src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -51,13 +52,14 @@ public final class UnloadPlugin extends GlobalCommand implements IntelligentComm
51 52
     /** {@inheritDoc} */
52 53
     @Override
53 54
     public void execute(final InputWindow origin, final boolean isSilent,
54
-            final String... args) {
55
-        if (args.length == 0) {
55
+            final CommandArguments args) {
56
+        if (args.getArguments().length == 0) {
56 57
             showUsage(origin, isSilent, "unloadplugin", "<plugin>");
57 58
             return;
58 59
         }
59 60
         
60
-        final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfoByName(args[0]);
61
+        final PluginInfo plugin = PluginManager.getPluginManager()
62
+                .getPluginInfoByName(args.getArguments()[0]);
61 63
         if (plugin == null) {
62 64
             sendLine(origin, isSilent, FORMAT_ERROR, "Plugin unloading failed - Plugin not loaded");
63 65
         } else if (PluginManager.getPluginManager().delPlugin(plugin.getRelativeFilename())) {

+ 3
- 2
src/com/dmdirc/commandparser/commands/server/AllChannels.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28 29
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -49,8 +50,8 @@ public final class AllChannels extends ServerCommand implements IntelligentComma
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final Server server,
52
-            final boolean isSilent, final String... args) {
53
-        final String command = implodeArgs(args);
53
+            final boolean isSilent, final CommandArguments args) {
54
+        final String command = args.getArgumentsAsString();
54 55
         InputWindow window;
55 56
         
56 57
         for (String channel : server.getChannels()) {

+ 3
- 2
src/com/dmdirc/commandparser/commands/server/Away.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerState;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.ServerCommand;
29 30
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -46,9 +47,9 @@ public final class Away extends ServerCommand {
46 47
     /** {@inheritDoc} */
47 48
     @Override
48 49
     public void execute(final InputWindow origin, final Server server,
49
-            final boolean isSilent, final String... args) {
50
+            final boolean isSilent, final CommandArguments args) {
50 51
         if (server.getState() == ServerState.CONNECTED) {
51
-            final String line = implodeArgs(args);
52
+            final String line = args.getArgumentsAsString();
52 53
 
53 54
             server.getParser().sendLine("AWAY :" + line);
54 55
         } else {

+ 2
- 1
src/com/dmdirc/commandparser/commands/server/Back.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerState;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
29 30
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -56,7 +57,7 @@ public final class Back extends ServerCommand implements IntelligentCommand {
56 57
      */
57 58
     @Override
58 59
     public void execute(final InputWindow origin, final Server server,
59
-            final boolean isSilent, final String... args) {
60
+            final boolean isSilent, final CommandArguments args) {
60 61
         if (server.getState() != ServerState.CONNECTED) {
61 62
             sendLine(origin, isSilent, FORMAT_ERROR, "Not connected");
62 63
             return;

+ 9
- 8
src/com/dmdirc/commandparser/commands/server/ChangeServer.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.ServerCommand;
28 29
 import com.dmdirc.logger.ErrorLevel;
@@ -48,8 +49,8 @@ public final class ChangeServer extends ServerCommand {
48 49
     /** {@inheritDoc} */
49 50
     @Override
50 51
     public void execute(final InputWindow origin, final Server server,
51
-            final boolean isSilent, final String... args) {
52
-        if (args.length == 0) {
52
+            final boolean isSilent, final CommandArguments args) {
53
+        if (args.getArguments().length == 0) {
53 54
             showUsage(origin, isSilent, "server", "<host[:[+]port]> [password]");
54 55
             return;
55 56
         }
@@ -61,7 +62,7 @@ public final class ChangeServer extends ServerCommand {
61 62
         int offset = 0;
62 63
         
63 64
         // Check for SSL
64
-        if (args[offset].equalsIgnoreCase("--ssl")) {
65
+        if (args.getArguments()[offset].equalsIgnoreCase("--ssl")) {
65 66
             Logger.userError(ErrorLevel.LOW,
66 67
                     "Using /server --ssl is deprecated, and may be removed in the future."
67 68
                     + " Use /server <host>:+<port> instead.");
@@ -71,8 +72,8 @@ public final class ChangeServer extends ServerCommand {
71 72
         }
72 73
         
73 74
         // Check for port
74
-        if (args[offset].indexOf(':') > -1) {
75
-            final String[] parts = args[offset].split(":");
75
+        if (args.getArguments()[offset].indexOf(':') > -1) {
76
+            final String[] parts = args.getArguments()[offset].split(":");
76 77
             host = parts[0];
77 78
             
78 79
             if (parts[1].length() > 0 && parts[1].charAt(0) == '+') {
@@ -92,12 +93,12 @@ public final class ChangeServer extends ServerCommand {
92 93
                 return;
93 94
             }
94 95
         } else {
95
-            host = args[offset];
96
+            host = args.getArguments()[offset];
96 97
         }
97 98
         
98 99
         // Check for password
99
-        if (args.length > ++offset) {
100
-            pass = implodeArgs(offset, args);
100
+        if (args.getArguments().length > ++offset) {
101
+            pass = args.getArgumentsAsString(offset);
101 102
         }
102 103
         
103 104
         server.connect(host, port, pass, ssl, server.getProfile());

+ 7
- 5
src/com/dmdirc/commandparser/commands/server/Ctcp.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerState;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
29 30
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -57,18 +58,19 @@ public final class Ctcp extends ServerCommand implements IntelligentCommand {
57 58
      */
58 59
     @Override
59 60
     public void execute(final InputWindow origin, final Server server,
60
-            final boolean isSilent, final String... args) {
61
+            final boolean isSilent, final CommandArguments args) {
61 62
         if (server.getState() != ServerState.CONNECTED) {
62 63
             sendLine(origin, isSilent, FORMAT_ERROR, "Not connected");
63 64
             return;
64 65
         }
65 66
 
66
-        if (args.length < 2) {
67
+        if (args.getArguments().length < 2) {
67 68
             showUsage(origin, isSilent, "ctcp", "<target> <type> [arguments]");
68 69
         } else {
69
-            server.getParser().sendLine("PRIVMSG " + args[0] + " :"
70
-                    + ((char) 1) + implodeArgs(1, args) + ((char) 1));
71
-            sendLine(origin, isSilent, "selfCTCP", args[0], implodeArgs(1, args));
70
+            server.getParser().sendLine("PRIVMSG " + args.getArguments()[0] + " :"
71
+                    + ((char) 1) + args.getArgumentsAsString(1) + ((char) 1));
72
+            sendLine(origin, isSilent, "selfCTCP", args.getArguments()[0],
73
+                    args.getArgumentsAsString(1));
72 74
         }
73 75
     }
74 76
     

+ 4
- 3
src/com/dmdirc/commandparser/commands/server/Disconnect.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.ServerCommand;
28 29
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -50,13 +51,13 @@ public final class Disconnect extends ServerCommand {
50 51
      * @param args The user supplied arguments
51 52
      */
52 53
     public void execute(final InputWindow origin, final Server server,
53
-            final boolean isSilent, final String... args) {
54
+            final boolean isSilent, final CommandArguments args) {
54 55
         String line;
55 56
         
56
-        if (args.length == 0) {
57
+        if (args.getArguments().length == 0) {
57 58
             line = origin.getConfigManager().getOption("general", "quitmessage");
58 59
         } else {
59
-            line = implodeArgs(args);
60
+            line = args.getArgumentsAsString();
60 61
         }
61 62
         
62 63
         server.disconnect(line);

+ 13
- 7
src/com/dmdirc/commandparser/commands/server/Ignore.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28 29
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -57,11 +58,12 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
57 58
      */
58 59
     @Override
59 60
     public void execute(final InputWindow origin, final Server server,
60
-            final boolean isSilent, final String... args) {
61
+            final boolean isSilent, final CommandArguments args) {
61 62
         
62 63
         final Identity identity = server.getNetworkIdentity();
63 64
         
64
-        if (args.length == 0 || args[0].toLowerCase().equals("view")) {
65
+        if (args.getArguments().length == 0
66
+                || args.getArguments()[0].toLowerCase().equals("view")) {
65 67
             
66 68
             if (identity.hasOptionString("network", "ignorelist")) {
67 69
                 final List<String> list = identity.getOptionList("network", "ignorelist");
@@ -86,9 +88,10 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
86 88
                 sendLine(origin, isSilent, FORMAT_ERROR, "No ignore list entries for this network.");
87 89
             }
88 90
             
89
-        } else if (args[0].toLowerCase().equals("add") && args.length > 1) {
91
+        } else if (args.getArguments()[0].toLowerCase().equals("add")
92
+                && args.getArguments().length > 1) {
90 93
             
91
-            final String host = implodeArgs(1, args);
94
+            final String host = args.getArgumentsAsString(1);
92 95
             String list = host;
93 96
             
94 97
             if (identity.hasOptionString("network", "ignorelist")) {
@@ -100,9 +103,11 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
100 103
             
101 104
             sendLine(origin, isSilent, FORMAT_OUTPUT, "Added " + host + " to the ignore list.");
102 105
             
103
-        } else if (args[0].toLowerCase().equals("remove") && args.length > 1) {
106
+        } else if (args.getArguments()[0].toLowerCase().equals("remove")
107
+                && args.getArguments().length > 1) {
104 108
             
105
-            final String host = server.getParser().getIRCStringConverter().toLowerCase(implodeArgs(1, args));
109
+            final String host = server.getParser().getIRCStringConverter()
110
+                    .toLowerCase(args.getArgumentsAsString(1));
106 111
             
107 112
             final StringBuffer newlist = new StringBuffer();
108 113
             boolean found = false;
@@ -112,7 +117,8 @@ public final class Ignore extends ServerCommand implements IntelligentCommand {
112 117
                 
113 118
                 
114 119
                 for (String entry : list.split("\n")) {
115
-                    if (server.getParser().getIRCStringConverter().toLowerCase(entry).equals(host)) {
120
+                    if (server.getParser().getIRCStringConverter()
121
+                            .toLowerCase(entry).equals(host)) {
116 122
                         found = true;
117 123
                     } else {
118 124
                         if (newlist.length() > 0) {

+ 13
- 11
src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java View File

@@ -27,6 +27,7 @@ import com.dmdirc.Server;
27 27
 import com.dmdirc.actions.ActionManager;
28 28
 import com.dmdirc.actions.CoreActionType;
29 29
 import com.dmdirc.actions.interfaces.ActionType;
30
+import com.dmdirc.commandparser.CommandArguments;
30 31
 import com.dmdirc.commandparser.CommandManager;
31 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 33
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -60,13 +61,13 @@ public final class JoinChannelCommand extends ServerCommand implements
60 61
     /** {@inheritDoc} */
61 62
     @Override
62 63
     public void execute(final InputWindow origin, final Server server,
63
-            final boolean isSilent, final String... args) {
64
-        if (args.length == 0) {
64
+            final boolean isSilent, final CommandArguments args) {
65
+        if (args.getArguments().length == 0) {
65 66
             showUsage(origin, isSilent, "join", "join <channel [key]>[,channel [key]...]");
66 67
             return;
67 68
         }
68 69
 
69
-        for (String pair : implodeArgs(args).split(",")) {
70
+        for (String pair : args.getArgumentsAsString().split(",")) {
70 71
             if (pair.trim().indexOf(' ') == -1) {
71 72
                 server.join(pair);
72 73
             } else {
@@ -74,24 +75,25 @@ public final class JoinChannelCommand extends ServerCommand implements
74 75
             }
75 76
         }
76 77
 
77
-        if (server.getParser().isValidChannelName(args[0])) {
78
+        if (server.getParser().isValidChannelName(args.getArguments()[0])) {
78 79
             sendLine(origin, isSilent, FORMAT_ERROR, "You can't open a query "
79 80
                     + "with a channel; maybe you meant " + Styliser.CODE_FIXED
80 81
                     + Styliser.CODE_BOLD + CommandManager.getCommandChar()
81
-                    + (args.length > 1 ? "msg" : "join") + " " + implodeArgs(args)
82
+                    + (args.getArguments().length > 1 ? "msg" : "join")
83
+                    + " " + args.getArgumentsAsString()
82 84
                     + Styliser.CODE_BOLD + Styliser.CODE_FIXED + "?");
83 85
             return;
84 86
         }
85 87
 
86
-        if (server.hasQuery(args[0])) {
87
-            server.getQuery(args[0]).activateFrame();
88
+        if (server.hasQuery(args.getArguments()[0])) {
89
+            server.getQuery(args.getArguments()[0]).activateFrame();
88 90
         } else {
89
-            server.addQuery(args[0]);
90
-            server.getQuery(args[0]).show();                
91
+            server.addQuery(args.getArguments()[0]);
92
+            server.getQuery(args.getArguments()[0]).show();
91 93
         }
92 94
 
93
-        if (args.length > 1) {
94
-            server.getQuery(args[0]).sendLine(implodeArgs(1, args));
95
+        if (args.getArguments().length > 1) {
96
+            server.getQuery(args.getArguments()[0]).sendLine(args.getArgumentsAsString(1));
95 97
         }
96 98
     }
97 99
     

+ 7
- 5
src/com/dmdirc/commandparser/commands/server/Message.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerState;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
29 30
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -53,18 +54,19 @@ public final class Message extends ServerCommand implements IntelligentCommand,
53 54
     /** {@inheritDoc} */
54 55
     @Override
55 56
     public void execute(final InputWindow origin, final Server server,
56
-            final boolean isSilent, final String... args) {
57
+            final boolean isSilent, final CommandArguments args) {
57 58
         if (server.getState() != ServerState.CONNECTED) {
58 59
             sendLine(origin, isSilent, FORMAT_ERROR, "Not connected");
59 60
             return;
60 61
         }
61 62
         
62
-        if (args.length < 2) {
63
+        if (args.getArguments().length < 2) {
63 64
             showUsage(origin, isSilent, "msg", "<target> <message>");
64 65
         } else {
65
-            server.getParser().sendLine("PRIVMSG " + args[0] + " :"
66
-                    + implodeArgs(1, args));
67
-            sendLine(origin, isSilent, "selfMessage", args[0], implodeArgs(1, args));
66
+            server.getParser().sendLine("PRIVMSG " + args.getArguments()[0] + " :"
67
+                    + args.getArgumentsAsString(1));
68
+            sendLine(origin, isSilent, "selfMessage", args.getArguments()[0],
69
+                    args.getArgumentsAsString(1));
68 70
         }
69 71
     }
70 72
     

+ 12
- 13
src/com/dmdirc/commandparser/commands/server/Nick.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28 29
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -47,35 +48,33 @@ public final class Nick extends ServerCommand implements IntelligentCommand {
47 48
         CommandManager.registerCommand(this);
48 49
     }
49 50
     
50
-    /**
51
-     * Executes this command.
52
-     * @param origin The frame in which this command was issued
53
-     * @param server The server object that this command is associated with
54
-     * @param isSilent Whether this command is silenced or not
55
-     * @param args The user supplied arguments
56
-     */
51
+    /** {@inheritDoc} */
52
+    @Override
57 53
     public void execute(final InputWindow origin, final Server server,
58
-            final boolean isSilent, final String... args) {
59
-        if (args.length == 0) {
54
+            final boolean isSilent, final CommandArguments args) {
55
+        if (args.getArguments().length == 0) {
60 56
             showUsage(origin, isSilent, "nick", "<new nickname>");
61 57
             return;
62 58
         }
63 59
         
64
-        server.getParser().setNickname(args[0]);
60
+        server.getParser().setNickname(args.getArguments()[0]);
65 61
     }
66 62
     
67 63
     
68
-    /** {@inheritDoc}. */
64
+    /** {@inheritDoc} */
65
+    @Override
69 66
     public String getName() {
70 67
         return "nick";
71 68
     }
72 69
     
73
-    /** {@inheritDoc}. */
70
+    /** {@inheritDoc} */
71
+    @Override
74 72
     public boolean showInHelp() {
75 73
         return true;
76 74
     }
77 75
     
78
-    /** {@inheritDoc}. */
76
+    /** {@inheritDoc} */
77
+    @Override
79 78
     public String getHelp() {
80 79
         return "nick <new nickname> - attempts to change your nickname to the one specified";
81 80
     }

+ 7
- 5
src/com/dmdirc/commandparser/commands/server/Notice.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerState;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
29 30
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -51,18 +52,19 @@ public final class Notice extends ServerCommand implements IntelligentCommand {
51 52
     /** {@inheritDoc} */
52 53
     @Override
53 54
     public void execute(final InputWindow origin, final Server server,
54
-            final boolean isSilent, final String... args) {
55
+            final boolean isSilent, final CommandArguments args) {
55 56
         if (server.getState() != ServerState.CONNECTED) {
56 57
             sendLine(origin, isSilent, FORMAT_ERROR, "Not connected");
57 58
             return;
58 59
         }
59 60
         
60
-        if (args.length < 2) {
61
+        if (args.getArguments().length < 2) {
61 62
             showUsage(origin, isSilent, "notice", "<target> <message>");
62 63
         } else {
63
-            server.getParser().sendLine("NOTICE " + args[0] + " :"
64
-                    + implodeArgs(1, args));
65
-            sendLine(origin, isSilent, "selfNotice", args[0], implodeArgs(1, args));
64
+            server.getParser().sendLine("NOTICE " + args.getArguments()[0] + " :"
65
+                    + args.getArgumentsAsString(1));
66
+            sendLine(origin, isSilent, "selfNotice", args.getArguments()[0],
67
+                    args.getArgumentsAsString(1));
66 68
         }
67 69
     }
68 70
     

+ 12
- 10
src/com/dmdirc/commandparser/commands/server/OpenQuery.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28 29
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -53,30 +54,31 @@ public final class OpenQuery extends ServerCommand implements
53 54
     /** {@inheritDoc} */
54 55
     @Override
55 56
     public void execute(final InputWindow origin, final Server server,
56
-            final boolean isSilent, final String... args) {
57
-        if (args.length == 0) {
57
+            final boolean isSilent, final CommandArguments args) {
58
+        if (args.getArguments().length == 0) {
58 59
             showUsage(origin, isSilent, "query", "<target> <message>");
59 60
             return;
60 61
         }
61 62
             
62
-        if (server.getParser().isValidChannelName(args[0])) {
63
+        if (server.getParser().isValidChannelName(args.getArguments()[0])) {
63 64
             sendLine(origin, isSilent, FORMAT_ERROR, "You can't open a query "
64 65
                     + "with a channel; maybe you meant " + Styliser.CODE_FIXED
65 66
                     + Styliser.CODE_BOLD + CommandManager.getCommandChar()
66
-                    + (args.length > 1 ? "msg" : "join") + " " + implodeArgs(args)
67
+                    + (args.getArguments().length > 1 ? "msg" : "join") + " "
68
+                    + args.getArgumentsAsString()
67 69
                     + Styliser.CODE_BOLD + Styliser.CODE_FIXED + "?");
68 70
             return;
69 71
         }
70 72
 
71
-        if (server.hasQuery(args[0])) {
72
-            server.getQuery(args[0]).activateFrame();
73
+        if (server.hasQuery(args.getArguments()[0])) {
74
+            server.getQuery(args.getArguments()[0]).activateFrame();
73 75
         } else {
74
-            server.addQuery(args[0]);
75
-            server.getQuery(args[0]).show();                
76
+            server.addQuery(args.getArguments()[0]);
77
+            server.getQuery(args.getArguments()[0]).show();
76 78
         }
77 79
 
78
-        if (args.length > 1) {
79
-            server.getQuery(args[0]).sendLine(implodeArgs(1, args));
80
+        if (args.getArguments().length > 1) {
81
+            server.getQuery(args.getArguments()[0]).sendLine(args.getArgumentsAsString(1));
80 82
         }
81 83
     }
82 84
     

+ 11
- 12
src/com/dmdirc/commandparser/commands/server/Raw.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.ServerCommand;
28 29
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -43,33 +44,31 @@ public final class Raw extends ServerCommand {
43 44
         CommandManager.registerCommand(this);
44 45
     }
45 46
     
46
-    /**
47
-     * Executes this command.
48
-     * @param origin The frame in which this command was issued
49
-     * @param server The server object that this command is associated with
50
-     * @param isSilent Whether this command is silenced or not
51
-     * @param args The user supplied arguments
52
-     */
47
+    /** {@inheritDoc} */
48
+    @Override
53 49
     public void execute(final InputWindow origin, final Server server,
54
-            final boolean isSilent, final String... args) {
55
-        final String line = implodeArgs(args);
50
+            final boolean isSilent, final CommandArguments args) {
51
+        final String line = args.getArgumentsAsString();
56 52
         
57 53
         server.getParser().sendLine(line);
58 54
         sendLine(origin, isSilent, "rawCommand", line);
59 55
     }
60 56
     
61 57
     
62
-    /** {@inheritDoc}. */
58
+    /** {@inheritDoc} */
59
+    @Override
63 60
     public String getName() {
64 61
         return "raw";
65 62
     }
66 63
     
67
-    /** {@inheritDoc}. */
64
+    /** {@inheritDoc} */
65
+    @Override
68 66
     public boolean showInHelp() {
69 67
         return true;
70 68
     }
71 69
     
72
-    /** {@inheritDoc}. */
70
+    /** {@inheritDoc} */
71
+    @Override
73 72
     public String getHelp() {
74 73
         return "raw <text> - sends the specified text directly to the server";
75 74
     }

+ 3
- 2
src/com/dmdirc/commandparser/commands/server/RawServerCommand.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.ServerCommand;
28 29
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -54,8 +55,8 @@ public final class RawServerCommand extends ServerCommand {
54 55
     /** {@inheritDoc} */
55 56
     @Override
56 57
     public void execute(final InputWindow origin, final Server server,
57
-            final boolean isSilent, final String... args) {
58
-        server.getParser().sendLine(myName.toUpperCase() + " " + implodeArgs(args));
58
+            final boolean isSilent, final CommandArguments args) {
59
+        server.getParser().sendLine(myName.toUpperCase() + " " + args.getArgumentsAsString());
59 60
     }
60 61
     
61 62
     

+ 4
- 3
src/com/dmdirc/commandparser/commands/server/Reconnect.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.ServerCommand;
28 29
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -45,13 +46,13 @@ public final class Reconnect extends ServerCommand {
45 46
     /** {@inheritDoc} */
46 47
     @Override
47 48
     public void execute(final InputWindow origin, final Server server,
48
-            final boolean isSilent, final String... args) {
49
+            final boolean isSilent, final CommandArguments args) {
49 50
         String line;
50 51
         
51
-        if (args.length == 0) {
52
+        if (args.getArguments().length == 0) {
52 53
             line = origin.getConfigManager().getOption("general", "reconnectmessage");
53 54
         } else {
54
-            line = implodeArgs(args);
55
+            line = args.getArgumentsAsString();
55 56
         }
56 57
         
57 58
         server.reconnect(line);

+ 3
- 2
src/com/dmdirc/commandparser/commands/server/Umode.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.server;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerState;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.ServerCommand;
29 30
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -47,14 +48,14 @@ public class Umode extends ServerCommand {
47 48
     /** {@inheritDoc} */
48 49
     @Override
49 50
     public void execute(final InputWindow origin, final Server server, 
50
-            final boolean isSilent, final String... args) {
51
+            final boolean isSilent, final CommandArguments args) {
51 52
         if (server.getState() != ServerState.CONNECTED) {
52 53
             sendLine(origin, isSilent, FORMAT_ERROR, "Not connected");
53 54
             return;
54 55
         }
55 56
 
56 57
         server.getParser().sendLine("MODE " + server.getParser().getMyNickname()
57
-                + " " + implodeArgs(args));
58
+                + " " + args.getArgumentsAsString());
58 59
     }
59 60
 
60 61
     /** {@inheritDoc} */

+ 10
- 5
src/com/dmdirc/commandparser/parsers/ChannelCommandParser.java View File

@@ -24,7 +24,9 @@ package com.dmdirc.commandparser.parsers;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
29
+import com.dmdirc.commandparser.CommandType;
28 30
 import com.dmdirc.commandparser.commands.ChannelCommand;
29 31
 import com.dmdirc.commandparser.commands.ChatCommand;
30 32
 import com.dmdirc.commandparser.commands.Command;
@@ -67,16 +69,17 @@ public final class ChannelCommandParser extends CommandParser {
67 69
         this.channel = newChannel;
68 70
     }
69 71
     
70
-    /** Loads the relevant commands into the parser. */
72
+    /** {@inheritDoc} */
73
+    @Override
71 74
     protected void loadCommands() {
72
-        CommandManager.loadGlobalCommands(this);
73
-        CommandManager.loadServerCommands(this);
74
-        CommandManager.loadChannelCommands(this);
75
+        CommandManager.loadCommands(this, CommandType.TYPE_GLOBAL,
76
+                CommandType.TYPE_SERVER, CommandType.TYPE_CHANNEL);
75 77
     }
76 78
     
77 79
     /** {@inheritDoc} */
80
+    @Override
78 81
     protected void executeCommand(final InputWindow origin,
79
-            final boolean isSilent, final Command command, final String... args) {
82
+            final boolean isSilent, final Command command, final CommandArguments args) {
80 83
         if (command instanceof ChannelCommand) {
81 84
             ((ChannelCommand) command).execute(origin, server, channel, isSilent, args);
82 85
         } else if (command instanceof ChatCommand) {
@@ -91,9 +94,11 @@ public final class ChannelCommandParser extends CommandParser {
91 94
     /**
92 95
      * Called when the input was a line of text that was not a command. This normally
93 96
      * means it is sent to the server/channel/user as-is, with no further processing.
97
+     *
94 98
      * @param origin The window in which the command was typed
95 99
      * @param line The line input by the user
96 100
      */
101
+    @Override
97 102
     protected void handleNonCommand(final InputWindow origin, final String line) {
98 103
         channel.sendLine(line);
99 104
     }

+ 35
- 53
src/com/dmdirc/commandparser/parsers/CommandParser.java View File

@@ -25,6 +25,8 @@ package com.dmdirc.commandparser.parsers;
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.actions.ActionManager;
27 27
 import com.dmdirc.actions.CoreActionType;
28
+import com.dmdirc.commandparser.CommandArguments;
29
+import com.dmdirc.commandparser.CommandInfo;
28 30
 import com.dmdirc.commandparser.CommandManager;
29 31
 import com.dmdirc.commandparser.CommandType;
30 32
 import com.dmdirc.commandparser.commands.Command;
@@ -79,19 +81,22 @@ public abstract class CommandParser implements Serializable {
79 81
     /**
80 82
      * Registers the specified command with this parser.
81 83
      *
84
+     * @since 0.6.3
82 85
      * @param command Command to be registered
86
+     * @param info The information the command should be registered with
83 87
      */
84
-    public final void registerCommand(final Command command) {
85
-        commands.put(command.getName().toLowerCase(), command);
88
+    public final void registerCommand(final Command command, final CommandInfo info) {
89
+        commands.put(info.getName().toLowerCase(), command);
86 90
     }
87 91
 
88 92
     /**
89 93
      * Unregisters the specified command with this parser.
90 94
      *
91
-     * @param command Command to be unregistered
95
+     * @param info Command information to be unregistered
96
+     * @since 0.6.3
92 97
      */
93
-    public final void unregisterCommand(final Command command) {
94
-        commands.remove(command.getName().toLowerCase());
98
+    public final void unregisterCommand(final CommandInfo info) {
99
+        commands.remove(info.getName().toLowerCase());
95 100
     }
96 101
 
97 102
     /**
@@ -104,67 +109,42 @@ public abstract class CommandParser implements Serializable {
104 109
      */
105 110
     public final void parseCommand(final InputWindow origin,
106 111
             final String line, final boolean parseChannel) {
107
-        if (line.isEmpty()) {
108
-            return;
109
-        }
110
-
111
-        if (line.charAt(0) == CommandManager.getCommandChar()) {
112
-            int offset = 1;
113
-            boolean silent = false;
114
-
115
-            if (line.length() > offset && line.charAt(offset) == CommandManager.getSilenceChar()) {
116
-                silent = true;
117
-                offset++;
118
-            }
112
+        final CommandArguments args = new CommandArguments(line);
119 113
 
120
-            final String[] args = line.split(" ");
121
-            final String command = args[0].substring(offset);
122
-            String[] comargs;
114
+        if (args.isCommand()) {
115
+            final boolean silent = args.isSilent();
116
+            final String command = args.getCommandName();
117
+            final String[] cargs = args.getArguments();
123 118
 
124
-            if (args.length >= 2 && parseChannel && origin != null
119
+            if (args.getArguments().length > 0 && parseChannel && origin != null
125 120
                     && origin.getContainer() != null
126 121
                     && origin.getContainer().getServer() != null
127
-                    && origin.getContainer().getServer().isValidChannelName(args[1])
122
+                    && origin.getContainer().getServer().isValidChannelName(cargs[0])
128 123
                     && CommandManager.isChannelCommand(command)) {
129 124
                 final Server server = origin.getContainer().getServer();
130 125
 
131
-                if (server.hasChannel(args[1])) {
132
-
133
-                    final StringBuilder newLine = new StringBuilder();
134
-                    for (int i = 0; i < args.length; i++) {
135
-                        if (i == 1) { continue; }
136
-                        newLine.append(" ").append(args[i]);
137
-                    }
138
-
139
-                    server.getChannel(args[1]).getFrame().getCommandParser()
140
-                            .parseCommand(origin, newLine.substring(1), false);
141
-
126
+                if (server.hasChannel(cargs[0])) {
127
+                    server.getChannel(cargs[0]).getFrame().getCommandParser()
128
+                            .parseCommand(origin, args.getWordsAsString(2), false);
142 129
                     return;
143 130
                 } else {
144 131
                     final Command actCommand = CommandManager.getCommand(
145 132
                             CommandType.TYPE_CHANNEL, command);
146 133
 
147 134
                     if (actCommand instanceof ExternalCommand) {
148
-                        comargs = new String[args.length - 2];
149
-                        System.arraycopy(args, 2, comargs, 0, args.length - 2);
150
-
151
-                        ((ExternalCommand) actCommand).execute(origin, server,
152
-                                args[1], silent, comargs);
135
+                        ((ExternalCommand) actCommand).execute(
136
+                                origin, server, cargs[0], silent,
137
+                                new CommandArguments(args.getWordsAsString(2)));
153 138
                         return;
154 139
                     }
155 140
                 }
156 141
             }
157 142
 
158
-            comargs = new String[args.length - 1];
159
-            System.arraycopy(args, 1, comargs, 0, args.length - 1);
160
-
161
-            final String signature = command;
162
-
163
-            if (commands.containsKey(signature.toLowerCase())) {
164
-                addHistory(line.substring(offset));
165
-                executeCommand(origin, silent, commands.get(signature.toLowerCase()), comargs);
143
+            if (commands.containsKey(command.toLowerCase())) {
144
+                addHistory(args.getStrippedLine());
145
+                executeCommand(origin, silent, commands.get(command.toLowerCase()), args);
166 146
            } else {
167
-                handleInvalidCommand(origin, command, comargs);
147
+                handleInvalidCommand(origin, args);
168 148
             }
169 149
         } else {
170 150
             handleNonCommand(origin, line);
@@ -233,30 +213,32 @@ public abstract class CommandParser implements Serializable {
233 213
      * @param isSilent Whether the command is being silenced or not
234 214
      * @param command The command to be executed
235 215
      * @param args The arguments to the command
216
+     * @since 0.6.3
236 217
      */
237 218
     protected abstract void executeCommand(final InputWindow origin,
238
-            final boolean isSilent, final Command command, final String... args);
219
+            final boolean isSilent, final Command command, final CommandArguments args);
239 220
 
240 221
     /**
241 222
      * Called when the user attempted to issue a command (i.e., used the command
242 223
      * character) that wasn't found. It could be that the command has a different
243 224
      * arity, or that it plain doesn't exist.
225
+     *
244 226
      * @param origin The window in which the command was typed
245
-     * @param command The command the user tried to execute
246 227
      * @param args The arguments passed to the command
228
+     * @since 0.6.3
247 229
      */
248 230
     protected void handleInvalidCommand(final InputWindow origin,
249
-            final String command, final String... args) {
231
+            final CommandArguments args) {
250 232
         if (origin == null) {
251 233
             ActionManager.processEvent(CoreActionType.UNKNOWN_COMMAND, null,
252
-                    null, command, args);
234
+                    null, args.getCommandName(), args.getArguments());
253 235
         } else {
254 236
             final StringBuffer buff = new StringBuffer("unknownCommand");
255 237
 
256 238
             ActionManager.processEvent(CoreActionType.UNKNOWN_COMMAND, buff,
257
-                    origin.getContainer(), command, args);
239
+                    origin.getContainer(), args.getCommandName(), args.getArguments());
258 240
 
259
-            origin.addLine(buff, command);
241
+            origin.addLine(buff, args.getCommandName());
260 242
         }
261 243
     }
262 244
 

+ 7
- 2
src/com/dmdirc/commandparser/parsers/GlobalCommandParser.java View File

@@ -22,7 +22,9 @@
22 22
 
23 23
 package com.dmdirc.commandparser.parsers;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
27
+import com.dmdirc.commandparser.CommandType;
26 28
 import com.dmdirc.commandparser.commands.Command;
27 29
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 30
 import com.dmdirc.logger.ErrorLevel;
@@ -67,13 +69,15 @@ public final class GlobalCommandParser extends CommandParser {
67 69
     }
68 70
     
69 71
     /** Loads the relevant commands into the parser. */
72
+    @Override
70 73
     protected void loadCommands() {
71
-        CommandManager.loadGlobalCommands(this);
74
+        CommandManager.loadCommands(this, CommandType.TYPE_GLOBAL);
72 75
     }
73 76
     
74 77
     /** {@inheritDoc} */
78
+    @Override
75 79
     protected void executeCommand(final InputWindow origin,
76
-            final boolean isSilent, final Command command, final String... args) {
80
+            final boolean isSilent, final Command command, final CommandArguments args) {
77 81
         ((GlobalCommand) command).execute(origin, isSilent, args);
78 82
     }
79 83
     
@@ -83,6 +87,7 @@ public final class GlobalCommandParser extends CommandParser {
83 87
      * @param origin The window in which the command was typed
84 88
      * @param line The line input by the user
85 89
      */
90
+    @Override
86 91
     protected void handleNonCommand(final InputWindow origin, final String line) {
87 92
         if (origin == null) {
88 93
             Logger.userError(ErrorLevel.MEDIUM, "Invalid global command: " + line);

+ 8
- 4
src/com/dmdirc/commandparser/parsers/QueryCommandParser.java View File

@@ -24,7 +24,9 @@ package com.dmdirc.commandparser.parsers;
24 24
 
25 25
 import com.dmdirc.Query;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
29
+import com.dmdirc.commandparser.CommandType;
28 30
 import com.dmdirc.commandparser.commands.ChatCommand;
29 31
 import com.dmdirc.commandparser.commands.Command;
30 32
 import com.dmdirc.commandparser.commands.GlobalCommand;
@@ -68,15 +70,16 @@ public final class QueryCommandParser extends CommandParser {
68 70
     }
69 71
     
70 72
     /** Loads the relevant commands into the parser. */
73
+    @Override
71 74
     protected void loadCommands() {
72
-        CommandManager.loadGlobalCommands(this);
73
-        CommandManager.loadServerCommands(this);
74
-        CommandManager.loadQueryCommands(this);
75
+        CommandManager.loadCommands(this, CommandType.TYPE_GLOBAL,
76
+                CommandType.TYPE_SERVER, CommandType.TYPE_QUERY);
75 77
     }
76 78
     
77 79
     /** {@inheritDoc} */
80
+    @Override
78 81
     protected void executeCommand(final InputWindow origin,
79
-            final boolean isSilent, final Command command, final String... args) {
82
+            final boolean isSilent, final Command command, final CommandArguments args) {
80 83
         if (command instanceof QueryCommand) {
81 84
             ((QueryCommand) command).execute(origin, server, query, isSilent, args);
82 85
         } else if (command instanceof ChatCommand) {
@@ -94,6 +97,7 @@ public final class QueryCommandParser extends CommandParser {
94 97
      * @param origin The window in which the command was typed
95 98
      * @param line The line input by the user
96 99
      */
100
+    @Override
97 101
     protected void handleNonCommand(final InputWindow origin, final String line) {
98 102
         query.sendLine(line);
99 103
     }

+ 7
- 3
src/com/dmdirc/commandparser/parsers/ServerCommandParser.java View File

@@ -23,7 +23,9 @@
23 23
 package com.dmdirc.commandparser.parsers;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
28
+import com.dmdirc.commandparser.CommandType;
27 29
 import com.dmdirc.commandparser.commands.Command;
28 30
 import com.dmdirc.commandparser.commands.GlobalCommand;
29 31
 import com.dmdirc.commandparser.commands.ServerCommand;
@@ -58,14 +60,15 @@ public final class ServerCommandParser extends CommandParser {
58 60
     }
59 61
     
60 62
     /** Loads the relevant commands into the parser. */
63
+    @Override
61 64
     protected void loadCommands() {
62
-        CommandManager.loadGlobalCommands(this);
63
-        CommandManager.loadServerCommands(this);
65
+        CommandManager.loadCommands(this, CommandType.TYPE_GLOBAL, CommandType.TYPE_SERVER);
64 66
     }
65 67
     
66 68
     /** {@inheritDoc} */
69
+    @Override
67 70
     protected void executeCommand(final InputWindow origin,
68
-            final boolean isSilent, final Command command, final String... args) {
71
+            final boolean isSilent, final Command command, final CommandArguments args) {
69 72
         if (command instanceof ServerCommand) {
70 73
             ((ServerCommand) command).execute(origin, server, isSilent, args);
71 74
         } else {
@@ -79,6 +82,7 @@ public final class ServerCommandParser extends CommandParser {
79 82
      * @param origin The window in which the command was typed
80 83
      * @param line The line input by the user
81 84
      */
85
+    @Override
82 86
     protected void handleNonCommand(final InputWindow origin, final String line) {
83 87
         server.sendLine(line);
84 88
     }

+ 4
- 0
src/com/dmdirc/config/defaults/default/defaults View File

@@ -163,7 +163,9 @@ ui:
163 163
   shownickcoloursintext=false
164 164
   showversion=true
165 165
   stylelinks=true
166
+  treeviewActiveBackground=false:f0f0f0
166 167
   treeviewActiveBold=true
168
+  treeviewActiveForeground=false:1
167 169
   treeviewRolloverColour=false:f0f0f0
168 170
   useOneTouchExpandable=false
169 171
   channelSplitPanePosition=150
@@ -172,6 +174,8 @@ treeview:
172 174
   dragSelection=true
173 175
   sortwindows=true
174 176
   sortservers=true
177
+  backgroundcolour=false:0
178
+  foregroundcolour=false:0
175 179
 
176 180
 channel:
177 181
   splitusermodes=false

+ 3
- 3
src/com/dmdirc/config/prefs/PreferencesManager.java View File

@@ -333,7 +333,7 @@ public class PreferencesManager {
333 333
         options.put("showWhenMaximised", "Show only when windows maximised");
334 334
 
335 335
         category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
336
-                "browser", "userlaunchdelay", "Use browser launch delay",
336
+                "browser", "uselaunchdelay", "Use browser launch delay",
337 337
                 "Enable delay between browser launches (to prevent mistakenly" +
338 338
                 " double clicking)?"));
339 339
         category.addSetting(new PreferencesSetting(PreferencesType.DURATION,
@@ -468,10 +468,10 @@ public class PreferencesManager {
468 468
                 "ui", "nickListAltBackgroundColour", "Alternate background colour",
469 469
                 "Background colour to use for every other nicklist entry"));
470 470
         category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
471
-                "ui", "sortByMode", "Sort nicklist by user mode",
471
+                "nicklist", "sortByMode", "Sort nicklist by user mode",
472 472
                 "Sort nicknames by the modes that they have?"));
473 473
         category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
474
-                "ui", "sortByCase", "Sort nicklist by case",
474
+                "nicklist", "sortByCase", "Sort nicklist by case",
475 475
                 "Sort nicknames in a case-sensitive manner?"));
476 476
 
477 477
         parent.addSubCategory(category);

+ 3
- 6
src/com/dmdirc/config/prefs/PreferencesSetting.java View File

@@ -299,12 +299,9 @@ public class PreferencesSetting {
299 299
      * @return true iif the setting will be changed if saved
300 300
      */
301 301
     public boolean needsSaving() {
302
-        if ((current != null && current.equals(original)) 
303
-                || (current == null && original == null)
304
-                || (validator != null && validator.validate(current).isFailure())) {
305
-            return false;
306
-        }
307
-        return true;
302
+        return (current == null || !current.equals(original))
303
+                && (current != null || original != null)
304
+                && (validator == null || !validator.validate(current).isFailure());
308 305
     }
309 306
 
310 307
 }

+ 1
- 1
test/com/dmdirc/IgnoreListTest.java View File

@@ -29,7 +29,7 @@ import org.junit.Test;
29 29
 import static org.junit.Assert.*;
30 30
 
31 31
 
32
-public class IgnoreListTest extends junit.framework.TestCase {
32
+public class IgnoreListTest {
33 33
     
34 34
     private final String[][] tests = {
35 35
         {"a@b.c", "a@b\\.c"},

+ 1
- 1
test/com/dmdirc/ProgramErrorTest.java View File

@@ -33,7 +33,7 @@ import org.junit.Before;
33 33
 import org.junit.Test;
34 34
 import static org.junit.Assert.*;
35 35
 
36
-public class ProgramErrorTest extends junit.framework.TestCase {
36
+public class ProgramErrorTest {
37 37
     
38 38
     private ErrorLevel level;
39 39
     private String message;

+ 1
- 1
test/com/dmdirc/StringTranscoderTest.java View File

@@ -29,7 +29,7 @@ import java.nio.charset.Charset;
29 29
 import org.junit.Test;
30 30
 import static org.junit.Assert.*;
31 31
 
32
-public class StringTranscoderTest extends junit.framework.TestCase {
32
+public class StringTranscoderTest {
33 33
 
34 34
     @Test
35 35
     public void testTranscode() {

+ 1
- 1
test/com/dmdirc/WritableFrameContainerTest.java View File

@@ -28,7 +28,7 @@ import java.util.Arrays;
28 28
 import org.junit.Test;
29 29
 import static org.junit.Assert.*;
30 30
 
31
-public class WritableFrameContainerTest extends junit.framework.TestCase {
31
+public class WritableFrameContainerTest {
32 32
     
33 33
     @Test
34 34
     public void testGetNumLines() {

+ 0
- 4
test/com/dmdirc/actions/ActionComparisonNamesTest.java View File

@@ -56,9 +56,5 @@ public class ActionComparisonNamesTest {
56 56
         
57 57
         return res;
58 58
     }
59
-    
60
-    public static junit.framework.Test suite() {
61
-        return new junit.framework.JUnit4TestAdapter(ActionComparisonNamesTest.class);
62
-    }    
63 59
 
64 60
 }

+ 4
- 5
test/com/dmdirc/actions/ActionComponentChainTest.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.actions;
24 24
 
25
+import com.dmdirc.config.IdentityManager;
26
+
25 27
 import org.junit.Before;
26 28
 import org.junit.Test;
27 29
 import static org.junit.Assert.*;
@@ -30,6 +32,7 @@ public class ActionComponentChainTest {
30 32
 
31 33
     @Before
32 34
     public void setUp() throws Exception {
35
+        IdentityManager.load();
33 36
         ActionManager.init();
34 37
     }
35 38
 
@@ -111,10 +114,6 @@ public class ActionComponentChainTest {
111 114
     public void testEmptyToString() {
112 115
         final ActionComponentChain chain = new ActionComponentChain(String.class, "");
113 116
         chain.toString();
114
-    }    
115
-    
116
-    public static junit.framework.Test suite() {
117
-        return new junit.framework.JUnit4TestAdapter(ActionComponentChainTest.class);
118
-    }    
117
+    }      
119 118
 
120 119
 }

+ 7
- 3
test/com/dmdirc/actions/ActionConditionTest.java View File

@@ -22,14 +22,18 @@
22 22
 
23 23
 package com.dmdirc.actions;
24 24
 
25
+import com.dmdirc.config.IdentityManager;
26
+
25 27
 import org.junit.Before;
28
+import org.junit.BeforeClass;
26 29
 import org.junit.Test;
27 30
 import static org.junit.Assert.*;
28 31
 
29
-public class ActionConditionTest extends junit.framework.TestCase {
32
+public class ActionConditionTest {
30 33
 
31
-    @Before
32
-    public void setUp() throws Exception {
34
+    @BeforeClass
35
+    public static void setUp() throws Exception {
36
+        IdentityManager.load();
33 37
         ActionManager.init();
34 38
     }
35 39
 

+ 1
- 1
test/com/dmdirc/actions/ActionGroupTest.java View File

@@ -30,7 +30,7 @@ import java.util.Map;
30 30
 import org.junit.Test;
31 31
 import static org.junit.Assert.*;
32 32
 
33
-public class ActionGroupTest extends junit.framework.TestCase {
33
+public class ActionGroupTest {
34 34
 
35 35
     @Test
36 36
     public void testGetAuthor() {

+ 5
- 3
test/com/dmdirc/actions/ActionManagerTest.java View File

@@ -22,6 +22,7 @@
22 22
 package com.dmdirc.actions;
23 23
 
24 24
 import com.dmdirc.actions.interfaces.ActionType;
25
+import com.dmdirc.config.IdentityManager;
25 26
 import java.io.File;
26 27
 
27 28
 import java.util.ArrayList;
@@ -30,17 +31,18 @@ import org.junit.BeforeClass;
30 31
 import org.junit.Test;
31 32
 import static org.junit.Assert.*;
32 33
 
33
-public class ActionManagerTest extends junit.framework.TestCase {
34
+public class ActionManagerTest {
34 35
     
35 36
     @BeforeClass
36
-    public void setUpClass() throws Exception {
37
+    public static void setUpClass() throws Exception {
38
+        IdentityManager.load();
37 39
         ActionManager.init();
38 40
         
39 41
         tearDownClass();
40 42
     }
41 43
     
42 44
     @AfterClass
43
-    public void tearDownClass() throws Exception {
45
+    public static void tearDownClass() throws Exception {
44 46
         if (ActionManager.getGroups().containsKey("unit-test")) {
45 47
             ActionManager.removeGroup("unit-test");
46 48
         }

+ 8
- 1
test/com/dmdirc/actions/ActionModelTest.java View File

@@ -23,15 +23,22 @@
23 23
 package com.dmdirc.actions;
24 24
 
25 25
 import com.dmdirc.actions.interfaces.ActionType;
26
+import com.dmdirc.config.IdentityManager;
26 27
 
27 28
 import java.util.ArrayList;
28 29
 import java.util.Arrays;
29 30
 import java.util.List;
30 31
 
32
+import org.junit.BeforeClass;
31 33
 import org.junit.Test;
32 34
 import static org.junit.Assert.*;
33 35
 
34
-public class ActionModelTest extends junit.framework.TestCase {
36
+public class ActionModelTest {
37
+
38
+    @BeforeClass
39
+    public static void setUpClass() {
40
+        IdentityManager.load();
41
+    }
35 42
 
36 43
     @Test
37 44
     public void testConditions() {

+ 4
- 3
test/com/dmdirc/actions/ActionTest.java View File

@@ -35,13 +35,14 @@ import java.util.ArrayList;
35 35
 import java.util.Arrays;
36 36
 
37 37
 import org.junit.Before;
38
+import org.junit.BeforeClass;
38 39
 import org.junit.Test;
39 40
 import static org.junit.Assert.*;
40 41
 
41
-public class ActionTest extends junit.framework.TestCase {
42
+public class ActionTest {
42 43
 
43
-    @Before
44
-    public void setUp() throws Exception {
44
+    @BeforeClass
45
+    public static void setUp() throws Exception {
45 46
         IdentityManager.load();
46 47
         ActionManager.init();
47 48
     }

+ 1
- 1
test/com/dmdirc/actions/ActionTypeComparatorTest.java View File

@@ -24,7 +24,7 @@ package com.dmdirc.actions;
24 24
 import org.junit.Test;
25 25
 import static org.junit.Assert.*;
26 26
 
27
-public class ActionTypeComparatorTest extends junit.framework.TestCase {
27
+public class ActionTypeComparatorTest {
28 28
 
29 29
     @Test
30 30
     public void testCompare() {

+ 1
- 1
test/com/dmdirc/actions/ConditionTreeTest.java View File

@@ -25,7 +25,7 @@ package com.dmdirc.actions;
25 25
 import org.junit.Test;
26 26
 import static org.junit.Assert.*;
27 27
 
28
-public class ConditionTreeTest extends junit.framework.TestCase {
28
+public class ConditionTreeTest {
29 29
 
30 30
     @Test
31 31
     public void testParseString() {

+ 1
- 1
test/com/dmdirc/actions/CoreActionComparisonTest.java View File

@@ -24,7 +24,7 @@ package com.dmdirc.actions;
24 24
 import org.junit.Test;
25 25
 import static org.junit.Assert.*;
26 26
 
27
-public class CoreActionComparisonTest extends junit.framework.TestCase {
27
+public class CoreActionComparisonTest {
28 28
 
29 29
     @Test
30 30
     public void testStringRegex() {

+ 1
- 1
test/com/dmdirc/actions/CoreActionTypeTest.java View File

@@ -25,7 +25,7 @@ import com.dmdirc.actions.metatypes.PluginEvents;
25 25
 import org.junit.Test;
26 26
 import static org.junit.Assert.*;
27 27
 
28
-public class CoreActionTypeTest extends junit.framework.TestCase {
28
+public class CoreActionTypeTest {
29 29
 
30 30
     @Test
31 31
     public void testGetName() {

+ 0
- 4
test/com/dmdirc/actions/StringComponentsTest.java View File

@@ -79,9 +79,5 @@ public class StringComponentsTest {
79 79
             {"abc foo def", "foo"}
80 80
         });
81 81
     }
82
-    
83
-    public static junit.framework.Test suite() {
84
-        return new junit.framework.JUnit4TestAdapter(StringComponentsTest.class);
85
-    }    
86 82
 
87 83
 }

+ 1
- 1
test/com/dmdirc/actions/metatypes/ActionEventsTest.java View File

@@ -25,7 +25,7 @@ import com.dmdirc.actions.interfaces.ActionMetaType;
25 25
 import org.junit.Test;
26 26
 import static org.junit.Assert.*;
27 27
 
28
-public class ActionEventsTest extends junit.framework.TestCase {
28
+public class ActionEventsTest {
29 29
 
30 30
     @Test
31 31
     public void testArity() {

+ 1
- 1
test/com/dmdirc/actions/metatypes/ChannelEventsTest.java View File

@@ -24,7 +24,7 @@ package com.dmdirc.actions.metatypes;
24 24
 import org.junit.Test;
25 25
 import static org.junit.Assert.*;
26 26
 
27
-public class ChannelEventsTest extends junit.framework.TestCase {
27
+public class ChannelEventsTest {
28 28
 
29 29
     @Test
30 30
     public void testArity() {

+ 1
- 1
test/com/dmdirc/actions/metatypes/ClientEventsTest.java View File

@@ -24,7 +24,7 @@ package com.dmdirc.actions.metatypes;
24 24
 import org.junit.Test;
25 25
 import static org.junit.Assert.*;
26 26
 
27
-public class ClientEventsTest extends junit.framework.TestCase {
27
+public class ClientEventsTest {
28 28
 
29 29
     @Test
30 30
     public void testArity() {

+ 1
- 1
test/com/dmdirc/actions/metatypes/PluginEventsTest.java View File

@@ -24,7 +24,7 @@ package com.dmdirc.actions.metatypes;
24 24
 import org.junit.Test;
25 25
 import static org.junit.Assert.*;
26 26
 
27
-public class PluginEventsTest extends junit.framework.TestCase {
27
+public class PluginEventsTest {
28 28
 
29 29
     @Test
30 30
     public void testArity() {

+ 1
- 1
test/com/dmdirc/actions/metatypes/QueryEventsTest.java View File

@@ -24,7 +24,7 @@ package com.dmdirc.actions.metatypes;
24 24
 import org.junit.Test;
25 25
 import static org.junit.Assert.*;
26 26
 
27
-public class QueryEventsTest extends junit.framework.TestCase {
27
+public class QueryEventsTest {
28 28
 
29 29
     @Test
30 30
     public void testArity() {

+ 0
- 0
test/com/dmdirc/actions/metatypes/ServerEventsTest.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save