|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
JavaPrompt.java | - | 0% | 0% | 0% |
|
1 |
package org.codehaus.groovy.sandbox.ui;
|
|
2 |
|
|
3 |
import java.io.BufferedReader;
|
|
4 |
import java.io.IOException;
|
|
5 |
import java.io.InputStreamReader;
|
|
6 |
|
|
7 |
/**
|
|
8 |
* Pure Java prompt using just System.in.
|
|
9 |
*/
|
|
10 |
public class JavaPrompt implements Prompt { |
|
11 |
private String prompt;
|
|
12 |
private BufferedReader input;
|
|
13 |
|
|
14 | 0 |
public JavaPrompt() {
|
15 |
// make a buffered reader to support readLine
|
|
16 | 0 |
this.input = new BufferedReader(new InputStreamReader(System.in)); |
17 |
} |
|
18 |
|
|
19 | 0 |
public String readLine() throws IOException { |
20 | 0 |
System.out.print(prompt); |
21 | 0 |
System.out.flush(); |
22 |
|
|
23 | 0 |
return input.readLine();
|
24 |
} |
|
25 |
|
|
26 | 0 |
public String getPrompt() {
|
27 | 0 |
return prompt;
|
28 |
} |
|
29 |
|
|
30 | 0 |
public void setPrompt(String prompt) { |
31 | 0 |
this.prompt = prompt;
|
32 |
} |
|
33 |
|
|
34 | 0 |
public void setCompleter(Completer completer) { |
35 |
// completer not supported
|
|
36 |
} |
|
37 |
|
|
38 | 0 |
public void close() { |
39 | 0 |
try {
|
40 | 0 |
input.close(); |
41 |
} catch (IOException e) {
|
|
42 | 0 |
e.printStackTrace(); |
43 |
} |
|
44 |
} |
|
45 |
} |
|
46 |
|
|