summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/ioutils/Prompter.java
blob: f39020d2d7e4abba3354159e9a71ba5f4b931d9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package bjc.utils.ioutils;

import java.io.PrintStream;

import bjc.utils.ioutils.blocks.TriggeredBlockReader;

/**
 * A runnable for use with {@link TriggeredBlockReader} to prompt the user for
 * input.
 *
 * @author bjculkin
 *
 */
public final class Prompter implements Runnable {
	private String promt;
	private final PrintStream printer;

	/**
	 * Create a new prompter using the specified prompt.
	 *
	 * @param prompt
	 *        The prompt to present.
	 *
	 * @param output
	 *        The stream to print the prompt on.
	 */
	public Prompter(final String prompt, final PrintStream output) {
		promt = prompt;

		printer = output;
	}

	/**
	 * Set the prompt this prompter uses.
	 *
	 * @param prompt
	 *        The prompt this prompter uses.
	 */
	public void setPrompt(final String prompt) {
		promt = prompt;
	}

	@Override
	public void run() {
		printer.print(promt);
	}
}