|
@@ -41,10 +41,13 @@ import com.dmdirc.config.IdentityManager;
|
41
|
41
|
import com.dmdirc.logger.ErrorLevel;
|
42
|
42
|
import com.dmdirc.logger.Logger;
|
43
|
43
|
import com.dmdirc.ui.input.TabCompleter;
|
|
44
|
+import com.dmdirc.util.MapList;
|
44
|
45
|
import com.dmdirc.util.WeakList;
|
45
|
46
|
|
46
|
47
|
import java.util.ArrayList;
|
|
48
|
+import java.util.HashMap;
|
47
|
49
|
import java.util.List;
|
|
50
|
+import java.util.Map;
|
48
|
51
|
|
49
|
52
|
/**
|
50
|
53
|
* The command manager creates and manages a single instance of all commands,
|
|
@@ -54,44 +57,14 @@ import java.util.List;
|
54
|
57
|
*/
|
55
|
58
|
public final class CommandManager {
|
56
|
59
|
|
57
|
|
- /**
|
58
|
|
- * The global commands that have been instansiated.
|
59
|
|
- */
|
60
|
|
- private static final List<Command> globalCommands = new ArrayList<Command>();
|
61
|
|
- /**
|
62
|
|
- * The server commands that have been instansiated.
|
63
|
|
- */
|
64
|
|
- private static final List<Command> serverCommands = new ArrayList<Command>();
|
65
|
|
- /**
|
66
|
|
- * The channel commands that have been instansiated.
|
67
|
|
- */
|
68
|
|
- private static final List<Command> channelCommands = new ArrayList<Command>();
|
69
|
|
- /**
|
70
|
|
- * The query commands that have been instansiated.
|
71
|
|
- */
|
72
|
|
- private static final List<Command> queryCommands = new ArrayList<Command>();
|
73
|
|
- /**
|
74
|
|
- * The "chat" commands that have been instansiated.
|
75
|
|
- */
|
76
|
|
- private static final List<Command> chatCommands = new ArrayList<Command>();
|
77
|
|
-
|
78
|
|
- /**
|
79
|
|
- * The parsers that have requested global commands.
|
80
|
|
- */
|
81
|
|
- private static final List<CommandParser> globalParsers = new WeakList<CommandParser>();
|
82
|
|
- /**
|
83
|
|
- * The parsers that have requested server commands.
|
84
|
|
- */
|
85
|
|
- private static final List<CommandParser> serverParsers = new WeakList<CommandParser>();
|
86
|
|
- /**
|
87
|
|
- * The parsers that have requested channel commands.
|
88
|
|
- */
|
89
|
|
- private static final List<CommandParser> channelParsers = new WeakList<CommandParser>();
|
90
|
|
- /**
|
91
|
|
- * The parsers that have requested query commands.
|
92
|
|
- */
|
93
|
|
- private static final List<CommandParser> queryParsers = new WeakList<CommandParser>();
|
|
60
|
+ /** A list of commands that have been instansiated. */
|
|
61
|
+ private static final Map<CommandInfo, Command> commands
|
|
62
|
+ = new HashMap<CommandInfo, Command>();
|
94
|
63
|
|
|
64
|
+ /** A list of command parsers that have been instansiated. */
|
|
65
|
+ private static final MapList<CommandType, CommandParser> parsers
|
|
66
|
+ = new MapList<CommandType, CommandParser>();
|
|
67
|
+
|
95
|
68
|
/**
|
96
|
69
|
* Channel commands that have been registered to appear in the nicklist
|
97
|
70
|
* popup.
|
|
@@ -160,21 +133,16 @@ public final class CommandManager {
|
160
|
133
|
boolean canContinue = true;
|
161
|
134
|
|
162
|
135
|
if (command instanceof ChannelCommand) {
|
163
|
|
- registerCommand(command, channelParsers, register);
|
164
|
|
- channelCommands.add(command);
|
|
136
|
+ registerCommand(command, parsers.get(CommandType.TYPE_CHANNEL), register);
|
165
|
137
|
} else if (command instanceof ServerCommand) {
|
166
|
|
- registerCommand(command, serverParsers, register);
|
167
|
|
- serverCommands.add(command);
|
|
138
|
+ registerCommand(command, parsers.get(CommandType.TYPE_SERVER), register);
|
168
|
139
|
} else if (command instanceof QueryCommand) {
|
169
|
|
- registerCommand(command, queryParsers, register);
|
170
|
|
- queryCommands.add(command);
|
|
140
|
+ registerCommand(command, parsers.get(CommandType.TYPE_QUERY), register);
|
171
|
141
|
} else if (command instanceof GlobalCommand) {
|
172
|
|
- registerCommand(command, globalParsers, register);
|
173
|
|
- globalCommands.add(command);
|
|
142
|
+ registerCommand(command, parsers.get(CommandType.TYPE_GLOBAL), register);
|
174
|
143
|
} else if (command instanceof ChatCommand) {
|
175
|
|
- registerCommand(command, queryParsers, register);
|
176
|
|
- registerCommand(command, channelParsers, register);
|
177
|
|
- chatCommands.add(command);
|
|
144
|
+ registerCommand(command, parsers.get(CommandType.TYPE_QUERY), register);
|
|
145
|
+ registerCommand(command, parsers.get(CommandType.TYPE_CHANNEL), register);
|
178
|
146
|
} else {
|
179
|
147
|
canContinue = false;
|
180
|
148
|
|
|
@@ -183,6 +151,7 @@ public final class CommandManager {
|
183
|
151
|
}
|
184
|
152
|
|
185
|
153
|
if (canContinue) {
|
|
154
|
+ commands.put(command, command);
|
186
|
155
|
registerCommandName(command, register);
|
187
|
156
|
}
|
188
|
157
|
}
|
|
@@ -194,7 +163,11 @@ public final class CommandManager {
|
194
|
163
|
* @param parsers The parsers to register the command with
|
195
|
164
|
*/
|
196
|
165
|
private static void registerCommand(final Command command,
|
197
|
|
- final List<CommandParser> parsers, final boolean register) {
|
|
166
|
+ final List<? extends CommandParser> parsers, final boolean register) {
|
|
167
|
+ if (parsers == null) {
|
|
168
|
+ return;
|
|
169
|
+ }
|
|
170
|
+
|
198
|
171
|
for (CommandParser parser : parsers) {
|
199
|
172
|
if (register) {
|
200
|
173
|
parser.registerCommand(command);
|
|
@@ -224,13 +197,15 @@ public final class CommandManager {
|
224
|
197
|
|
225
|
198
|
if (command instanceof ChannelCommand || command instanceof ChatCommand) {
|
226
|
199
|
for (String channelName : server.getChannels()) {
|
227
|
|
- registerCommandName(server.getChannel(channelName).getTabCompleter(), commandName, register);
|
|
200
|
+ registerCommandName(server.getChannel(channelName).getTabCompleter(),
|
|
201
|
+ commandName, register);
|
228
|
202
|
}
|
229
|
203
|
}
|
230
|
204
|
|
231
|
205
|
if (command instanceof QueryCommand || command instanceof ChatCommand) {
|
232
|
206
|
for (String queryName : server.getQueries()) {
|
233
|
|
- registerCommandName(server.getQuery(queryName).getTabCompleter(), commandName, register);
|
|
207
|
+ registerCommandName(server.getQuery(queryName).getTabCompleter(),
|
|
208
|
+ commandName, register);
|
234
|
209
|
}
|
235
|
210
|
}
|
236
|
211
|
}
|
|
@@ -284,12 +259,9 @@ public final class CommandManager {
|
284
|
259
|
new Ban();
|
285
|
260
|
new ChannelSettings();
|
286
|
261
|
new Cycle();
|
287
|
|
- new Kick();
|
288
|
|
- new KickEmpty();
|
289
|
262
|
new KickReason();
|
290
|
263
|
new Mode();
|
291
|
264
|
new Part();
|
292
|
|
- new PartDefault();
|
293
|
265
|
new SetNickColour();
|
294
|
266
|
new SetTopic();
|
295
|
267
|
new ShowTopic();
|
|
@@ -327,7 +299,6 @@ public final class CommandManager {
|
327
|
299
|
new Debug();
|
328
|
300
|
new Echo();
|
329
|
301
|
new Exit();
|
330
|
|
- new ExitDefault();
|
331
|
302
|
new Ifplugin();
|
332
|
303
|
new NewServer();
|
333
|
304
|
new Notify();
|
|
@@ -360,15 +331,15 @@ public final class CommandManager {
|
360
|
331
|
* @param parser The parser to load commands into
|
361
|
332
|
*/
|
362
|
333
|
public static void loadChannelCommands(final CommandParser parser) {
|
363
|
|
- for (Command com : channelCommands) {
|
|
334
|
+ for (Command com : getCommands(CommandType.TYPE_CHANNEL, null, null)) {
|
364
|
335
|
parser.registerCommand(com);
|
365
|
336
|
}
|
366
|
337
|
|
367
|
|
- for (Command com : chatCommands) {
|
|
338
|
+ for (Command com : getCommands(CommandType.TYPE_CHAT, null, null)) {
|
368
|
339
|
parser.registerCommand(com);
|
369
|
340
|
}
|
370
|
341
|
|
371
|
|
- channelParsers.add(parser);
|
|
342
|
+ parsers.add(CommandType.TYPE_CHANNEL, parser);
|
372
|
343
|
}
|
373
|
344
|
|
374
|
345
|
/**
|
|
@@ -377,11 +348,11 @@ public final class CommandManager {
|
377
|
348
|
* @param parser The parser to load commands into
|
378
|
349
|
*/
|
379
|
350
|
public static void loadServerCommands(final CommandParser parser) {
|
380
|
|
- for (Command command : serverCommands) {
|
|
351
|
+ for (Command command : getCommands(CommandType.TYPE_SERVER, null, null)) {
|
381
|
352
|
parser.registerCommand(command);
|
382
|
353
|
}
|
383
|
354
|
|
384
|
|
- serverParsers.add(parser);
|
|
355
|
+ parsers.add(CommandType.TYPE_SERVER, parser);
|
385
|
356
|
}
|
386
|
357
|
|
387
|
358
|
/**
|
|
@@ -390,11 +361,11 @@ public final class CommandManager {
|
390
|
361
|
* @param parser The parser to load commands into
|
391
|
362
|
*/
|
392
|
363
|
public static void loadGlobalCommands(final CommandParser parser) {
|
393
|
|
- for (Command com : globalCommands) {
|
|
364
|
+ for (Command com : getCommands(CommandType.TYPE_GLOBAL, null, null)) {
|
394
|
365
|
parser.registerCommand(com);
|
395
|
366
|
}
|
396
|
367
|
|
397
|
|
- globalParsers.add(parser);
|
|
368
|
+ parsers.add(CommandType.TYPE_GLOBAL, parser);
|
398
|
369
|
}
|
399
|
370
|
|
400
|
371
|
/**
|
|
@@ -403,15 +374,15 @@ public final class CommandManager {
|
403
|
374
|
* @param parser The parser to load commands into
|
404
|
375
|
*/
|
405
|
376
|
public static void loadQueryCommands(final CommandParser parser) {
|
406
|
|
- for (Command com : queryCommands) {
|
|
377
|
+ for (Command com : getCommands(CommandType.TYPE_QUERY, null, null)) {
|
407
|
378
|
parser.registerCommand(com);
|
408
|
379
|
}
|
409
|
380
|
|
410
|
|
- for (Command com : chatCommands) {
|
|
381
|
+ for (Command com : getCommands(CommandType.TYPE_CHAT, null, null)) {
|
411
|
382
|
parser.registerCommand(com);
|
412
|
383
|
}
|
413
|
384
|
|
414
|
|
- queryParsers.add(parser);
|
|
385
|
+ parsers.add(CommandType.TYPE_QUERY, parser);
|
415
|
386
|
}
|
416
|
387
|
|
417
|
388
|
/**
|
|
@@ -422,195 +393,16 @@ public final class CommandManager {
|
422
|
393
|
* @return A command with a matching signature, or null if none were found
|
423
|
394
|
*/
|
424
|
395
|
public static Command getCommand(final String name) {
|
425
|
|
- if (getGlobalCommandByName(name) != null) {
|
426
|
|
- return getGlobalCommandByName(name);
|
427
|
|
- } else if (getServerCommandByName(name) != null) {
|
428
|
|
- return getServerCommandByName(name);
|
429
|
|
- } else if (getChannelCommandByName(name) != null) {
|
430
|
|
- return getChannelCommandByName(name);
|
431
|
|
- } else if (getChatCommandByName(name) != null) {
|
432
|
|
- return getChatCommandByName(name);
|
433
|
|
- } else {
|
434
|
|
- return getChannelCommandByName(name);
|
435
|
|
- }
|
436
|
|
- }
|
437
|
|
-
|
438
|
|
- /**
|
439
|
|
- * Retrieves the server command identified by the specified signature.
|
440
|
|
- *
|
441
|
|
- * @param signature The signature to look for
|
442
|
|
- * @return A server command with a matching signature, or null if none
|
443
|
|
- * were found.
|
444
|
|
- */
|
445
|
|
- public static ServerCommand getServerCommand(final String signature) {
|
446
|
|
- for (Command com : serverCommands) {
|
447
|
|
- if (com.getSignature().equalsIgnoreCase(signature)) {
|
448
|
|
- return (ServerCommand) com;
|
449
|
|
- }
|
450
|
|
- }
|
451
|
|
-
|
452
|
|
- return null;
|
453
|
|
- }
|
454
|
|
-
|
455
|
|
- /**
|
456
|
|
- * Retrieves the server command identified by the specified name.
|
457
|
|
- *
|
458
|
|
- * @param name The name to look for
|
459
|
|
- * @return A server command with a matching name, or null if none were found
|
460
|
|
- */
|
461
|
|
- public static ServerCommand getServerCommandByName(final String name) {
|
462
|
|
- return (ServerCommand) getCommandByName(name, serverCommands);
|
463
|
|
- }
|
464
|
|
-
|
465
|
|
- /**
|
466
|
|
- * Retrieves the global command identified by the specified signature.
|
467
|
|
- *
|
468
|
|
- * @param signature The signature to look for
|
469
|
|
- * @return A global command with a matching signature, or null if none
|
470
|
|
- * were found.
|
471
|
|
- */
|
472
|
|
- public static GlobalCommand getGlobalCommand(final String signature) {
|
473
|
|
- for (Command com : globalCommands) {
|
474
|
|
- if (com.getSignature().equalsIgnoreCase(signature)) {
|
475
|
|
- return (GlobalCommand) com;
|
476
|
|
- }
|
477
|
|
- }
|
478
|
|
-
|
479
|
|
- return null;
|
480
|
|
- }
|
481
|
|
-
|
482
|
|
- /**
|
483
|
|
- * Retrieves the global command identified by the specified name.
|
484
|
|
- *
|
485
|
|
- * @param name The name to look for
|
486
|
|
- * @return A global command with a matching name, or null if none were found
|
487
|
|
- */
|
488
|
|
- public static GlobalCommand getGlobalCommandByName(final String name) {
|
489
|
|
- return (GlobalCommand) getCommandByName(name, globalCommands);
|
490
|
|
- }
|
491
|
|
-
|
492
|
|
- /**
|
493
|
|
- * Retrieves the channel command identified by the specified signature.
|
494
|
|
- *
|
495
|
|
- * @param signature The signature to look for
|
496
|
|
- * @return A channel command with a matching signature, or null if none
|
497
|
|
- * were found.
|
498
|
|
- */
|
499
|
|
- public static ChannelCommand getChannelCommand(final String signature) {
|
500
|
|
- for (Command com : channelCommands) {
|
501
|
|
- if (com.getSignature().equalsIgnoreCase(signature)) {
|
502
|
|
- return (ChannelCommand) com;
|
503
|
|
- }
|
504
|
|
- }
|
505
|
|
-
|
506
|
|
- return null;
|
507
|
|
- }
|
508
|
|
-
|
509
|
|
- /**
|
510
|
|
- * Retrieves the channel command identified by the specified name.
|
511
|
|
- *
|
512
|
|
- * @param name The name to look for
|
513
|
|
- * @return A channel command with a matching name, or null if none were found
|
514
|
|
- */
|
515
|
|
- public static ChannelCommand getChannelCommandByName(final String name) {
|
516
|
|
- return (ChannelCommand) getCommandByName(name, channelCommands);
|
517
|
|
- }
|
518
|
|
-
|
519
|
|
- /**
|
520
|
|
- * Retrieves the chat command identified by the specified signature.
|
521
|
|
- *
|
522
|
|
- * @param signature The signature to look for
|
523
|
|
- * @return A chat command with a matching signature, or null if none
|
524
|
|
- * were found.
|
525
|
|
- */
|
526
|
|
- public static ChatCommand getChatCommand(final String signature) {
|
527
|
|
- for (Command com : chatCommands) {
|
528
|
|
- if (com.getSignature().equalsIgnoreCase(signature)) {
|
529
|
|
- return (ChatCommand) com;
|
530
|
|
- }
|
531
|
|
- }
|
532
|
|
-
|
533
|
|
- return null;
|
534
|
|
- }
|
535
|
|
-
|
536
|
|
- /**
|
537
|
|
- * Retrieves the chat command identified by the specified name.
|
538
|
|
- *
|
539
|
|
- * @param name The name to look for
|
540
|
|
- * @return A chat command with a matching name, or null if none were found
|
541
|
|
- */
|
542
|
|
- public static ChatCommand getChatCommandByName(final String name) {
|
543
|
|
- return (ChatCommand) getCommandByName(name, chatCommands);
|
|
396
|
+ return getCommand(null, name, null);
|
544
|
397
|
}
|
545
|
398
|
|
546
|
|
- /**
|
547
|
|
- * Retrieves the command identified by the specified name.
|
548
|
|
- *
|
549
|
|
- * @param name The name to look for
|
550
|
|
- * @param list The list to look in
|
551
|
|
- * @return A command with a matching name, or null if none were found
|
552
|
|
- */
|
553
|
|
- private static Command getCommandByName(final String name,
|
554
|
|
- final List<Command> list) {
|
555
|
|
- for (Command com : list) {
|
556
|
|
- if (com.getName().equalsIgnoreCase(name)) {
|
557
|
|
- return com;
|
558
|
|
- }
|
559
|
|
- }
|
|
399
|
+ public static Command getCommand(final CommandType type, final String name,
|
|
400
|
+ final String signature) {
|
|
401
|
+ final List<Command> res = getCommands(type, name, signature);
|
560
|
402
|
|
561
|
|
- return null;
|
562
|
|
- }
|
563
|
|
-
|
564
|
|
- /**
|
565
|
|
- * Returns a list containing the global commands that have been initialised
|
566
|
|
- * by this command manager.
|
567
|
|
- *
|
568
|
|
- * @return An ArrayList of global commands, or null if none have been loaded
|
569
|
|
- */
|
570
|
|
- public static List<Command> getGlobalCommands() {
|
571
|
|
- return globalCommands;
|
572
|
|
- }
|
573
|
|
-
|
574
|
|
- /**
|
575
|
|
- * Returns a list containing the server commands that have been initialised
|
576
|
|
- * by this command manager.
|
577
|
|
- *
|
578
|
|
- * @return An ArrayList of server commands, or null if none have been loaded
|
579
|
|
- */
|
580
|
|
- public static List<Command> getServerCommands() {
|
581
|
|
- return serverCommands;
|
582
|
|
- }
|
583
|
|
-
|
584
|
|
- /**
|
585
|
|
- * Returns a list containing the channel commands that have been initialised
|
586
|
|
- * by this command manager.
|
587
|
|
- *
|
588
|
|
- * @return An ArrayList of channel commands, or null if none have been loaded
|
589
|
|
- */
|
590
|
|
- public static List<Command> getChannelCommands() {
|
591
|
|
- return channelCommands;
|
592
|
|
- }
|
593
|
|
-
|
594
|
|
- /**
|
595
|
|
- * Returns a list containing the chat commands that have been initialised
|
596
|
|
- * by this command manager.
|
597
|
|
- *
|
598
|
|
- * @return An ArrayList of chat commands, or null if none have been loaded
|
599
|
|
- */
|
600
|
|
- public static List<Command> getChatCommands() {
|
601
|
|
- return chatCommands;
|
602
|
|
- }
|
603
|
|
-
|
604
|
|
- /**
|
605
|
|
- * Returns a list containing the query commands that have been initialised
|
606
|
|
- * by this command manager.
|
607
|
|
- *
|
608
|
|
- * @return An ArrayList of query commands, or null if none have been loaded
|
609
|
|
- */
|
610
|
|
- public static List<Command> getQueryCommands() {
|
611
|
|
- return queryCommands;
|
612
|
|
- }
|
613
|
|
-
|
|
403
|
+ return res.isEmpty() ? null : res.get(0);
|
|
404
|
+ }
|
|
405
|
+
|
614
|
406
|
/**
|
615
|
407
|
* Determines if the specified command is a valid channel command.
|
616
|
408
|
*
|
|
@@ -618,90 +410,34 @@ public final class CommandManager {
|
618
|
410
|
* @return True iff the command is a channel command, false otherwise
|
619
|
411
|
*/
|
620
|
412
|
public static boolean isChannelCommand(final String command) {
|
621
|
|
- for (Command chanCommand : channelCommands) {
|
622
|
|
- if (chanCommand.getName().equalsIgnoreCase(command)) {
|
623
|
|
- return true;
|
624
|
|
- }
|
625
|
|
- }
|
|
413
|
+ return getCommand(CommandType.TYPE_CHANNEL, command, null) != null
|
|
414
|
+ || getCommand(CommandType.TYPE_CHAT, command, null) != null;
|
|
415
|
+ }
|
|
416
|
+
|
|
417
|
+ public static List<String> getCommandNames(final CommandType type) {
|
|
418
|
+ final List<String> res = new ArrayList<String>();
|
626
|
419
|
|
627
|
|
- for (Command chanCommand : chatCommands) {
|
628
|
|
- if (chanCommand.getName().equalsIgnoreCase(command)) {
|
629
|
|
- return true;
|
630
|
|
- }
|
|
420
|
+ for (Command command : getCommands(type, null, null)) {
|
|
421
|
+ res.add(getCommandChar() + command.getName());
|
631
|
422
|
}
|
632
|
423
|
|
633
|
|
- return false;
|
634
|
|
- }
|
635
|
|
-
|
636
|
|
- /**
|
637
|
|
- * Returns the names (including command char) of all registered server
|
638
|
|
- * commands.
|
639
|
|
- *
|
640
|
|
- * @return An ArrayList<String> containing all registered server command
|
641
|
|
- * names
|
642
|
|
- */
|
643
|
|
- public static List<String> getServerCommandNames() {
|
644
|
|
- return getCommandNames(serverCommands);
|
645
|
|
- }
|
646
|
|
-
|
647
|
|
- /**
|
648
|
|
- * Returns the names (including command char) of all registered global
|
649
|
|
- * commands.
|
650
|
|
- *
|
651
|
|
- * @return An ArrayList<String> containing all registered global command
|
652
|
|
- * names
|
653
|
|
- */
|
654
|
|
- public static List<String> getGlobalCommandNames() {
|
655
|
|
- return getCommandNames(globalCommands);
|
656
|
|
- }
|
657
|
|
-
|
658
|
|
- /**
|
659
|
|
- * Returns the names (including command char) of all registered channel
|
660
|
|
- * commands.
|
661
|
|
- *
|
662
|
|
- * @return A list containing all registered channel command names
|
663
|
|
- */
|
664
|
|
- public static List<String> getChannelCommandNames() {
|
665
|
|
- return getCommandNames(channelCommands);
|
666
|
|
- }
|
667
|
|
-
|
668
|
|
- /**
|
669
|
|
- * Returns the names (including command char) of all registered query
|
670
|
|
- * commands.
|
671
|
|
- *
|
672
|
|
- * @return A list containing all registered query command names
|
673
|
|
- */
|
674
|
|
- public static List<String> getQueryCommandNames() {
|
675
|
|
- return getCommandNames(queryCommands);
|
|
424
|
+ return res;
|
676
|
425
|
}
|
677
|
426
|
|
678
|
|
- /**
|
679
|
|
- * Returns the names (including command char) of all registered chat
|
680
|
|
- * commands.
|
681
|
|
- *
|
682
|
|
- * @return An ArrayList<String> containing all registered chat command
|
683
|
|
- * names
|
684
|
|
- */
|
685
|
|
- public static List<String> getChatCommandNames() {
|
686
|
|
- return getCommandNames(chatCommands);
|
|
427
|
+ public static List<Command> getCommands(final CommandType type) {
|
|
428
|
+ return getCommands(type, null, null);
|
687
|
429
|
}
|
688
|
430
|
|
689
|
|
- /**
|
690
|
|
- * Iterates through the specified source and returns a list of the names
|
691
|
|
- * of all commands found in it.
|
692
|
|
- *
|
693
|
|
- * @param source The source vector to iterate over
|
694
|
|
- * @return A list of all commands in the source
|
695
|
|
- */
|
696
|
|
- private static List<String> getCommandNames(final List<Command> source) {
|
697
|
|
- if (source == null) {
|
698
|
|
- return null;
|
699
|
|
- }
|
|
431
|
+ private static List<Command> getCommands(final CommandType type,
|
|
432
|
+ final String name, final String signature) {
|
|
433
|
+ final List<Command> res = new ArrayList<Command>();
|
700
|
434
|
|
701
|
|
- final List<String> res = new ArrayList<String>();
|
702
|
|
-
|
703
|
|
- for (Command command : source) {
|
704
|
|
- res.add(getCommandChar() + command.getName());
|
|
435
|
+ for (Map.Entry<CommandInfo, Command> entry : commands.entrySet()) {
|
|
436
|
+ if ((type == null || type.equals(entry.getKey().getType()))
|
|
437
|
+ && (name == null || name.equals(entry.getKey().getName()))
|
|
438
|
+ && (signature == null || signature.equals(entry.getKey().getSignature()))) {
|
|
439
|
+ res.add(entry.getValue());
|
|
440
|
+ }
|
705
|
441
|
}
|
706
|
442
|
|
707
|
443
|
return res;
|