01: package org.codehaus.groovy.sandbox.ui;
02:
03: import java.io.InputStream;
04: import java.io.PrintStream;
05:
06: /**
07: * Factory to build a command line prompt. Should build the most featureful
08: * prompt available.
09: * <p/>
10: * Currently readline prompt will be looked up dynamically, and defaults to
11: * normal System.in prompt.
12: */
13: public class PromptFactory {
14: public static Prompt buildPrompt(InputStream in, PrintStream out,
15: PrintStream err) {
16: try {
17: return (Prompt) Class.forName(
18: "org.codehaus.groovy.sandbox.ui.ReadlinePrompt")
19: .newInstance();
20: } catch (ClassNotFoundException e) {
21: return new JavaPrompt(in, out, err);
22: } catch (Exception e) {
23: e.printStackTrace();
24: return new JavaPrompt(in, out, err);
25: }
26: }
27: }
|