Class TextQuestion
java.lang.Object
com.marcpg.libpg.formular.question.Question
com.marcpg.libpg.formular.question.TextQuestion
A question with text, that supports any characters between ASCII 32 (' ') and 126 ('~').
Note that most features will require you to manually implement the JNA dependency (>5.14.0)!
Note that most features will require you to manually implement the JNA dependency (>5.14.0)!
- Since:
- 0.0.8
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.marcpg.libpg.formular.question.Question
Question.QuestionException
-
Field Summary
Fields inherited from class com.marcpg.libpg.formular.question.Question
description, form, id, requirement, submitted, title
-
Constructor Summary
ConstructorDescriptionTextQuestion
(String id, String title, String description) Creates a new text question with the default character limit of 128.TextQuestion
(String id, String title, String description, int characterLimit) Creates a new text question with a specific character limit. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Renders the current question toSystem.out
.int
Gets the text question's character limit, which is 128 by default.getInput()
Gets the current or preferably final input of the question.void
Resets the state of this question to be as if it was just created.void
setInput
(CharSequence input) Sets the input, if the question isn't already submitted.void
submit()
Submits the question with the current choice and locks in a final answer.void
submit
(CharSequence input) Submits the question with a specific input.toResult()
Converts this question to a Result, that can be used in a FormularResult.Methods inherited from class com.marcpg.libpg.formular.question.Question
invalid, isSubmitted, setForm, setRequirement
-
Constructor Details
-
TextQuestion
public TextQuestion(@Pattern("[a-z0-9_-]+") String id, String title, String description, int characterLimit) Creates a new text question with a specific character limit.- Parameters:
id
- The question's unique identifier.title
- The question's title.description
- The question's description.characterLimit
- How long the text can be.
-
TextQuestion
Creates a new text question with the default character limit of 128.- Parameters:
id
- The question's unique identifier.title
- The question's title.description
- The question's description.
-
-
Method Details
-
resetState
public void resetState()Description copied from class:Question
Resets the state of this question to be as if it was just created. Won't reset the question's settings, but only the already chosen and rendered things.- Specified by:
resetState
in classQuestion
-
getCharacterLimit
public int getCharacterLimit()Gets the text question's character limit, which is 128 by default.- Returns:
- The character limit.
-
setInput
Sets the input, if the question isn't already submitted.- Parameters:
input
- The input.
-
submit
Submits the question with a specific input.- Parameters:
input
- The input to be submitted.
-
submit
public void submit()Description copied from class:Question
Submits the question with the current choice and locks in a final answer. -
getInput
Description copied from class:Question
Gets the current or preferably final input of the question. -
toResult
Description copied from class:Question
Converts this question to a Result, that can be used in a FormularResult. -
cliRender
public void cliRender()Renders the current question toSystem.out
. Will only work forCLIFormular
s.
If the character limit is set to 128, it will ask this:Enter Text (0/128):
-