Name

ConfirmationCallback

Synopsis

A Callback of this type represents a request to ask the user a yes/no or multiple-choice question. A CallbackHandler should first call getPrompt( ) to obtain the text of the question. It should also call getMessageType( ) to determine the message type (INFORMATION, WARNING, or ERROR) and present the question to the user in a suitable manner based on that type.

Next, the CallbackHandler must determine the appropriate set of responses to the question. It does this by calling getOptionType( ). The return values have the following meanings:

YES_NO_OPTION

The CallbackHandler should allow the user to respond to the question with a “yes” or a “no” (or their localized equivalents).

YES_NO_CANCEL_OPTION

The CallbackHandler should allow “yes”, “no”, and “cancel” (or their localized equivalents) responses.

OK_CANCEL_OPTION

The CallbackHandler should allow “ok” and “cancel” (or their localized equivalents) responses.

UNSPECIFIED_OPTION

The CallbackHandler should call getOptions( ) and use present all strings it returns as possible responses.

In each of these cases, the CallbackHandler should also call getDefaultOption( ) to determine which response should be presented as the default response. If getOptionType( ) returned UNSPECIFIED_TYPE, then getDefaultOption( ) returns an index into the array of options returned by getOptions( ). Otherwise getDefaultOption( ) returns one of the constants YES, NO, OK, or CANCEL.

When the user has selected a response to the ...

Get Java in a Nutshell, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.