ChoiceCallbackpublic class ChoiceCallback extends Object implements Callback, Serializable Underlying security services instantiate and pass a
ChoiceCallback to the handle
method of a CallbackHandler to display a list of choices
and to retrieve the selected choice(s). |
Fields Summary |
---|
private static final long | serialVersionUID | private String | prompt | private String[] | choices | private int | defaultChoice | private boolean | multipleSelectionsAllowed | private int[] | selections |
Constructors Summary |
---|
public ChoiceCallback(String prompt, String[] choices, int defaultChoice, boolean multipleSelectionsAllowed)Construct a ChoiceCallback with a prompt,
a list of choices, a default choice, and a boolean specifying
whether or not multiple selections from the list of choices are allowed.
if (prompt == null || prompt.length() == 0 ||
choices == null || choices.length == 0 ||
defaultChoice < 0 || defaultChoice >= choices.length)
throw new IllegalArgumentException();
for (int i = 0; i < choices.length; i++) {
if (choices[i] == null || choices[i].length() == 0)
throw new IllegalArgumentException();
}
this.prompt = prompt;
this.choices = choices;
this.defaultChoice = defaultChoice;
this.multipleSelectionsAllowed = multipleSelectionsAllowed;
|
Methods Summary |
---|
public boolean | allowMultipleSelections()Get the boolean determining whether multiple selections from
the choices list are allowed.
return multipleSelectionsAllowed;
| public java.lang.String[] | getChoices()Get the list of choices.
return choices;
| public int | getDefaultChoice()Get the defaultChoice.
return defaultChoice;
| public java.lang.String | getPrompt()Get the prompt.
return prompt;
| public int[] | getSelectedIndexes()Get the selected choices.
return selections;
| public void | setSelectedIndex(int selection)Set the selected choice.
this.selections = new int[1];
this.selections[0] = selection;
| public void | setSelectedIndexes(int[] selections)Set the selected choices.
if (!multipleSelectionsAllowed)
throw new UnsupportedOperationException();
this.selections = selections;
|
|