Package adams.core.io

Class ConsoleHelper


  • public class ConsoleHelper
    extends Object
    Helper for input in a terminal. By default, it uses System.out and System.in for interaction.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • m_Helper

        protected static Console m_Helper
        the actual helper.
    • Constructor Detail

      • ConsoleHelper

        public ConsoleHelper()
    • Method Detail

      • useBasic

        public static void useBasic()
        Switches to the basic helper.
        See Also:
        Basic
      • useOther

        public static void useOther​(Console other)
        Switches to another helper.
        Parameters:
        other - the other helper
      • enterMultiLineValue

        public static String enterMultiLineValue​(String msg)
        Lets the user enter a multi-line value.
        Parameters:
        msg - the message to output before reading the input
        Returns:
        the entered value, null if cancelled or failed to read input
      • enterValue

        public static String enterValue​(String msg)
        Lets the user enter a value.
        Parameters:
        msg - the message to output before reading the input
        Returns:
        the entered value, null if cancelled or failed to read input
      • enterValue

        public static String enterValue​(String msg,
                                        String initial)
        Lets the user enter a value.
        Parameters:
        msg - the message to output before reading the input
        initial - the initial value, ignored if empty or null
        Returns:
        the entered value, null if cancelled or failed to read input
      • enterMultipleValues

        public static String[] enterMultipleValues​(String msg)
        Lets the user enter multiple values. Empty string terminates the loop.
        Parameters:
        msg - the message to output before reading the input
        Returns:
        the entered value, null if cancelled or failed to read input
      • enterPassword

        public static BasePassword enterPassword​(String msg)
        Lets the user enter a password.
        Parameters:
        msg - the message to output before reading the input
        Returns:
        the entered value, null if cancelled or failed to read input
      • selectOption

        public static String selectOption​(String msg,
                                          String[] options)
        Lets the user select from a number of choices.
        Parameters:
        msg - the message to output before reading the input
        options - the options to choose from
        Returns:
        the selected option, null if cancelled or failed to read input
      • selectOption

        public static String selectOption​(String msg,
                                          String[] options,
                                          String initial)
        Lets the user select from a number of choices.
        Parameters:
        msg - the message to output before reading the input
        options - the options to choose from
        initial - the initial selection (selected if just hitting enter), null or empty string to ignore
        Returns:
        the selected option, null if cancelled or failed to read input
      • selectDirectory

        public static PlaceholderDirectory selectDirectory​(String msg,
                                                           PlaceholderDirectory initial)
        Lets the user select a directory.
        Parameters:
        msg - the message to output
        initial - the initial directory
        Returns:
        the directory, null if cancelled
      • selectFiles

        public static PlaceholderFile[] selectFiles​(String msg,
                                                    PlaceholderFile... initial)
        Lets the user select files.
        Parameters:
        msg - the message to output
        initial - the initial files
        Returns:
        the directory, null if cancelled
      • printlnOut

        public static void printlnOut​(String msg)
        Outputs the message.
        Parameters:
        msg - the message to output
      • printlnErr

        public static void printlnErr​(String msg)
        Outputs the error message.
        Parameters:
        msg - the error message to output