1 package org.lsst.ccs.command;
2
3
4
5
6
7 public class RoutingCommandSet implements CommandSet {
8
9 RoutingDictionary dict = new RoutingDictionary();
10
11 public void add(String route, CommandSet cs) {
12 Dictionary subDict = cs.getCommandDictionary();
13 dict.add(route, subDict);
14 }
15
16 public void remove(String route) {
17 dict.remove(route);
18 }
19
20 @Override
21 public Dictionary getCommandDictionary() {
22 return dict;
23 }
24
25 @Override
26 public Object invoke(BasicCommand command) throws CommandInvocationException {
27 DictionaryCommand dc = dict.findCommand(command);
28 if (dc == null) {
29 throw new CommandInvocationException("Error: No handler found for command %s with %d arguments",command.getCommand(),command.getArgumentCount());
30 }
31 return null;
32 }
33
34 }