1 /* 2 * aTunes 3 * Copyright (C) Alex Aranda, Sylvain Gaudard and contributors 4 * 5 * See http://www.atunes.org/wiki/index.php?title=Contributing for information about contributors 6 * 7 * http://www.atunes.org 8 * http://sourceforge.net/projects/atunes 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License 12 * as published by the Free Software Foundation; either version 2 13 * of the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 */ 20 21 package net.sourceforge.atunes.model; 22 23 24 /** 25 * Handles and executes commands received 26 * @author alex 27 * 28 */ 29 public interface ICommandHandler extends IHandler { 30 31 /** 32 * Adds a command to the map of commands ready to be used 33 * 34 * @param cmd 35 */ registerCommand(ICommand cmd)36 public void registerCommand(ICommand cmd); 37 38 /** 39 * Removed command from map of commands ready to be used 40 * 41 * @param cmd 42 */ unregisterCommand(ICommand cmd)43 public void unregisterCommand(ICommand cmd); 44 45 /** 46 * Parses commandline to search for commands and execute them. Return of 47 * command is ignored This method is created to run commands without sending 48 * it to another instance 49 * 50 * @param commandline 51 */ runCommands(String commandline)52 public void runCommands(String commandline); 53 54 /** 55 * Returns <code>true</code> if the given string is a valid command: has 56 * correct syntax and exists 57 * 58 * @param commandName 59 * @return 60 */ isValidCommand(String commandName)61 public boolean isValidCommand(String commandName); 62 63 /** 64 * Returns <code>true</code> if the given string has correct command syntax 65 * 66 * @param commandName 67 * @return 68 */ isCommand(String commandName)69 public boolean isCommand(String commandName); 70 71 /** 72 * Identifies and executes given command 73 * 74 * @param commandName 75 * @return command output 76 */ processAndRun(String commandName)77 public String processAndRun(String commandName); 78 79 }