|
|||||||||||||||||||
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 |
import java.io.InputStream;
|
|
7 |
import java.io.PrintStream;
|
|
8 |
|
|
9 |
/**
|
|
10 |
* Pure Java prompt using just System.in.
|
|
11 |
*/
|
|
12 |
public class JavaPrompt implements Prompt |
|
13 |
{ |
|
14 |
private String prompt;
|
|
15 |
private BufferedReader input;
|
|
16 |
private final PrintStream out;
|
|
17 |
private final PrintStream err;
|
|
18 |
|
|
19 | 0 |
public JavaPrompt(InputStream in, PrintStream out, PrintStream err)
|
20 |
{ |
|
21 | 0 |
this.out = out;
|
22 | 0 |
this.err = err;
|
23 | 0 |
this.input = new BufferedReader(new InputStreamReader(in)); |
24 |
} |
|
25 |
|
|
26 | 0 |
public JavaPrompt()
|
27 |
{ |
|
28 | 0 |
this(System.in, System.out, System.err);
|
29 |
} |
|
30 |
|
|
31 | 0 |
public String readLine() throws IOException |
32 |
{ |
|
33 | 0 |
out.print(prompt); |
34 | 0 |
out.flush(); |
35 | 0 |
return input.readLine();
|
36 |
} |
|
37 |
|
|
38 | 0 |
public String getPrompt()
|
39 |
{ |
|
40 | 0 |
return prompt;
|
41 |
} |
|
42 |
|
|
43 | 0 |
public void setPrompt(String prompt) |
44 |
{ |
|
45 | 0 |
this.prompt = prompt;
|
46 |
} |
|
47 |
|
|
48 | 0 |
public void setCompleter(Completer completer) |
49 |
{ |
|
50 |
// completer not supported
|
|
51 |
} |
|
52 |
|
|
53 | 0 |
public void close() |
54 |
{ |
|
55 | 0 |
try
|
56 |
{ |
|
57 | 0 |
input.close(); |
58 |
} |
|
59 |
catch (IOException e)
|
|
60 |
{ |
|
61 | 0 |
e.printStackTrace(err); |
62 |
} |
|
63 |
} |
|
64 |
} |
|
65 |
|
|