Constructor: |
public ConfirmationCallback(int messageType,
int optionType,
int defaultOption) {
if (messageType < INFORMATION || messageType > ERROR ||
optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION)
throw new IllegalArgumentException();
switch (optionType) {
case YES_NO_OPTION:
if (defaultOption != YES && defaultOption != NO)
throw new IllegalArgumentException();
break;
case YES_NO_CANCEL_OPTION:
if (defaultOption != YES && defaultOption != NO &&
defaultOption != CANCEL)
throw new IllegalArgumentException();
break;
case OK_CANCEL_OPTION:
if (defaultOption != OK && defaultOption != CANCEL)
throw new IllegalArgumentException();
break;
}
this.messageType = messageType;
this.optionType = optionType;
this.defaultOption = defaultOption;
}
Construct a ConfirmationCallback with a
message type, an option type and a default option.
Underlying security services use this constructor if
they require either a YES/NO, YES/NO/CANCEL or OK/CANCEL
confirmation.
Parameters:
messageType - the message type (INFORMATION ,
WARNING or ERROR ).
optionType - the option type (YES_NO_OPTION ,
YES_NO_CANCEL_OPTION or
OK_CANCEL_OPTION ).
defaultOption - the default option
from the provided optionType (YES ,
NO , CANCEL or
OK ).
Throws:
IllegalArgumentException - if messageType is not either
INFORMATION , WARNING ,
or ERROR , if optionType is not either
YES_NO_OPTION ,
YES_NO_CANCEL_OPTION , or
OK_CANCEL_OPTION ,
or if defaultOption
does not correspond to one of the options in
optionType .
- exception:
IllegalArgumentException - if messageType is not either
INFORMATION , WARNING ,
or ERROR , if optionType is not either
YES_NO_OPTION ,
YES_NO_CANCEL_OPTION , or
OK_CANCEL_OPTION ,
or if defaultOption
does not correspond to one of the options in
optionType .
|
public ConfirmationCallback(int messageType,
String[] options,
int defaultOption) {
if (messageType < INFORMATION || messageType > ERROR ||
options == null || options.length == 0 ||
defaultOption < 0 || defaultOption >= options.length)
throw new IllegalArgumentException();
for (int i = 0; i < options.length; i++) {
if (options[i] == null || options[i].length() == 0)
throw new IllegalArgumentException();
}
this.messageType = messageType;
this.options = options;
this.defaultOption = defaultOption;
}
Construct a ConfirmationCallback with a
message type, a list of options and a default option.
Underlying security services use this constructor if
they require a confirmation different from the available preset
confirmations provided (for example, CONTINUE/ABORT or STOP/GO).
The confirmation options are listed in the options array,
and are displayed by the CallbackHandler implementation
in a manner consistent with the way preset options are displayed.
Parameters:
messageType - the message type (INFORMATION ,
WARNING or ERROR ).
options - the list of confirmation options.
defaultOption - the default option, represented as an index
into the options array.
Throws:
IllegalArgumentException - if messageType is not either
INFORMATION , WARNING ,
or ERROR , if options is null,
if options has a length of 0,
if any element from options is null,
if any element from options
has a length of 0, or if defaultOption
does not lie within the array boundaries of
options .
- exception:
IllegalArgumentException - if messageType is not either
INFORMATION , WARNING ,
or ERROR , if options is null,
if options has a length of 0,
if any element from options is null,
if any element from options
has a length of 0, or if defaultOption
does not lie within the array boundaries of
options .
|
public ConfirmationCallback(String prompt,
int messageType,
int optionType,
int defaultOption) {
if (prompt == null || prompt.length() == 0 ||
messageType < INFORMATION || messageType > ERROR ||
optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION)
throw new IllegalArgumentException();
switch (optionType) {
case YES_NO_OPTION:
if (defaultOption != YES && defaultOption != NO)
throw new IllegalArgumentException();
break;
case YES_NO_CANCEL_OPTION:
if (defaultOption != YES && defaultOption != NO &&
defaultOption != CANCEL)
throw new IllegalArgumentException();
break;
case OK_CANCEL_OPTION:
if (defaultOption != OK && defaultOption != CANCEL)
throw new IllegalArgumentException();
break;
}
this.prompt = prompt;
this.messageType = messageType;
this.optionType = optionType;
this.defaultOption = defaultOption;
}
Construct a ConfirmationCallback with a prompt,
message type, an option type and a default option.
Underlying security services use this constructor if
they require either a YES/NO, YES/NO/CANCEL or OK/CANCEL
confirmation.
Parameters:
prompt - the prompt used to describe the list of options.
messageType - the message type (INFORMATION ,
WARNING or ERROR ).
optionType - the option type (YES_NO_OPTION ,
YES_NO_CANCEL_OPTION or
OK_CANCEL_OPTION ).
defaultOption - the default option
from the provided optionType (YES ,
NO , CANCEL or
OK ).
Throws:
IllegalArgumentException - if prompt is null,
if prompt has a length of 0,
if messageType is not either
INFORMATION , WARNING ,
or ERROR , if optionType is not either
YES_NO_OPTION ,
YES_NO_CANCEL_OPTION , or
OK_CANCEL_OPTION ,
or if defaultOption
does not correspond to one of the options in
optionType .
- exception:
IllegalArgumentException - if prompt is null,
if prompt has a length of 0,
if messageType is not either
INFORMATION , WARNING ,
or ERROR , if optionType is not either
YES_NO_OPTION ,
YES_NO_CANCEL_OPTION , or
OK_CANCEL_OPTION ,
or if defaultOption
does not correspond to one of the options in
optionType .
|
public ConfirmationCallback(String prompt,
int messageType,
String[] options,
int defaultOption) {
if (prompt == null || prompt.length() == 0 ||
messageType < INFORMATION || messageType > ERROR ||
options == null || options.length == 0 ||
defaultOption < 0 || defaultOption >= options.length)
throw new IllegalArgumentException();
for (int i = 0; i < options.length; i++) {
if (options[i] == null || options[i].length() == 0)
throw new IllegalArgumentException();
}
this.prompt = prompt;
this.messageType = messageType;
this.options = options;
this.defaultOption = defaultOption;
}
Construct a ConfirmationCallback with a prompt,
message type, a list of options and a default option.
Underlying security services use this constructor if
they require a confirmation different from the available preset
confirmations provided (for example, CONTINUE/ABORT or STOP/GO).
The confirmation options are listed in the options array,
and are displayed by the CallbackHandler implementation
in a manner consistent with the way preset options are displayed.
Parameters:
prompt - the prompt used to describe the list of options.
messageType - the message type (INFORMATION ,
WARNING or ERROR ).
options - the list of confirmation options.
defaultOption - the default option, represented as an index
into the options array.
Throws:
IllegalArgumentException - if prompt is null,
if prompt has a length of 0,
if messageType is not either
INFORMATION , WARNING ,
or ERROR , if options is null,
if options has a length of 0,
if any element from options is null,
if any element from options
has a length of 0, or if defaultOption
does not lie within the array boundaries of
options .
- exception:
IllegalArgumentException - if prompt is null,
if prompt has a length of 0,
if messageType is not either
INFORMATION , WARNING ,
or ERROR , if options is null,
if options has a length of 0,
if any element from options is null,
if any element from options
has a length of 0, or if defaultOption
does not lie within the array boundaries of
options .
|