Package adams.core.io.console
Class Basic
- java.lang.Object
-
- adams.core.io.console.Basic
-
-
Constructor Summary
Constructors Constructor Description Basic()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
enterMultiLineValue(String msg)
Lets the user enter a multi-line value.String[]
enterMultipleValues(String msg)
Lets the user enter multiple values.BasePassword
enterPassword(String msg)
Lets the user enter a password.String
enterValue(String msg)
Lets the user enter a value.String
enterValue(String msg, String initial)
Lets the user enter a value.void
printlnErr(String msg)
Outputs the error message.void
printlnOut(String msg)
Outputs the message.protected String
readAll()
Reads all lines from stdin (till null encountered, i.e.protected String
readLine()
Reads a line from stdin.PlaceholderDirectory
selectDirectory(String msg, PlaceholderDirectory initial)
Lets the user select a directory.PlaceholderFile[]
selectFiles(String msg, PlaceholderFile... initial)
Lets the user select files.String
selectOption(String msg, String[] options)
Lets the user select from a number of choices.String
selectOption(String msg, String[] options, String initial)
Lets the user select from a number of choices.
-
-
-
Method Detail
-
readLine
protected String readLine()
Reads a line from stdin.- Returns:
- the line, null if failed to read
-
readAll
protected String readAll()
Reads all lines from stdin (till null encountered, i.e. "Ctrl+D").- Returns:
- the line, null if failed to read
-
enterMultiLineValue
public String enterMultiLineValue(String msg)
Lets the user enter a multi-line value.- Specified by:
enterMultiLineValue
in interfaceConsole
- Parameters:
msg
- the message to output before reading the input- Returns:
- the entered value, null if cancelled or failed to read input
-
enterValue
public String enterValue(String msg)
Lets the user enter a value.- Specified by:
enterValue
in interfaceConsole
- Parameters:
msg
- the message to output before reading the input- Returns:
- the entered value, null if cancelled or failed to read input
-
enterValue
public String enterValue(String msg, String initial)
Lets the user enter a value.- Specified by:
enterValue
in interfaceConsole
- 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 (or initial value if empty string returned)
-
enterMultipleValues
public String[] enterMultipleValues(String msg)
Lets the user enter multiple values. Empty string terminates the loop.- Specified by:
enterMultipleValues
in interfaceConsole
- Parameters:
msg
- the message to output before reading the input- Returns:
- the entered value, null if cancelled or failed to read input
-
enterPassword
public BasePassword enterPassword(String msg)
Lets the user enter a password.- Specified by:
enterPassword
in interfaceConsole
- Parameters:
msg
- the message to output before reading the input- Returns:
- the entered value, null if cancelled or failed to read input
-
selectOption
public String selectOption(String msg, String[] options)
Lets the user select from a number of choices.- Specified by:
selectOption
in interfaceConsole
- 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 String selectOption(String msg, String[] options, String initial)
Lets the user select from a number of choices.- Specified by:
selectOption
in interfaceConsole
- 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 PlaceholderDirectory selectDirectory(String msg, PlaceholderDirectory initial)
Lets the user select a directory.- Specified by:
selectDirectory
in interfaceConsole
- Parameters:
msg
- the message to outputinitial
- the initial directory- Returns:
- the directory, null if cancelled
-
selectFiles
public PlaceholderFile[] selectFiles(String msg, PlaceholderFile... initial)
Lets the user select files.- Specified by:
selectFiles
in interfaceConsole
- Parameters:
msg
- the message to outputinitial
- the initial files- Returns:
- the directory, null if cancelled
-
printlnOut
public void printlnOut(String msg)
Outputs the message.- Specified by:
printlnOut
in interfaceConsole
- Parameters:
msg
- the message to output
-
printlnErr
public void printlnErr(String msg)
Outputs the error message.- Specified by:
printlnErr
in interfaceConsole
- Parameters:
msg
- the error message to output
-
-