Class StandardProgressIndicator

java.lang.Object
org.reldb.toolbox.progress.StandardProgressIndicator
All Implemented Interfaces:
ProgressIndicator
Direct Known Subclasses:
ConsoleProgressIndicator

public class StandardProgressIndicator extends Object implements ProgressIndicator
A ProgressIndicator that generates and outputs progress updates via specified lambda expressions.
  • Constructor Details

    • StandardProgressIndicator

      public StandardProgressIndicator(String messagePrefix, ProgressIndicatorDisplay display, ProgressIndicatorMessage messageGenerator)
      Constructor.
      Parameters:
      messagePrefix - This will be prefixed to all outputted messages.
      display - Lambda definition of display mechanism.
      messageGenerator - Lambda definition of message generator.
  • Method Details

    • setPrecision

      public void setPrecision(int precision)
      Set progress message percent precision.
      Parameters:
      precision - Decimal precision of percentage. Default is 2 decimal places.
    • getPrecision

      public int getPrecision()
      Get progress message percent precision.
      Returns:
      Decimal precision of percentage. Default is 2 decimal places.
    • getMessagePrefix

      public String getMessagePrefix()
      Get the message prefix. Set in the constructor.
      Returns:
      The message prefix.
    • getPosition

      public int getPosition()
      Description copied from interface: ProgressIndicator
      Get the current indicator position.
      Specified by:
      getPosition in interface ProgressIndicator
      Returns:
      Current indicator position.
    • getLastMessage

      public String getLastMessage()
      Description copied from interface: ProgressIndicator
      Get the most recent non-null additional information.
      Specified by:
      getLastMessage in interface ProgressIndicator
      Returns:
      Most recent non-null additional information string.
    • getPercent

      public float getPercent()
      Get percent progress as a float.
      Returns:
      Percent progress.
    • initialise

      public void initialise(int steps)
      Description copied from interface: ProgressIndicator
      Initialise the indicator with the number of steps.
      Specified by:
      initialise in interface ProgressIndicator
      Parameters:
      steps - Number of steps or -1 if unknown. Should be non-zero.
    • getSteps

      public int getSteps()
      Description copied from interface: ProgressIndicator
      Get the number of steps. Set via initialise(...)
      Specified by:
      getSteps in interface ProgressIndicator
      Returns:
      The total number of steps; -1 if unknown.
    • getProgressMessage

      public String getProgressMessage()
      Get the current progress as a percentage.
      Returns:
      Current progress message.
    • move

      public void move(int step, String additionalInformation)
      Description copied from interface: ProgressIndicator
      Move the indicator to the given 0-based step. additionalInformation supplies additional progress text; null if not needed.
      Specified by:
      move in interface ProgressIndicator
      Parameters:
      step - Move the indicator to this step number.
      additionalInformation - Provide optional additional information about this step.