Top Description Fields Constructors Methods
javax.security.auth.callback

public Class ChoiceCallback

extends Object
implements Callback, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.security.auth.callback.Callback
Imports
java.io.IOException, .InvalidObjectException, .ObjectInputStream

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).

Since
1.4
See Also
javax.security.auth.callback.CallbackHandler

Field Summary

Modifier and TypeField and Description
private String[]
private final int
private final boolean
private final String
private int[]
private static final long

Constructor Summary

AccessConstructor and Description
public
ChoiceCallback(String
the prompt used to describe the list of choices.
prompt
,
String[]
the list of choices. The array is cloned to protect against subsequent modification.
choices
,
int
the choice to be used as the default choice when the list of choices are displayed. This value is represented as an index into the choices array.
defaultChoice
,
boolean
boolean specifying whether multiple selections can be made from the list of choices.
multipleSelectionsAllowed
)

Construct a ChoiceCallback with a prompt, a list of choices, a default choice, and a boolean specifying whether multiple selections from the list of choices are allowed.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

whether multiple selections are allowed.
allowMultipleSelections
()

Get the boolean determining whether multiple selections from the choices list are allowed.

public String[]

Returns:

a copy of the list of choices.
getChoices
()

Get the list of choices.

public int

Returns:

the defaultChoice, represented as an index into the choices list.
getDefaultChoice
()

Get the defaultChoice.

public String

Returns:

the prompt.
getPrompt
()

Get the prompt.

public int[]

Returns:

a copy of the selected choices, represented as indexes into the choices list.
getSelectedIndexes
()

Get the selected choices.

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
stream
)

Restores the state of this object from the stream.

public void
setSelectedIndex(int
the selection represented as an index into the choices list.
selection
)

Set the selected choice.

public void
setSelectedIndexes(int[]
the selections represented as indexes into the choices list. The array is cloned to protect against subsequent modification.
selections
)

Set the selected choices.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

choicesback to summary
private String[] choices
Since
1.4
defaultChoiceback to summary
private final int defaultChoice
Since
1.4
multipleSelectionsAllowedback to summary
private final boolean multipleSelectionsAllowed
Since
1.4
promptback to summary
private final String prompt
Since
1.4
selectionsback to summary
private int[] selections
Since
1.4
serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial

Constructor Detail

ChoiceCallbackback to 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 multiple selections from the list of choices are allowed.

Parameters
prompt:String

the prompt used to describe the list of choices.

choices:String[]

the list of choices. The array is cloned to protect against subsequent modification.

defaultChoice:int

the choice to be used as the default choice when the list of choices are displayed. This value is represented as an index into the choices array.

multipleSelectionsAllowed:boolean

boolean specifying whether multiple selections can be made from the list of choices.

Exceptions
IllegalArgumentException:
if prompt is null, if prompt has a length of 0, if choices is null, if choices has a length of 0, if any element from choices is null, if any element from choices has a length of 0 or if defaultChoice does not fall within the array boundaries of choices.

Method Detail

allowMultipleSelectionsback to summary
public boolean allowMultipleSelections()

Get the boolean determining whether multiple selections from the choices list are allowed.

Returns:boolean

whether multiple selections are allowed.

getChoicesback to summary
public String[] getChoices()

Get the list of choices.

Returns:String[]

a copy of the list of choices.

getDefaultChoiceback to summary
public int getDefaultChoice()

Get the defaultChoice.

Returns:int

the defaultChoice, represented as an index into the choices list.

getPromptback to summary
public String getPrompt()

Get the prompt.

Returns:String

the prompt.

getSelectedIndexesback to summary
public int[] getSelectedIndexes()

Get the selected choices.

Returns:int[]

a copy of the selected choices, represented as indexes into the choices list.

See Also
setSelectedIndexes
readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException

Restores the state of this object from the stream.

Parameters
stream:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
setSelectedIndexback to summary
public void setSelectedIndex(int selection)

Set the selected choice.

Parameters
selection:int

the selection represented as an index into the choices list.

See Also
getSelectedIndexes
setSelectedIndexesback to summary
public void setSelectedIndexes(int[] selections)

Set the selected choices.

Parameters
selections:int[]

the selections represented as indexes into the choices list. The array is cloned to protect against subsequent modification.

Exceptions
UnsupportedOperationException:
if multiple selections are not allowed, as determined by allowMultipleSelections.
See Also
getSelectedIndexes