|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.novell.nds.dirxml.util.Menu
public class Menu
publc * Simple menu system for a command-line environment. Also has a few utility prompting methods.
Field Summary | |
---|---|
static int |
RESPONSE_CANCEL
Value returned from getYesNoResponse() if user enters other than 'y', 'yes', 'n', or 'no' (localized
appropriately). |
static int |
RESPONSE_NO
Value returned from getYesNoResponse() if user answers negatively. |
static int |
RESPONSE_YES
Value returned from getYesNoResponse() if user answers positively. |
Constructor Summary | |
---|---|
Menu(String label,
String header,
String exitPrompt,
List userItems)
Constructor. |
Method Summary | |
---|---|
static int |
getYesNoResponse(String question)
Pose a yes/no question. |
static int[] |
parseNumberList(String tokenString)
Parse a whitespace-, comma-, or semicolon-separated list of integers. |
static String |
promptForData(String prompt)
Utility routine to gather input from System.in . |
static String |
promptForPassword(String prompt)
Utility routine to gather input from System.in . |
int |
run()
Execute this Menu instance. |
void |
setAllowMultiSelect(boolean allowMultiSelect)
Enable or disable the selection of multiple menu items at once. |
void |
setLabel(String label)
Set the label for this menu. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int RESPONSE_CANCEL
getYesNoResponse()
if user enters other than 'y', 'yes', 'n', or 'no' (localized
appropriately).
getYesNoResponse(java.lang.String)
,
Constant Field Valuespublic static final int RESPONSE_NO
getYesNoResponse()
if user answers negatively.
getYesNoResponse(java.lang.String)
,
Constant Field Valuespublic static final int RESPONSE_YES
getYesNoResponse()
if user answers positively.
getYesNoResponse(java.lang.String)
,
Constant Field ValuesConstructor Detail |
---|
public Menu(String label, String header, String exitPrompt, List userItems)
label
- text displayed over all menu items.header
- optional text to be displayed over the menu itemsexitPrompt
- optional text for exit item. If null, "Exit" is used.userItems
- List
of MenuItem
instances. A default
"Exit" item is always provided, so there must not be an
"Exit" item in the list.Method Detail |
---|
public void setLabel(String label)
label
- text displayed over all menu items.public void setAllowMultiSelect(boolean allowMultiSelect)
allowMultiSelect
- true
to allow multiple item selection, false
otherwisepublic static String promptForData(String prompt) throws IOException
System.in
.
prompt
- text to display informing the user what to input.
IOException
- thrown by underlying System.in
InputStream
.public static String promptForPassword(String prompt) throws IOException
System.in
.
This will attempt to hide the input as it is typed.
prompt
- text to display informing the user what to input.
IOException
- thrown by underlying System.in
InputStream
.public static int getYesNoResponse(String question)
question
- question text (no question mark).
public int run() throws IOException
Menu
instance.
MenuItem
selected that caused menu to exit. If the built-in
"Exit" item is selected then the index will be equal to the size of the
List passed to the constructor.
IOException
- thrown by underlying System.in
InputStream
.public static int[] parseNumberList(String tokenString) throws NumberFormatException
tokenString
- String
containing list to parse.
int
s.
NumberFormatException
- thrown if a token in tokenString
isn't a lexically-valid int
according to Java rules.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |