Package adams.core.io
Class ConsoleHelper
- java.lang.Object
-
- adams.core.io.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)
-
-
Constructor Summary
Constructors Constructor Description ConsoleHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
enterMultiLineValue(String msg)
Lets the user enter a multi-line value.static String[]
enterMultipleValues(String msg)
Lets the user enter multiple values.static BasePassword
enterPassword(String msg)
Lets the user enter a password.static String
enterValue(String msg)
Lets the user enter a value.static String
enterValue(String msg, String initial)
Lets the user enter a value.static void
printlnErr(String msg)
Outputs the error message.static void
printlnOut(String msg)
Outputs the message.static PlaceholderDirectory
selectDirectory(String msg, PlaceholderDirectory initial)
Lets the user select a directory.static PlaceholderFile[]
selectFiles(String msg, PlaceholderFile... initial)
Lets the user select files.static String
selectOption(String msg, String[] options)
Lets the user select from a number of choices.static String
selectOption(String msg, String[] options, String initial)
Lets the user select from a number of choices.static void
useBasic()
Switches to the basic helper.static void
useOther(Console other)
Switches to another helper.
-
-
-
Field Detail
-
m_Helper
protected static Console m_Helper
the actual helper.
-
-
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 inputinitial
- 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 inputoptions
- 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 inputoptions
- the options to choose frominitial
- 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 outputinitial
- 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 outputinitial
- 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
-
-