/** * Returns a nice formated String of the Commands this class handles * * @return */ protected final String getCommandsAsString() { String res = ""; for (Cmd c : mCommandMap.values()) { res += c.getName(); if (c.getAlias().length > 0) { res += " ("; for (String s : c.getAlias()) { res += s + ", "; } res = res.substring(0, res.length() - 2) + ")"; } res += ", "; } return res; }
CommandHandlerBase(MainService mainService, int cmdType, Object... commands) { if (sMainService == null) { sMainService = mainService; sSettingsMgr = SettingsManager.getSettingsManager(sContext); sContext = mainService.getBaseContext(); Cmd.setContext(sContext); } mCommandMap = new HashMap<String, Cmd>(); for (Object o : commands) { Cmd c = (Cmd) o; mCommandMap.put(c.getName(), c); } mCmdType = cmdType; mAnswerTo = null; initializeSubCommands(); }
public boolean isMatchingCmd(String cmdName, String input) { Cmd cmd = getCommand(input); return cmd != null && cmd.getName().equals(cmdName); }