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 java.lang.Object

base interface for all console commands

Author:
Tobias Minich

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

IConsoleCommand

public IConsoleCommand(java.lang.String main_name,
                       java.lang.String short_name)
Method Detail

execute

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

Parameters:
commandName -
console -
arguments -

getCommandDescriptions

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

Returns:

printHelp

public final void printHelp(java.io.PrintStream out,
                            java.util.List<java.lang.String> args)
do nothing by default

Parameters:
out -
args -

printHelpExtra

public void printHelpExtra(java.io.PrintStream out,
                           java.util.List<java.lang.String> args)

printHelp

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

Parameters:
out -
arg -

getCommandNames

public java.util.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 java.lang.String getCommandName()

getShortCommandName

public final java.lang.String getShortCommandName()

getTorrentSummary

protected java.lang.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 java.lang.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 java.lang.String getDefaultSummaryFormat()
returns the format string (in printf style format) to use for displaying the torrent summary

Returns: