org.gudy.azureus2.ui.console.commands
Class IConsoleCommand

java.lang.Object
  extended by org.gudy.azureus2.ui.console.commands.IConsoleCommand
Direct Known Subclasses:
Archive, Create, Move, OptionsConsoleCommand, Pairing, Plugin, RunState, Set, Share, Show, Subscriptions, Tags, TorrentCommand, UserCommand, XML

public abstract class IConsoleCommand
extends Object

base interface for all console commands

Author:
Tobias Minich

Nested Class Summary
protected static class IConsoleCommand.TorrentComparator
           
 
Constructor Summary
IConsoleCommand(String main_name)
           
IConsoleCommand(String main_name, String short_name)
           
 
Method Summary
abstract  void execute(String commandName, ConsoleInput console, List<String> arguments)
          execute the command with the specified name using the specified arguments
protected  String expandVariable(char variable, DownloadManager dm)
          expands the specified variable character into a string.
abstract  String getCommandDescriptions()
          return high-level help about the commands supported by this object.
 String getCommandName()
           
 Set getCommandNames()
          returns the set of command names that this command understands.
protected  String getDefaultSummaryFormat()
          returns the format string (in printf style format) to use for displaying the torrent summary
 String getShortCommandName()
           
protected  String getTorrentSummary(DownloadManager dm)
          returns the summary details for the specified torrent.
 void printHelp(PrintStream out, List<String> args)
          do nothing by default
protected  void printHelp(PrintStream out, String arg)
          helper method if subclasses want to print out help for a particular subcommand
 void printHelpExtra(PrintStream out, List<String> args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IConsoleCommand

public IConsoleCommand(String main_name)

IConsoleCommand

public IConsoleCommand(String main_name,
                       String short_name)
Method Detail

execute

public abstract void execute(String commandName,
                             ConsoleInput console,
                             List<String> arguments)
execute the command with the specified name using the specified arguments

Parameters:
commandName -
console -
arguments -

getCommandDescriptions

public abstract String getCommandDescriptions()
return high-level help about the commands supported by this object.

Returns:

printHelp

public final void printHelp(PrintStream out,
                            List<String> args)
do nothing by default

Parameters:
out -
args -

printHelpExtra

public void printHelpExtra(PrintStream out,
                           List<String> args)

printHelp

protected final void printHelp(PrintStream out,
                               String arg)
helper method if subclasses want to print out help for a particular subcommand

Parameters:
out -
arg -

getCommandNames

public Set getCommandNames()
returns the set of command names that this command understands. eg: the 'quit' command might understand 'quit', 'q', 'bye' other commands might actually have several command names and execute different code depending upon the command name

Returns:

getCommandName

public final String getCommandName()

getShortCommandName

public final String getShortCommandName()

getTorrentSummary

protected String getTorrentSummary(DownloadManager dm)
returns the summary details for the specified torrent. - we do this by obtaining the summary format and then performing variable substitution NOTE: we currently reprocess the summary format string each time however we could pre-parse this once.. its probably not that important though.

Returns:

expandVariable

protected String expandVariable(char variable,
                                DownloadManager dm)
expands the specified variable character into a string.
currently available variables that can be expanded are:

%a for state
%c percentage complete
%t torrent details - error message if error, otherwise torrent name
%z size
%e ETA
%r progress, if we have disabled some files
%d download speed
%u upload speed
%D amount downloaded
%U amount uploaded
%v upload slots %s connected seeds
%p connected peers
%S tracker seeds
%P tracker peers

Parameters:
variable - variable character, eg: 'e' for ETA
dm - download manager object
Returns:
string expansion of the variable

getDefaultSummaryFormat

protected String getDefaultSummaryFormat()
returns the format string (in printf style format) to use for displaying the torrent summary

Returns: