View Javadoc

1   package org.codehaus.groovy.sandbox.ui;
2   
3   import java.io.IOException;
4   
5   /***
6    * Factory to build a command line prompt.  Should build the most featureful
7    * prompt available.
8    * 
9    * Currently readline prompt will be looked up dynamically, and defaults to 
10   * normal System.in prompt.
11   */
12  public class PromptFactory {
13    public static Prompt buildPrompt() throws IOException {
14      try {
15        return (Prompt) Class.forName("org.codehaus.groovy.sandbox.ui.ReadlinePrompt").newInstance();
16      } catch (ClassNotFoundException e) {
17        // nothing
18        return new JavaPrompt();
19      } catch (Exception e) {
20        e.printStackTrace();
21        return new JavaPrompt();
22      }
23    }
24  }