diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-26 23:00:28 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-26 23:00:28 -0400 |
| commit | faedf1fe8c22e4ccfa375951166bd1a41a4e3b94 (patch) | |
| tree | 5f5be2ff2ca77bb0d02f21624268a8cc9dedc31e /BJC-Utils2/src/main/java/bjc/utils/cli/fds/FDSState.java | |
| parent | 0040f420f5cc9a8daf8e7ebb2899dec88fdd7214 (diff) | |
More FDS work
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/cli/fds/FDSState.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/cli/fds/FDSState.java | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/fds/FDSState.java b/BJC-Utils2/src/main/java/bjc/utils/cli/fds/FDSState.java new file mode 100644 index 0000000..a0ad5e6 --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/fds/FDSState.java @@ -0,0 +1,85 @@ +package bjc.utils.cli.fds; + +import java.util.function.Consumer; + +import bjc.utils.ioutils.Block; + +/** + * Internal state for an FDS interface. + * + * @author bjculkin + * + * @param <S> + * The state type of the interface. + */ +public class FDSState<S> { + /** + * The input mode for the interface. + * + * @author bjculkin + * + */ + public static enum InputMode { + /** + * Normal mode. + * + * Reads only the first character in the block as a command. + */ + NORMAL, + /** + * Reads every character in the block as a command. + */ + CHORD, + /** + * Reads every character in the block, but after a terminal + * command, data will be read inline separated by spaces until a + * semicolon is read. + * + * The semicolon can be escaped with a backslash. + */ + INLINE, + /** + * Reads every character in the block, but after a terminal + * command, data will be read inline with each character being a + * separate item until a semicolon is read. + * + * The semicolon can be escaped with a backslash. + */ + } + + /** + * The state of the interface + */ + public S state; + /** + * The input mode for the interface. + */ + public InputMode mode; + + /** + * Function to add a command block to be processed. + */ + public Consumer<Block> enqueCommand; + + /** + * Function to add a data block to be processed. + */ + public Consumer<Block> enqueData; + + /** + * Create a new interface state. + * + * @param stat + * The initial state for the interface. + * + * @param inputMode + * The input mode for the interface. + */ + public FDSState(S stat, InputMode inputMode, Consumer<Block> comQueue, Consumer<Block> dataQueue) { + state = stat; + mode = inputMode; + + enqueCommand = comQueue; + enqueData = dataQueue; + } +}
\ No newline at end of file |
