Package com.sun.interview
Class ChoiceArrayQuestion
- java.lang.Object
-
- com.sun.interview.Question
-
- com.sun.interview.ChoiceArrayQuestion
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ChoiceArrayQuestion(Interview interview, java.lang.String tag)
Create a question with a nominated tag.protected
ChoiceArrayQuestion(Interview interview, java.lang.String tag, java.lang.String[] choices)
Create a question with a nominated tag.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear any response to this question, resetting the value back to its initial state.java.lang.String[]
getChoices()
Get the set of legal responses for this question.boolean[]
getDefaultValue()
Get the default response for this question.java.lang.String[]
getDisplayChoices()
Get the display values for the set of choices for this question.java.lang.String
getStringValue()
Get the response to this question as a string.boolean[]
getValue()
Get the current (default or latest) response to this question.boolean[]
getValueOnPath()
Verify this question is on the current path, and if it is, return the current value.boolean
isValueAlwaysValid()
Check if the question always has a valid response.boolean
isValueValid()
Check if the question currently has a valid response.protected void
load(java.util.Map data)
Load the value for this question from a dictionary, using the tag as the key.protected void
save(java.util.Map data)
Save the value for this question in a dictionary, using the tag as the key.protected void
setChoices(java.lang.String[] choices)
Set the names of the choices for this question.protected void
setChoices(java.lang.String[] choices, boolean localize)
Set the names of the choices for this question.protected void
setChoices(java.lang.String[] choices, java.lang.String[] displayChoices)
Set the names of the choices for this question.void
setDefaultValue(boolean[] v)
Set the default response for this question, used by the clear method.void
setValue(boolean[] newValue)
Set the current value.void
setValue(java.lang.String newValue)
Set the current value.-
Methods inherited from class com.sun.interview.Question
addMarker, equals, export, getChecklistItems, getHelpID, getImage, getInterview, getKey, getNext, getResourceString, getResourceString, getSummary, getTag, getText, getTextArgs, hashCode, hasMarker, isEnabled, isHidden, reload, removeMarker, setHelpID, setImage, setImage, setSummary, setText
-
-
-
-
Constructor Detail
-
ChoiceArrayQuestion
protected ChoiceArrayQuestion(Interview interview, java.lang.String tag)
Create a question with a nominated tag. If this constructor is used, the choices must be supplied separately.- Parameters:
interview
- The interview containing this question.tag
- A unique tag to identify this specific question.
-
ChoiceArrayQuestion
protected ChoiceArrayQuestion(Interview interview, java.lang.String tag, java.lang.String[] choices)
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:
java.lang.NullPointerException
- if choices is null
-
-
Method Detail
-
setChoices
protected void setChoices(java.lang.String[] choices)
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:
java.lang.NullPointerException
- if choices is null- See Also:
getChoices()
,getDisplayChoices()
-
setChoices
protected void setChoices(java.lang.String[] choices, boolean localize)
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:
java.lang.NullPointerException
- if choices is null- See Also:
getChoices()
,getDisplayChoices()
-
setChoices
protected void setChoices(java.lang.String[] choices, java.lang.String[] displayChoices)
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:
java.lang.NullPointerException
- if choices is null.java.lang.IllegalArgumentException
- if displayChoices is not null and is a different length than choices.- See Also:
getChoices()
,getDisplayChoices()
-
getChoices
public java.lang.String[] getChoices()
Get the set of legal responses for this question.- Returns:
- The set of possible responses for this question.
- See Also:
setChoices(java.lang.String[])
-
getDisplayChoices
public java.lang.String[] 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:
setChoices(java.lang.String[])
,getDisplayChoices()
-
getDefaultValue
public boolean[] getDefaultValue()
Get the default response for this question.- Returns:
- the default response for this question.
- See Also:
setDefaultValue(boolean[])
-
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:
getDefaultValue()
-
getValue
public boolean[] getValue()
Get the current (default or latest) response to this question.- Returns:
- The current value.
- Throws:
java.lang.IllegalStateException
- if no choices have been set, defining the set of responses to this question- See Also:
setValue(java.lang.String)
,setChoices(java.lang.String[])
-
getValueOnPath
public boolean[] getValueOnPath() throws Interview.NotOnPathFault
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:
getValue()
-
getStringValue
public java.lang.String getStringValue()
Description copied from class:Question
Get the response to this question as a string.- Specified by:
getStringValue
in classQuestion
- Returns:
- a string representing the current response to this question, or null.
- See Also:
Question.setValue(String)
-
setValue
public void setValue(java.lang.String newValue)
Set the current value.- Specified by:
setValue
in classQuestion
- Parameters:
newValue
- The value to be set. The value is broken into words, and each word must identify one of the set of choices for this question. The set of choices so identified will be set to true. Invalid choices are ignored.- See Also:
getValue()
-
isValueValid
public boolean isValueValid()
Description copied from class:Question
Check if the question currently has a valid response.- Specified by:
isValueValid
in classQuestion
- Returns:
- true if the question currently has a valid response, and false otherwise.
-
isValueAlwaysValid
public boolean isValueAlwaysValid()
Description copied from class:Question
Check if the question always has a valid response. This may be true, for example, for a choice question with a default response.- Specified by:
isValueAlwaysValid
in classQuestion
- Returns:
- true if the question always has a valid response, and false otherwise.
-
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:
getValue()
-
clear
public void clear()
Clear any response to this question, resetting the value back to its initial state.
-
load
protected void load(java.util.Map data)
Load the value for this question from a dictionary, using the tag as the key.
-
-