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()protected Printerprotected Scannerbooleanabstract 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 inputSet the label for the inputsetLabel(StyledText label) Set the label for the inputsetPrinter(Printer printer) setRetryOnInvalid(boolean retryOnInvalid) Set whether to retry on invalid inputsetScanner(Scanner scanner) protected voidValidate the input value
-
Constructor Details
-
Input
public Input()Constructor with default scanner and printer
-
-
Method Details
-
read
Read the input value- Returns:
- the input value
- Throws:
InputValidationException- if the input is invalid and retryOnInvalid is false
-
setLabel
Set the label for the input- Parameters:
label- the label to set- Returns:
- the input object
-
setLabel
Set 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
-
isRetryOnInvalid
public boolean isRetryOnInvalid() -
getErrorMessage
-
getScanner
-
getPrinter
-