KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > groovy > sandbox > ui > PromptFactory


1 package org.codehaus.groovy.sandbox.ui;
2
3 import java.io.InputStream JavaDoc;
4 import java.io.PrintStream JavaDoc;
5
6 /**
7  * Factory to build a command line prompt. Should build the most featureful
8  * prompt available.
9  * <p/>
10  * Currently readline prompt will be looked up dynamically, and defaults to
11  * normal System.in prompt.
12  */

13 public class PromptFactory
14 {
15     public static Prompt buildPrompt(InputStream JavaDoc in, PrintStream JavaDoc out, PrintStream JavaDoc err)
16     {
17         try
18         {
19             return (Prompt) Class.forName("org.codehaus.groovy.sandbox.ui.ReadlinePrompt").newInstance();
20         }
21         catch (ClassNotFoundException JavaDoc e)
22         {
23             return new JavaPrompt(in, out, err);
24         }
25         catch (Exception JavaDoc e)
26         {
27             e.printStackTrace();
28             return new JavaPrompt(in, out, err);
29         }
30     }
31 }
32
Popular Tags