net.sf.flatpack.examples
Class ConsoleMenu

java.lang.Object
  extended by net.sf.flatpack.examples.ConsoleMenu

public class ConsoleMenu
extends java.lang.Object

 

Constructor Summary
ConsoleMenu(Repeater containingObject)
           
 
Method Summary
 void addMenuItem(java.lang.String menuDisplay, java.lang.String methodName, boolean repeat)
          add an entry in the menu, sequentially
 void displayMenu()
          display the menu, the application goes into a loop which provides the menu and fires the entries selected.
static java.math.BigDecimal getBigDecimal(java.lang.String title, java.math.BigDecimal defaultValue)
          Gets an BigDecimal from the System.in
static boolean getBoolean(java.lang.String title, boolean defaultValue)
          Gets a boolean from the System.in
static java.util.Date getDate(java.lang.String title, java.util.Date defaultValue)
           
static int getInt(java.lang.String title, int defaultValue)
          Gets an int from the System.in
static java.lang.String getPassword(java.lang.String prompt)
           
static java.lang.String getString(java.lang.String msg, java.lang.String defaultValue)
          Gets a String from the System.in
static java.lang.String selectOne(java.lang.String title, java.lang.String[] optionNames, java.lang.String[] optionValues, int defaultOption)
          Generates a menu with a list of options and return the value selected.
 void setScreenColumns(int width)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleMenu

public ConsoleMenu(Repeater containingObject)
Parameters:
containingObject - the object that will be called back once an option is chosen in the menu
Method Detail

addMenuItem

public void addMenuItem(java.lang.String menuDisplay,
                        java.lang.String methodName,
                        boolean repeat)
add an entry in the menu, sequentially

Parameters:
menuDisplay - how the entry will be displayed in the menu
methodName - name of the public method
askForRepeat - call back for repeat

setScreenColumns

public void setScreenColumns(int width)

displayMenu

public void displayMenu()
display the menu, the application goes into a loop which provides the menu and fires the entries selected. It automatically adds an entry to exit.


getInt

public static int getInt(java.lang.String title,
                         int defaultValue)
Gets an int from the System.in

Parameters:
title - for the command line
Returns:
int as entered by the user of the console app

getBoolean

public static boolean getBoolean(java.lang.String title,
                                 boolean defaultValue)
Gets a boolean from the System.in

Parameters:
title - for the command line
Returns:
boolean as selected by the user of the console app

getBigDecimal

public static java.math.BigDecimal getBigDecimal(java.lang.String title,
                                                 java.math.BigDecimal defaultValue)
Gets an BigDecimal from the System.in

Parameters:
title - for the command line
Returns:
int as entered by the user of the console app

getDate

public static java.util.Date getDate(java.lang.String title,
                                     java.util.Date defaultValue)

getString

public static java.lang.String getString(java.lang.String msg,
                                         java.lang.String defaultValue)
Gets a String from the System.in

Parameters:
msg - for the command line
Returns:
String as entered by the user of the console app

selectOne

public static java.lang.String selectOne(java.lang.String title,
                                         java.lang.String[] optionNames,
                                         java.lang.String[] optionValues,
                                         int defaultOption)
Generates a menu with a list of options and return the value selected.

Parameters:
title - for the command line
optionNames - name for each option
optionValues - value for each option
Returns:
String as selected by the user of the console app

getPassword

public static java.lang.String getPassword(java.lang.String prompt)
Parameters:
prompt - The prompt to display to the user.
Returns:
The password as entered by the user.