Package org.strassburger.tui4j.input
Class Input<T,S extends Input<T,S>>
java.lang.Object
org.strassburger.tui4j.input.Input<T,S>
- Type Parameters:
T- the type of the input valueS- the type of the input subclass
- Direct Known Subclasses:
BooleanInput,ContinueInput,DateInput,DoubleInput,IntegerInput,MultilineTextInput,NumberInput,SelectInput,TextInput
Abstract class for input
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddValidationRule(ValidationRule<T> rule) Add a validation rule to the inputaddValidationRules(List<ValidationRule<T>> rules) Add validation rules to the inputgetLabel()Deprecated.UsegetPrompt()insteadprotected Printerprotected Scannerbooleanprotected voidprintPromptAndCursor(boolean inline) abstract Tread()Read the input valuesetCursor(StyledText cursor) setErrorMessage(String errorMessage) Set the error message for invalid inputsetErrorMessage(StyledText errorMessage) Set the error message for invalid inputDeprecated.UsesetPrompt(String)insteadsetLabel(StyledText label) Deprecated.UsesetPrompt(StyledText)insteadsetPrinter(Printer printer) Set the label for the inputsetPrompt(StyledText prompt) Set the label for the inputsetRetryOnInvalid(boolean retryOnInvalid) Set whether to retry on invalid inputsetScanner(Scanner scanner) protected voidValidate the input value
-
Constructor Details
-
Input
public Input()Deprecated.UseInput(Printer)insteadConstructor with default scanner and printer -
Input
Constructor with default scanner- Parameters:
printer- the printer to use
-
-
Method Details
-
read
Read the input value- Returns:
- the input value
- Throws:
InputValidationException- if the input is invalid and retryOnInvalid is false
-
setPrompt
Set the label for the input- Parameters:
prompt- the label to set- Returns:
- the input object
-
setLabel
Deprecated.UsesetPrompt(String)insteadSet the label for the input- Parameters:
label- the label to set- Returns:
- the input object
-
setPrompt
Set the label for the input- Parameters:
prompt- the label to set- Returns:
- the input object
-
setLabel
Deprecated.UsesetPrompt(StyledText)insteadSet the label for the input- Parameters:
label- the label to set- Returns:
- the input object
-
setRetryOnInvalid
Set whether to retry on invalid input- Parameters:
retryOnInvalid- whether to retry on invalid input- Returns:
- the input object
-
setErrorMessage
Set the error message for invalid input- Parameters:
errorMessage- the error message to set (as plain text)- Returns:
- the input object
-
setErrorMessage
Set the error message for invalid input- Parameters:
errorMessage- the error message to set- Returns:
- the input object
-
addValidationRule
Add a validation rule to the input- Parameters:
rule- the validation rule to add- Returns:
- the input object
-
addValidationRules
Add validation rules to the input- Parameters:
rules- the validation rules to add- Returns:
- the input object
-
setPrinter
-
setScanner
-
setCursor
-
getCursor
-
validate
Validate the input value- Parameters:
value- the input value to validate- Throws:
InputValidationException- if the input is invalid
-
getLabel
Deprecated.UsegetPrompt()instead -
getPrompt
-
isRetryOnInvalid
public boolean isRetryOnInvalid() -
getErrorMessage
-
getScanner
-
getPrinter
-
printPromptAndCursor
protected void printPromptAndCursor(boolean inline)
-
Input(Printer)instead