public abstract class ChoiceQuestion extends Question
question
to which the response is one of a number of choices.Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
value
The current (default or latest) response to this question.
|
Modifier | Constructor and Description |
---|---|
protected |
ChoiceQuestion(Interview interview,
java.lang.String tag)
Create a question with a nominated tag.
|
protected |
ChoiceQuestion(Interview interview,
java.lang.String tag,
java.lang.String[] choices)
Create a question with a nominated tag.
|
Modifier and Type | Method and 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.
|
java.lang.String |
getDefaultValue()
Get the default response for this question.
|
java.lang.String[] |
getDisplayChoices()
Get the display values for the set of legal responses for this question.
|
java.lang.String |
getDisplayValue()
Get the display string for the current (default or latest)
response to this question.
|
java.lang.String |
getStringValue()
Get the response to this question as a string.
|
java.lang.String |
getValue()
Get the internal value for the current (default or latest)
response to this question.
|
java.lang.String |
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 set of legal responses for this question.
|
protected void |
setChoices(java.lang.String[] choices,
boolean localize)
Set the set of legal responses for this question.
|
protected void |
setChoices(java.lang.String[] choices,
java.lang.String[] displayChoices)
Set the set of legal responses for this question.
|
void |
setDefaultValue(java.lang.String v)
Set the default response for this question,
used by the clear method.
|
protected void |
setI18NChoices(java.lang.String[] choices)
Deprecated.
Use the other setChoices() methods, which support i18n as
an option.
|
void |
setValue(java.lang.String newValue)
Set the current value.
|
addMarker, equals, export, getChecklistItems, getHelpID, getImage, getInterview, getKey, getNext, getResourceString, getResourceString, getSummary, getTag, getText, getTextArgs, hashCode, hasMarker, isEnabled, isHidden, reload, removeMarker, setImage, setImage, setSummary, setText
protected java.lang.String value
protected ChoiceQuestion(Interview interview, java.lang.String tag)
interview
- The interview containing this question.tag
- A unique tag to identify this specific question.protected ChoiceQuestion(Interview interview, java.lang.String tag, java.lang.String[] choices)
interview
- The interview containing this question.tag
- A unique tag to identify this specific question.choices
- The set of legal values for responses to this question.protected void setChoices(java.lang.String[] choices)
choices
- The set of possible responses for this question.java.lang.NullPointerException
- if choices is null.getChoices()
,
setChoices(String[], boolean)
,
setChoices(String[], String[])
protected void setChoices(java.lang.String[] choices, boolean localize)
choices
- An array of strings identifying the set of
legal responses for this question. Depending on the value of
the 'localize' argument, the strings will be used literally, or
will be used to construct keys to look up resources in the
containing interview's resource bundle, in order to get the
display strings. In both cases, the current value will always
be one of the values in the choices array.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.java.lang.NullPointerException
- if choices is null.getChoices()
,
setChoices(String[])
,
setChoices(String[], String[])
protected void setChoices(java.lang.String[] choices, java.lang.String[] displayChoices)
choices
- An array of strings identifying the set of
legal responses for this question.displayChoices
- An array of strings to be presented to
the user that identify the legal responses to 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.java.lang.NullPointerException
- if choices is null.java.lang.IllegalArgumentException
- if displayChoices is not null
and is a different length than choices.getChoices()
,
setChoices(String[])
,
setChoices(String[], boolean)
protected void setI18NChoices(java.lang.String[] choices)
choices
- The set of possible responses for this question.
Each entry in the argument array is localized by looking up
question-key.choices[i] in the standard
resource bundle used by the parent interview. If an appropriate
entry is not found, the array value (choices[i]) is
used instead.getChoices()
,
setChoices(java.lang.String[])
,
Interview.getResourceBundle()
public java.lang.String[] getChoices()
setChoices(java.lang.String[])
,
getDisplayChoices()
public java.lang.String[] getDisplayChoices()
setChoices(java.lang.String[])
,
getDisplayChoices()
public java.lang.String getDefaultValue()
setDefaultValue(java.lang.String)
public void setDefaultValue(java.lang.String v)
v
- the default response for this question.getDefaultValue()
public java.lang.String getValue()
setValue(java.lang.String)
,
getDisplayChoices()
public java.lang.String getDisplayValue()
setValue(java.lang.String)
,
getDisplayChoices()
public java.lang.String getValueOnPath() throws Interview.NotOnPathFault
Interview.NotOnPathFault
- if this question is not on the
current pathgetValue()
public java.lang.String getStringValue()
Question
getStringValue
in class Question
Question.setValue(String)
public void setValue(java.lang.String newValue)
setValue
in class Question
newValue
- The value to be set. It must be one of the valid
choices for this question, as distinct from the display choices.getValue()
public boolean isValueValid()
Question
isValueValid
in class Question
public boolean isValueAlwaysValid()
Question
isValueAlwaysValid
in class Question
public void clear()
protected void load(java.util.Map data)
Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.