Class ChoiceArrayQuestion
java.lang.Object
com.sun.interview.Question
com.sun.interview.ChoiceArrayQuestion
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean[]The current (default or latest) response to this question. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedChoiceArrayQuestion(Interview interview, String tag) Create a question with a nominated tag.protectedChoiceArrayQuestion(Interview interview, String tag, String... choices) Create a question with a nominated tag. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear any response to this question, resetting the value back to its initial state.String[]Get the set of legal responses for this question.boolean[]Get the default response for this question.String[]Get the display values for the set of choices for this question.Get the response to this question as a string.boolean[]getValue()Get the current (default or latest) response to this question.boolean[]Verify this question is on the current path, and if it is, return the current value.booleanCheck if the question always has a valid response.booleanCheck if the question currently has a valid response.protected voidSave the value for this question in a dictionary, using the tag as the key.protected voidsetChoices(String... choices) Set the names of the choices for this question.protected voidsetChoices(String[] choices, boolean localize) Set the names of the choices for this question.protected voidsetChoices(String[] choices, String... displayChoices) Set the names of the choices for this question.voidsetDefaultValue(boolean... v) Set the default response for this question, used by the clear method.voidsetValue(boolean... newValue) Set the current value.voidSet the current value.Methods inherited from class Question
addMarker, equals, export, getChecklistItems, getHelpID, getImage, getInterview, getKey, getNext, getResourceString, getResourceString, getSummary, getTag, getText, getTextArgs, hashCode, hasMarker, isEnabled, isHidden, load, reload, removeMarker, setHelpID, setImage, setImage, setSummary, setText
-
Field Details
-
value
protected boolean[] valueThe current (default or latest) response to this question.
-
-
Constructor Details
-
ChoiceArrayQuestion
-
ChoiceArrayQuestion
Create a question with a nominated tag.- Parameters:
interview- The interview containing this question.tag- A unique tag to identify this specific question.choices- The names of the choices, which can each be selected (true) or not (false).- Throws:
NullPointerException- if choices is null
-
-
Method Details
-
setChoices
Set the names of the choices for this question. The current value will be set to all false;- Parameters:
choices- The set of names of the choices for this question.localize- if false, the choices will be used directly as the display choices; otherwise the choices will be used to construct keys to get localized values from the interview's resource bundle.- Throws:
NullPointerException- if choices is null- See Also:
-
setChoices
Set the names of the choices for this question.- Parameters:
choices- The set of names of the choices for this question.displayChoices- An array of strings to be presented to the user that identify the choices for this question. The value can also be null, to indicate that the display choices should be determined automatically by obtaining localized values for the entries in the choices array.- Throws:
NullPointerException- if choices is null.IllegalArgumentException- if displayChoices is not null and is a different length than choices.- See Also:
-
getChoices
Get the set of legal responses for this question.- Returns:
- The set of possible responses for this question.
- See Also:
-
setChoices
Set the names of the choices for this question. The choices will also be used as the display choices. The current value will be set to all false;- Parameters:
choices- The set of names for the choices for this question.- Throws:
NullPointerException- if choices is null- See Also:
-
getDisplayChoices
Get the display values for the set of choices for this question. The display values will typically be different from the standard values if they have been localized.- Returns:
- The display values for the set of possible responses for this question.
- See Also:
-
getDefaultValue
public boolean[] getDefaultValue()Get the default response for this question.- Returns:
- the default response for this question.
- See Also:
-
setDefaultValue
public void setDefaultValue(boolean... v) Set the default response for this question, used by the clear method.- Parameters:
v- the default response for this question.- See Also:
-
getValue
public boolean[] getValue()Get the current (default or latest) response to this question.- Returns:
- The current value.
- Throws:
IllegalStateException- if no choices have been set, defining the set of responses to this question- See Also:
-
setValue
Set the current value. -
setValue
public void setValue(boolean... newValue) Set the current value.- Parameters:
newValue- The new value: one boolean per choice, indicating whether the corresponding choice is selected or not.- See Also:
-
getValueOnPath
Verify this question is on the current path, and if it is, return the current value.- Returns:
- the current value of this question
- Throws:
Interview.NotOnPathFault- if this question is not on the current path- See Also:
-
getStringValue
Description copied from class:QuestionGet the response to this question as a string.- Specified by:
getStringValuein classQuestion- Returns:
- a string representing the current response to this question, or null.
- See Also:
-
isValueValid
public boolean isValueValid()Description copied from class:QuestionCheck if the question currently has a valid response.- Specified by:
isValueValidin classQuestion- Returns:
- true if the question currently has a valid response, and false otherwise.
-
isValueAlwaysValid
public boolean isValueAlwaysValid()Description copied from class:QuestionCheck if the question always has a valid response. This may be true, for example, for a choice question with a default response.- Specified by:
isValueAlwaysValidin classQuestion- Returns:
- true if the question always has a valid response, and false otherwise.
-
clear
-
save
-