Class ChainedProgressReporter

java.lang.Object
net.sf.basedb.util.ChainedProgressReporter
All Implemented Interfaces:
ProgressReporter

public class ChainedProgressReporter extends Object implements ProgressReporter
An implementation of the ProgressReporter interface that chains to another progress reporter while recalculating the percentage values. This class is useful when you call several methods in a row that each of them outputs progress messages between 0 and 100 percent. Use this progress reporter to change the scale so that the first method output values between 0 and 20, the next between 20 and 50, and so on.
Version:
2.0
Author:
Nicklas
Last modified
$Date: 2015-06-04 13:33:43 +0200 (to, 04 jun 2015) $
  • Field Details

    • master

      private final ProgressReporter master
    • start

      private int start
    • end

      private int end
    • scale

      private float scale
    • messagePrefix

      private String messagePrefix
  • Constructor Details

    • ChainedProgressReporter

      public ChainedProgressReporter(ProgressReporter master)
      Create a new chained progress reporter. All calls to this progress reporter will be propagated to the master progress reporter after the percentage value has been recalculated to be within the specified range.
      Parameters:
      master - The master progress reporter
      See Also:
  • Method Details

    • display

      public void display(int percent, String message)
      Description copied from interface: ProgressReporter
      Display a progress message.
      Specified by:
      display in interface ProgressReporter
      Parameters:
      percent - How many percent of the task that is completed or -1 if not known
      message - A message, or null
    • append

      public void append(String message)
      Description copied from interface: ProgressReporter
      Append a message to the previous one.
      Specified by:
      append in interface ProgressReporter
      Parameters:
      message - The message
    • setRange

      public void setRange(int start, int end)
      Set the range to use for the percentage values. When the display(int, String) method is invoked the percentage value is recalculated to be within the specified range before the master progress reporter is invoked. Ie. 0 --> start and 100 --> end.
      Parameters:
      start - Start value
      end - End value.
    • setMessagePrefix

      public void setMessagePrefix(String prefix)
      Set a message prefix that is pre-pended to message before it is sent to the master progress reporter.
      Since:
      3.6