Class IConsoleCommand

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.HashSet commands  
      private java.lang.String main_name  
      private java.lang.String short_name  
    • Constructor Summary

      Constructors 
      Constructor Description
      IConsoleCommand​(java.lang.String main_name)  
      IConsoleCommand​(java.lang.String main_name, java.lang.String short_name)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      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()  
      private static java.lang.String getShortStateString​(int dmstate)
      returns a string representation of the specified state number suitable for inclusion in a torrent summary
      protected java.lang.String getTorrentSummary​(DownloadManager dm)
      returns the summary details for the specified torrent.
      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 printHelp​(java.io.PrintStream out, java.util.List<java.lang.String> args)
      do nothing by default
      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
    • Field Detail

      • main_name

        private java.lang.String main_name
      • short_name

        private java.lang.String short_name
      • commands

        private java.util.HashSet commands
    • 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:
      • getShortStateString

        private static java.lang.String getShortStateString​(int dmstate)
        returns a string representation of the specified state number suitable for inclusion in a torrent summary
        Parameters:
        dmstate -
        Returns: