Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.interview
Class ListQuestion

    java.lang.Object
      com.sun.interview.Question
          com.sun.interview.ListQuestion

    public abstract class ListQuestion

extends Question

A `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.

Nested Class Summary
`static class` | `ListQuestion.Body` A special subtype of Interview to use for the questions in the body of a loop.

Field Summary

Fields inherited from class com.sun.interview.Question
`interview, key, tag`

Constructor Summary
`protected` | `ListQuestion(Interview interview, java.lang.String tag)` Create a question with a nominated tag.

Method Summary
`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.

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`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ListQuestion

    protected ListQuestion(Interview interview,
                           java.lang.String tag)

  Create a question with a nominated tag.

  Parameters:
    `interview` - The interview containing this question.
    `tag` - A unique tag to identify this specific question.

Method Detail

### createBody

    public abstract ListQuestion.Body createBody(int index)

  Create a new instance of a body for this loop question. The body is a subinterview that contains the questions for the body of the loop. The body does not become one of the set of bodies for the loop until the set is updated with `setBodies(com.sun.interview.ListQuestion.Body[], int)`.

  Parameters:
    `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.
  Returns:
    a new instance of a body for this loop question

### isEnd

    public final boolean isEnd()

  Check if this is the question that appears at the beginning or at the end of the loop. When a ListQuestion is created, a sibling is automatically created that will appear at the end of the loop.

  Returns:
    false if this is the main question, that appears at the head of the loop, or true if this is the question that is automatically created to appear at the end of the lop.

### getOther

    public ListQuestion getOther()

  Get the sibling question that appears at the other end of the loop. When a ListQuestion is created, a sibling is automatically created that will appear at the end of the loop. From either of these questions, you can use this method to get at the other one.

  Returns:
    the sibling question that appears at the other end of the loop

### getSelectedBody

    public ListQuestion.Body getSelectedBody()

  Get the currently selected loop body, or null, as selected by by setValue.

  Returns:
    the currently selected loop body, or null, if none.

### getValue

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

  Returns:
    the index of the currently selected loop body, or an out of range value (typically less than zero) if none is selected
  See Also:
    `setValue(int)`

### getValueOnPath

    public int 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()

  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.

  Specified by:
    `getStringValue` in class `Question`
  Returns:
    a string representing the current response to this question, or null.
  See Also:
    `Question.setValue(String)`

### setValue

    public void setValue(int newValue)

  Set the index of the loop body to be selected. If the value is out of range, no loop body will be selected.

  Parameters:
    `newValue` - the index of the loop body to be selected
  See Also:
    `getValue()`

### setValue

    public void setValue(java.lang.String s)

  Set the index of the loop body to be selected. If the value is out of range, no loop body will be selected.

  Specified by:
    `setValue` in class `Question`
  Parameters:
    `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.
  See Also:
    `getValue()`

### isValueValid

    public boolean isValueValid()

  Check if the question currently has a valid response. For a ListQuestion, this is normally true.

  Specified by:
    `isValueValid` in class `Question`
  Returns:
    true if the question currently has a valid response, and false otherwise.

### isValueAlwaysValid

    public boolean isValueAlwaysValid()

  Check if the question always has a valid response. For a ListQuestion, this is normally false.

  Specified by:
    `isValueAlwaysValid` in class `Question`
  Returns:
    true if the question always has a valid response, and false otherwise.

### clear

    public void clear()

  Remove all the bodies currently allocated for this question, and set the value of the question to indicate no loop body selected.

  Specified by:
    `clear` in class `Question`

### getEndSummary

    public java.lang.String getEndSummary()

  Get the summary text for the end question. When a ListQuestion is created, a sibling is automatically created that will appear at the end of the loop. Override this method to override the default behavior to get the summary text from the standard resource bundle. The tag for the end question is the same as the tag for the main question, with ".end" appended.

  Returns:
    the summary text for the end question
  See Also:
    `Question.getSummary()`, `getOther()`

### getEndText

    public java.lang.String getEndText()

  Get the question text for the end question. When a ListQuestion is created, a sibling is automatically created that will appear at the end of the loop. Override this method to override the default behavior to get the question text from the standard resource bundle. The tag for the end question is the same as the tag for the main question, with ".end" appended.

  Returns:
    the question text for the end question
  See Also:
    `getEndTextArgs()`, `Question.getText()`, `getOther()`

### getEndTextArgs

    public java.lang.Object[] getEndTextArgs()

  Get the formatting arguments for the question text for the end question. When a ListQuestion is created, a sibling is automatically created that will appear at the end of the loop. Override this method to override the default behavior to return null.

  Returns:
    the formatting arguments for the question text for the end question
  See Also:
    `getEndText()`, `Question.getTextArgs()`, `getOther()`

### load

    protected void load(java.util.Map data)

  Description copied from class: `Question`
  Load any state for this question from a dictionary, using the tag as the key.

  Specified by:
    `load` in class `Question`
  Parameters:
    `data` - The map from which to load the value for this question.

### save

    protected void save(java.util.Map data)

  Description copied from class: `Question`
  Save any state for this question in a dictionary, using the tag as the key.

  Specified by:
    `save` in class `Question`
  Parameters:
    `data` - The map in which to save the value for this question.

### getBodies

    public ListQuestion.Body[] getBodies()

  Get the set of bodies currently allocated within the loop.

  Returns:
    the set of bodies currently allocated within the loop
  See Also:
    `setBodies(com.sun.interview.ListQuestion.Body[], int)`

### getBodyCount

    public int getBodyCount()

  Get the number of bodies (iterations) currently allocated within the loop.

  Returns:
    the number of bodies currently allocated within the loop

### getBody

    public ListQuestion.Body getBody(int index)

  Get a specified body from the loop.

  Parameters:
    `index` - the position of the desired body within the set of bodies currently allocated within the loop.
  Returns:
    the specified body
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException` - if index does not identify a valid body

### setBodies

    public 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. The bodies will normally come from a combination of the bodies returned from getBodies() or new ones created by createBody().

  Parameters:
    `newBodies` - the set of bodies to be taken as the new set of loop bodies
    `newValue` - the index of the body which should be the selected body.
  See Also:
    `getBodies()`

### getIncompleteBodyCount

    public int getIncompleteBodyCount()

  Get the number of bodies for this loop that are currently incomplete, as determined by `ListQuestion.Body.isBodyFinishable()`.

  Returns:
    the number of bodies for this loop that are currently incomplete.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.