View Javadoc

    1   package org.codehaus.groovy.sandbox.ui;
    2
    3   import java.io.InputStream;
    4   import java.io.PrintStream;
    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 in, PrintStream out, PrintStream err)
    16      {
    17          try
    18          {
    19              return (Prompt) Class.forName("org.codehaus.groovy.sandbox.ui.ReadlinePrompt").newInstance();
    20          }
    21          catch (ClassNotFoundException e)
    22          {
    23              return new JavaPrompt(in, out, err);
    24          }
    25          catch (Exception e)
    26          {
    27              e.printStackTrace();
    28              return new JavaPrompt(in, out, err);
    29          }
    30      }
    31  }