Class CLITools
- java.lang.Object
-
- edu.uiuc.ncsa.security.util.configuration.CLITools
-
public class CLITools extends Object
Tools for creating command line clientsCreated by Jeff Gaynor
on Jun 25, 2010 at 2:15:40 PM
-
-
Constructor Summary
Constructors Constructor Description CLITools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static OutputStream
getOutputStream()
protected static PrintWriter
getPrintWriter()
static int
listChoose(String head, Object[] options)
This displays the head then each of the list choices which are numbered.static int
listChoose(String head, Object[] options, int defaultChoice)
static int
listChoose(String head, List options, int defaultChoice)
Convenience method to give a list of choices from a set of options.static String
prompt(String prompt, Object defaultValue)
A utility for getting user input.static void
say(Object obj, String x)
Very useful for debugging.static void
say(String x)
static void
setOutputStream(OutputStream outputStream)
-
-
-
Method Detail
-
prompt
public static String prompt(String prompt, Object defaultValue)
A utility for getting user input. For command line clients. This display the first argument and encloses the second in parentheses. If the user enters a value that is returned, otherwise the second argument is.- Parameters:
prompt
-defaultValue
-- Returns:
-
getOutputStream
public static OutputStream getOutputStream()
-
setOutputStream
public static void setOutputStream(OutputStream outputStream)
-
getPrintWriter
protected static PrintWriter getPrintWriter()
-
say
public static void say(String x)
-
say
public static void say(Object obj, String x)
Very useful for debugging. Supply the local "this" to get the name of the object plus the current time.- Parameters:
obj
-x
-
-
listChoose
public static int listChoose(String head, Object[] options)
This displays the head then each of the list choices which are numbered. The user enters the choice which is converted to an integer then returned. This is perfect for switch statements, e.g. Each option displayed is just thetoString
method for the object.- Parameters:
head
-options
-- Returns:
-
-