From 6490246da875f3946b5f74e1c1971786e71fd7c7 Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Mon, 18 Mar 2013 08:41:46 +0000 Subject: [PATCH] Cleans up source code, provides tiny optimization. --- .../CommandNotificationHandlerImpl.java | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/net/java/sip/communicator/impl/notification/CommandNotificationHandlerImpl.java b/src/net/java/sip/communicator/impl/notification/CommandNotificationHandlerImpl.java index fd4a877d5..0794c9d62 100644 --- a/src/net/java/sip/communicator/impl/notification/CommandNotificationHandlerImpl.java +++ b/src/net/java/sip/communicator/impl/notification/CommandNotificationHandlerImpl.java @@ -16,12 +16,16 @@ /** * An implementation of the CommandNotificationHandler interface. - * + * * @author Yana Stamcheva */ public class CommandNotificationHandlerImpl implements CommandNotificationHandler { + /** + * The Logger used by this CommandNotificationHandlerImpl + * instance to log debugging information. + */ private Logger logger = Logger.getLogger(CommandNotificationHandlerImpl.class); @@ -34,30 +38,29 @@ public String getActionType() } /** - * Executes the command, given by the commandDescriptor of the - * action. - * + * Executes the command, given by the descriptor of a specific + * CommandNotificationAction. + * * @param action the action to act upon. * @param cmdargs command-line arguments. */ - public void execute(CommandNotificationAction action, - Map cmdargs) + public void execute( + CommandNotificationAction action, + Map cmdargs) { - if(StringUtils.isNullOrEmpty(action.getDescriptor(), true)) + String actionDescriptor = action.getDescriptor(); + + if(StringUtils.isNullOrEmpty(actionDescriptor, true)) return; - String actionDescriptor = action.getDescriptor(); if (cmdargs != null) { - for (Map.Entry entry : cmdargs.entrySet()) + for (Map.Entry cmdarg : cmdargs.entrySet()) { - if(actionDescriptor.indexOf("${" + entry.getKey() + "}") != -1) - { - actionDescriptor = actionDescriptor.replace( - "${" + entry.getKey() + "}", - entry.getValue() - ); - } + actionDescriptor + = actionDescriptor.replace( + "${" + cmdarg.getKey() + "}", + cmdarg.getValue()); } } @@ -65,10 +68,12 @@ public void execute(CommandNotificationAction action, { Runtime.getRuntime().exec(actionDescriptor); } - catch (IOException e) + catch (IOException ioe) { - logger.error("Failed execute the following command: " - + action.getDescriptor(), e); + logger.error( + "Failed to execute the following command: " + + action.getDescriptor(), + ioe); } } }