com.sun.interview
public abstract class ListQuestion extends Question
question
to support the construction of an
open-ended set of complex values determined by a specified subinterview.
A "loop" is created by creating an instance of a subtype of ListQuestion. The subtype must implement createBody() to create instances of the subinterview for the body of the loop. getNext() should return the next question after the loop has been completed.
Computationally, this question behaves more like a "fork" than a "loop". Semantically, it is as though all the bodies are evaluated together, in parallel, rather than serially one after the other. In the GUI presentation, it is expected that only one body is displayed at a time, and that the user can choose which body is viewed. This avoids having all the loops unrolled all the time in the display of the current path. Internally, each ListQuestion has a sibling that is created automatically, and together, these two questions bracket the set of loop bodies.
Modifier and Type | Class and Description |
---|---|
static class |
ListQuestion.Body
A special subtype of Interview to use for the questions in the body of
a loop.
|
Modifier | Constructor and Description |
---|---|
protected |
ListQuestion(Interview interview,
java.lang.String tag)
Create a question with a nominated tag.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all the bodies currently allocated for this question,
and set the value of the question to indicate no loop
body selected.
|
abstract ListQuestion.Body |
createBody(int index)
Create a new instance of a body for this loop question.
|
ListQuestion.Body[] |
getBodies()
Get the set of bodies currently allocated within the loop.
|
ListQuestion.Body |
getBody(int index)
Get a specified body from the loop.
|
int |
getBodyCount()
Get the number of bodies (iterations) currently allocated within the loop.
|
java.lang.String |
getEndSummary()
Get the summary text for the end question.
|
java.lang.String |
getEndText()
Get the question text for the end question.
|
java.lang.Object[] |
getEndTextArgs()
Get the formatting arguments for the question text for the end question.
|
int |
getIncompleteBodyCount()
Get the number of bodies for this loop that are currently incomplete,
as determined by
ListQuestion.Body.isBodyFinishable() . |
ListQuestion |
getOther()
Get the sibling question that appears at the other end of the loop.
|
ListQuestion.Body |
getSelectedBody()
Get the currently selected loop body, or null, as selected by by setValue.
|
java.lang.String |
getStringValue()
Get a string representation of the index of the currently
selected loop body, or an out of range value
(typically less than zero) if none is selected.
|
int |
getValue()
Get the index of the currently selected loop body, or an out of range
value (typically less than zero) if none is selected.
|
int |
getValueOnPath()
Verify this question is on the current path, and if it is,
return the current value.
|
boolean |
isEnd()
Check if this is the question that appears at the beginning or
at the end of the loop.
|
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 any state for this question from a dictionary,
using the tag as the key.
|
protected void |
save(java.util.Map data)
Save any state for this question in a dictionary,
using the tag as the key.
|
void |
setBodies(ListQuestion.Body[] newBodies,
int newValue)
Set the set of bodies allocated within the loop, and the
index of one which should be selected.
|
void |
setValue(int newValue)
Set the index of the loop body to be selected.
|
void |
setValue(java.lang.String s)
Set the index of the loop body to be selected.
|
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 ListQuestion(Interview interview, java.lang.String tag)
interview
- The interview containing this question.tag
- A unique tag to identify this specific question.public abstract ListQuestion.Body createBody(int index)
setBodies(com.sun.interview.ListQuestion.Body[], int)
.index
- the position that this body will have within
the set of bodies for the loop. This value should be passed
through to the Body constructor.public final boolean isEnd()
public ListQuestion getOther()
public ListQuestion.Body getSelectedBody()
public int getValue()
setValue(int)
public int getValueOnPath() throws Interview.NotOnPathFault
Interview.NotOnPathFault
- if this question is not on the
current pathgetValue()
public java.lang.String getStringValue()
getStringValue
in class Question
Question.setValue(String)
public void setValue(int newValue)
newValue
- the index of the loop body to be selectedgetValue()
public void setValue(java.lang.String s)
setValue
in class Question
s
- a string containing the index of the loop body
to be selected. If the string does not contain a valid
integer, the value will be set to -1.getValue()
public boolean isValueValid()
isValueValid
in class Question
public boolean isValueAlwaysValid()
isValueAlwaysValid
in class Question
public void clear()
public java.lang.String getEndSummary()
Question.getSummary()
,
getOther()
public java.lang.String getEndText()
getEndTextArgs()
,
Question.getText()
,
getOther()
public java.lang.Object[] getEndTextArgs()
getEndText()
,
Question.getTextArgs()
,
getOther()
protected void load(java.util.Map data)
Question
protected void save(java.util.Map data)
Question
public ListQuestion.Body[] getBodies()
setBodies(com.sun.interview.ListQuestion.Body[], int)
public int getBodyCount()
public ListQuestion.Body getBody(int index)
index
- the position of the desired body within the set of bodies
currently allocated within the loop.java.lang.ArrayIndexOutOfBoundsException
- if index does not identify a
valid bodypublic void setBodies(ListQuestion.Body[] newBodies, int newValue)
newBodies
- the set of bodies to be taken as the
new set of loop bodiesnewValue
- the index of the body which should be
the selected body.getBodies()
public int getIncompleteBodyCount()
ListQuestion.Body.isBodyFinishable()
.Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.