FileDocCategorySizeDatePackage
CommandCollection.javaAPI DocAzureus 3.0.3.43195Tue Sep 06 06:46:52 BST 2005org.gudy.azureus2.ui.console.commands

CommandCollection

public class CommandCollection extends Object
this class represents a collection of commands. it can be used by command objects to house their subcommands. when execute() method is called, the appropriate subcommand is looked up and executed
author
pauld

Fields Summary
private final Map
subCommands
Constructors Summary
Methods Summary
public voidadd(IConsoleCommand command)
adds the specified console command as a subcommand to this object. we will therefore respond to all of the subcommands command names when passed as the first argument to this command

param
command

		for (Iterator iter = command.getCommandNames().iterator(); iter.hasNext();) {
			String cmdName = (String) iter.next();
			subCommands.put(cmdName, command);
		}
	
public voidexecute(java.lang.String commandName, org.gudy.azureus2.ui.console.ConsoleInput ci, java.util.List args)
determines the appropriate subcommand to execute and then executes it, passing in the arguments that we received

param
commandName
param
ci
param
args


	                       	 
	        
	
		IConsoleCommand command = get(commandName);
		command.execute(commandName, ci, args);
	
public IConsoleCommandget(java.lang.String commandName)
returns the sub command with the specified command name

param
commandName
return

		return (IConsoleCommand) subCommands.get(commandName);
	
public java.lang.StringgetCommandDescriptions()
constructs a string with the descriptions of all of the subcommands, each separated by a newline

return

		StringWriter sw = new StringWriter();
		PrintWriter out = new PrintWriter(sw);
		for (Iterator iter = iterator(); iter.hasNext();) {
			IConsoleCommand cmd = (IConsoleCommand) iter.next();
			out.println(cmd.getCommandDescriptions());
		}
		return sw.toString();
	
public java.util.Iteratoriterator()
gets the set of IConsoleCommand objects that are all of the subcommands that this object owns

return

		return new HashSet(subCommands.values()).iterator();