class ConsoleDialogueElement
extends java.lang.Object
The second of the two parts that make up my ConsoleDialogueAPI, a lightweight programming interface for creating console dialogues.
Abbreviations you might encounter in this documentation:
CDM = ConsoleDialogueManager
CDE = ConsoleDialogueElement
Modifier and Type | Field | Description |
---|---|---|
private java.lang.Runnable |
action |
A slot for the code that should be executed after a positive check.
|
(package private) boolean |
lastWord |
A slot for the value returned by the check() -function to the "last word" boolean in the process communication variable in the ConsoleDialogue() -method.
|
(package private) java.util.regex.Matcher |
matcher |
Used to see if the Pattern object's pattern matches with a given string (user input, of course, in this case).
|
private java.util.regex.Pattern |
pattern |
The Pattern object – initiated by the constructor with the regex string provided as parameter.
|
Constructor | Description |
---|---|
ConsoleDialogueElement(java.lang.Runnable action,
java.lang.String pattern,
boolean terminal) |
CDE Constructor
|
Modifier and Type | Method | Description |
---|---|---|
(package private) boolean[] |
check(java.lang.String input) |
check
|
private java.lang.Runnable action
boolean lastWord
java.util.regex.Matcher matcher
private java.util.regex.Pattern pattern
ConsoleDialogueElement(java.lang.Runnable action, java.lang.String pattern, boolean terminal)
action
- a runnable with the code that should be executed after a positive checkpattern
- a regex string defining the pattern used for matching by this CDEterminal
- if true, means that "the element is terminal" – a "positive check" with this CDE doesn't only stop "the interpreter", but also ends the "prompter" (see comments within the ConsoleDialogue() -method's code for explanations on what the words surrounded by double quotation marks mean)boolean[] check(java.lang.String input)
input
- the latest user input string